How does one Automate Variable Turn Order

I want to enforce turn order based on current victory points, checked when all players complete a turn. Any ideas how to adjust the Turn Counter (list and counter) based on the order of each player’s VictoryPoint property?

I sense that some sort of property indirection aught to be employed…


I had your exact same problem.

Unfortunately, there is no easy way to sort a list of numbers (like victory points). I actually submitted a feature request for some sort of victory track counter. It might be picked out and implemented in Vassal 4. See thread in the “feature requests” board.

Related to that, I had also asked earlier for the ability to vary the order in turn counter’s list programmatically (see older thread in the same “feature request” board). Again, maybe in Vassal 4.

In the meanwhile you need to do it all by yourself, and it ain’t pretty. I am using dozens of triggers and global properties and the like to accomplish this.

Module out soon, if you want to give a look at what I did ;)

For sorting the victory points, you might try an insertion sort using a deck. It would only require a handful of traits. In a couple of days, when I get a little time, I could provide an example, unless someone knows of a module which already does this.

To be more precise, it took me dozens of traits/keys because I also needed to break eventual ties according to some other player specific variables and, failing that, randomly.

I would look forward to seeing an implementation that I could draw inspiration from. Maybe after understanding an example…



I’ve written this in 3.2 in order to use named keystrokes to make it easier to see the logic, but you could replace all the named keystrokes with CTRL-SHIFT-ALT-META-INS-NUM5, whatever, and it should still work. That is, none of the other features of 3.2 are used - loops, calculated properties, Beanshell expressions, etc.
You can get a 3.2 build, if you don’t already have one, at
In this demo, I give the ‘turn markers’ pictures, so you can see the order more easily, but normally I would use invisible pieces - that is, with no graphic defined in ‘Basic Piece’.


Thanks for the example! I understand the process but am unable to follow how this module does the swap between high-low VP. You have a property that triggers on doSwap and executes RIGHT command. I can find no other reference to RIGHT (and yet the example works).

I had given some thought to the swap idea by creating a Set Global Property with N commands that update each possible element, e.g.,:
[SGP] FIRST (=0)
FirstGetsSecond $SECOND$
FirstGetsThird $THIRD$
* * * * * *
FirstGetsTemp $TEMP$

* * *

I’d then have a trigger that tests: First<Second
and executes:

I wonder what way you devised in the example you posted.


I follow your logic for performing a swap, but what is the actual sorting algorithm? Loop through last turn’s list over and over, making swaps until the new order is correct (bubble sort)? Add the players one at a time, sorting them as they’re added (insertion sort)?
Another sort-of viable alternative for a small number of players is just to explicitly list the possible orders - N! possibilities, so for 4 players, 24 possible orders. Test each one, e.g. ‘P1_VP <= P2_VP && P2_VP <= P3_VP && P3_VP <= P4_VP’, and set the turn order Global Properties directly: FIRST = P1, SECOND = P2, so on.
What my algorithm does is exploit the existing stack support to implement an insertion sort - I put a new piece on top of the deck and then, from the top down, I ask each piece if it thinks it ought to be on top of the piece above it. If so, the RIGHT keystroke moves a piece in a stack or a deck up one position (this is poorly documented, unfortunately - UP moves to the top of the stack/deck, LEFT down one position, etc.). If not, I update the LastValue accordingly - although frankly at this point the rest of the elements should be in order and you should be able to ignore the GKCs to the remainder of the stack. Whether RIGHT is issued or not, the next piece tested will be queued up according to the original stack order.

Also, note that I recommend avoiding the actual turn counter component - I don’t think you can change the turn order with that at all.


Yeah, I was thinking a bubble sort. The TurnCounter property does not seem to support any means to change order (I tried some experiments without success).

How deep can one employ indirection? It looks like I am going to need to build a TurnCounting piece that’s fully functional and place it as an AtStart stack on the main board. Joy!


I’m not sure I understand the question, because I’m a bit of a terminology n00b. I believe the answer is that in 3.1 only single indirection is supported, except on the left-hand side of a property match expression, which supports double indirection. But you can never use a reference such as: $VictoryPoints_$playerSide$$ and get anything useful out of it. You /can/ do this in 3.2 with the GetProperty method:
{ GetProperty(“VictoryPoints_” + GetProperty(“playerSide”)) }
I do recommend using your own TurnCounter piece, unfortunately. Dr. Nostromo’s To Be King module may have some very helpful examples.