Trouble with shuffling

Hello everyone, I have another problem where I need help.
It is a bit complicated so I first have to explain how I structured my generator, I hope it will make sense to you.

I built a generator for a mission board for a port, it is for a board game about sailing warships.
Since I'd like to keep the generator setting at one, so players don't need to switch that setting constantly while playing, I want to generate five different missions every time.
The first table is this:

Table: MissionBoard
[@5 AvailableMissions]

at AvailableMissions it lists all the four different types of mission. Within there is for example a trading convoy requesting an escort. It rolls a random available nation and a fitting fleet, and then calculates a price that the traders offer based on how many ships they have. If they have a lot and very strong ships, they pay little, if they have few or weak ones, they pay more.
@RandomNationConvoy is the main table that gets called for the ship selection within each generated mission.
That table goes down to select 1d4 off of @RandomNationShips (with ! deck pick), which lists a bunch of ship classes and a random amount of them each, for example like these:
40:[![@SmallShipAmount]Random2MastShip >> implode]
30:[![@MediumShipAmount]Random3MastShip >> implode]
20:[![@LargeShipAmount]Random4MastShip >> implode]

And "RandomXMastShip" then goes into the actual list of specific named ships and picks them.

So to summarize: Available Missions -> Escort Mission -> RandomNationConvoy -> RandomNationShips -> RandomXMastShip

Now the problem is that because the amount of named ships is not a whole lot, it regularly happens if a lot of ships of a nation get rolled for a mission that for the next mission, there are not enough left. Because I don't want there to be doubles of the same ship within a particular mission. However, having duplicates between each mission is fine, since obviously it doesn't work otherwise and I get blanks. I understand from the documentation that I should use the shuffle command to make all ships available again between mission generations. However, whereever I tried to put it and whichever table that is involved with ship selection I tried to shuffle, it won't work. It will still try to pick unique ships for each set of five missions, resulting in blank spaces in the last few missions. Where do I have to put the shuffle command and what table in this tree do I really need to shuffle so I can get duplicates between each generated mission but not within each mission?

Thank you for any help.


  • I think you'd probably want the shuffle at the top of AvailableMissions. You want it to shuffle tables used by the table, so you want to call it once before each mission is generated.

  • Alternatively you can use MaxReps: 5 at the top of the generator to limit it to 5 missions. Then you dont have to try to manage multiple missions per run.

  • Thank you for the answers. I tried putting "shuffle: RandomNationShips" under AvailableMissions but it didn't work and I still got blanks.
    The second option could be a fix if a little hacky. Then I would just have to put MaxReps 1 in the other generators that are involved here, but at least that would do what I want it to do.

  • The MaxReps applies to the run itself, so you shouldn't have to touch other generator files that are being imported.

  • No no, I meant for other separate ones. For example I have some generators that handle travelling on the seas and checking for random encounters, and those would have to be MaxReps 1 obviously. But that is fine, they are done and even if I would need to change and test something I can just comment out the maxreps while doing it.

  • Can you clarify what's going on with lines like [![@SmallShipAmount]Random2MastShip >> implode]

    As you've written it here, without a space between [@SmallShipAmount] and Random2MastShip, you're trying to call a table whose name consists of whatever SmallShipAmount returns and "Random2MastShip." For example, if SmallShipAmount returns 4, you're calling a table named 4Random2MastShip.

    With a space, SmallShipAmount would say how many times to call Random2MastShip. I'm guessing this is what you intended. [![@SmallShipAmount] Random2MastShip >> implode]. That will call Random2MastShip a number of times.

    If each mission could invoke the table that includes those lines, you could easily run out of (for example) Random2MastShip entries while Random3MastShip and Random4MastShip still have entries to spare. Shuffle doesn't fix that. Instead, merge the three tables into one table. Give different weights to different entries as you see fit, but now it's one deck of ships to pick from instead of three separate decks of ships.

    If you want to allow ships to repeat on different missions, you'd want Shuffle: RandomShip (for the merged table) in the AvailableMissions table (if that's the table that creates new missions).

    If that's not what's going on, you'd do well to post more code samples. For example, I'm not sure how to interpret "select 1d4 off of @RandomNationShips (with ! deck pick)."

Leave a Comment