09.03.2015, 18:33
Basically I need to be able to select a random index from an iterator and use that index in that iterator and another.
For example, I have this to get the random index of one:
" new rand = random(Iter_Count(Frontier[0]))"
But how would I return that index from two iterators (Frontier[0] and Frontier[1])?
The iterator will always have the same amount, one is the X of a cell and the other is the Y of a cell. The index represents cells stored.
More parts of the code:
The iterator and inserting cells:
Where I need to draw a marble from the bag:
I've tried (but got an expected token ';' error on both lines):
For example, I have this to get the random index of one:
" new rand = random(Iter_Count(Frontier[0]))"
But how would I return that index from two iterators (Frontier[0] and Frontier[1])?
The iterator will always have the same amount, one is the X of a cell and the other is the Y of a cell. The index represents cells stored.
More parts of the code:
The iterator and inserting cells:
pawn Код:
new Iterator:Frontier[2]<MAX_CELL_SIZE>;
Iter_Init(Frontier);
for(new X=0;X<X_SIZE;X++) for(new Y=0;Y<Y_SIZE;Y++)
{
if(!(X==0||X==X_SIZE-1||Y==0||Y==Y_SIZE-1))
{
if(Current[0] != X && Current[1] != Y &&
(CELL[X][Y-1][in]&&CELL[X][Y+1][in]&&CELL[X-1][Y][in]&&CELL[X+1][Y][in]))
//!WALLS_COLOR
Iter_Add(Frontier[0], X);
Iter_Add(Frontier[1], Y);
}
}
pawn Код:
new rand = random(Iter_Count(Frontier[0]))
RandomCell[0] = //What do I put here to get data from the index (rand) of Frontier[0]?
RandomCell[1] = //What do I put here to get data from the index (rand) of Frontier[1]?
pawn Код:
new rand = random(Iter_Count(Frontier[0]))
RandomCell[0] = Iter_Prev(Frontier[0], rand+1);
RandomCell[1] = Iter_Prev(Frontier[1], rand+1);