-
Foreach Random
I'm always told to use ForEach loops instead of fastloops for practically everything. Well I've come across a dilemma. I want the ForEach object to iterate through some objects randomly and never pick the same one twice until the pool is refilled. Is this possible?
-
I think I have an idea on how to do it, but you might need to explain in further detail first.
-
I want the game to cycle randomly through all the provinces on the map once per game month where each one takes a turn. A month passes after all provinces have taken a turn. I was able to pull it off with foreach but to my dissatisfaction it cycled through all the provinces in the order in which they were created (going backwards from 30 to 1) and I need them to be selected randomly instead.
-
You could try having a recursive for each loop for each object. This might make it random.
For example;
+Some initial conditions
-Run loop "myfirstloop" for "myobject"
+On "myfirstloop" for "myobject"
+Flag 0 is off for "myobject"
+Pick a random "myobject"
-Turn Flag 0 on for "myobject"
-Run loop "myfirstloop" for "myobject"
This should effectively run through each object once and make it random at the same time.