Sk3letr0n
August 28th, 2009, 12:54 PM
In my code I have an array that holds a bunch of strucs. Those structs have 4 bool values.
What I'm trying to do is have a while loop that runs until the total number has been reached and inside the loop there are 4 if statements that check to make sure all of these bool values are set to true, and if they are it sets one of them to true.
What I'm trying to do is have it do is call these if statements randomly so that they are not always in the same order of bool1, bool2, bool3, bool4. But of course these if statements also have another if statement inside so there is possible that even though one of these is picked at random there is still a chance that it will not go because the if statement inside it doesn't allow the change.
Bascially it's for a game I'm working on. there is squares, what I need to do is pick a random square from the one that I'm currently on.
so:
_ _ _
|+|X|+|
|_|_|X|
|+|_|+|
+ = wall
X = not walkable
so I need to pick either left, or down. How can I do this randomly?
Because if it was just randomly between 4 and it happens to choose up first. it is not walkable to that loop would be wasted. Please help thanks.
What I'm trying to do is have a while loop that runs until the total number has been reached and inside the loop there are 4 if statements that check to make sure all of these bool values are set to true, and if they are it sets one of them to true.
What I'm trying to do is have it do is call these if statements randomly so that they are not always in the same order of bool1, bool2, bool3, bool4. But of course these if statements also have another if statement inside so there is possible that even though one of these is picked at random there is still a chance that it will not go because the if statement inside it doesn't allow the change.
Bascially it's for a game I'm working on. there is squares, what I need to do is pick a random square from the one that I'm currently on.
so:
_ _ _
|+|X|+|
|_|_|X|
|+|_|+|
+ = wall
X = not walkable
so I need to pick either left, or down. How can I do this randomly?
Because if it was just randomly between 4 and it happens to choose up first. it is not walkable to that loop would be wasted. Please help thanks.