Storing cells in y_iterate.
#1

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:
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);
            }
        }
Where I need to draw a marble from the bag:
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]?
I've tried (but got an expected token ';' error on both lines):
pawn Код:
new rand = random(Iter_Count(Frontier[0]))
            RandomCell[0] = Iter_Prev(Frontier[0], rand+1);
            RandomCell[1] = Iter_Prev(Frontier[1], rand+1);
Reply


Messages In This Thread
Storing cells in y_iterate. - by Crayder - 09.03.2015, 18:33
Re: Storing cells in y_iterate. - by oliverrud - 09.03.2015, 20:42
Re: Storing cells in y_iterate. - by Misiur - 09.03.2015, 20:44
Re: Storing cells in y_iterate. - by Crayder - 09.03.2015, 21:17
AW: Storing cells in y_iterate. - by Nero_3D - 10.03.2015, 04:06
Re: AW: Storing cells in y_iterate. - by Crayder - 10.03.2015, 04:14
AW: Re: AW: Storing cells in y_iterate. - by Nero_3D - 10.03.2015, 13:18
Re: Storing cells in y_iterate. - by Misiur - 10.03.2015, 14:36
Re: Storing cells in y_iterate. - by Crayder - 10.03.2015, 21:24

Forum Jump:


Users browsing this thread: 6 Guest(s)