Random Tile Map Example

I’ve seen enough questions about how to deal out tile-based boards randomly that I think we should have an example floating around, and while Tim and Dr. Nostromo have a very good explanation of how to do this here: http://www.vassalengine.org/forum/viewtopic.php?f=6&t=1558, it is essentially based on To Be King, the editing of which module was not meant for mortal man.

Only the bare essentials for dealing a random board are included in this module. They are:

  1. Numbered locations for the tiles to end up on (in this case, zones)
  2. A global property to store the numeric value of the next SendTo location
  3. A deck of tiles, ‘always shuffled’
  4. Some type of global key command to tell the tiles to go to their spots (in this case, a deck global key command)
  5. A prototype to define the ‘deal’ process (though technically a prototype is not necessary) - receive the GKC with Trigger Action, and do:
    5a) Send To Location to the correct zone, and
    5b) Increment the global property
  6. Does Not Stack on the tiles, which is not really essential but I imagine 96% of random tile boards will want this to prevent players from accidentally moving the tiles around after they’re placed. They can still be selected with Shift-click.


P.S. Instead of sending the deal command to the tiles one at a time, I just had my deck global key command issue its deal command to all the tiles at once. This may not be thread safe! If tiles show up in weird places, specifically, on top of each other, the iteration of the global property would need to be offloaded to a helper piece. However, I haven’t seen any problems with it, yet, so for now I think this is a simpler demo without such a piece.