Storing cells in y_iterate.
#9

Quote:
Originally Posted by ******
Посмотреть сообщение
From what you've written, I don't think what you want is possible at all with y_iterate, as it doesn't work the way you seem to think it does. Values ARE indexes, so if you randomly select the value "4" from one iterator, that is stored at index "4", and getting a value from the same slot in a different iterator will get you exactly the same value.
Oh I guess you're right, I always thought it stored the values in the iterator.

Quote:
Originally Posted by Misiur
Посмотреть сообщение
For future reference, there is a way without collection of iterators:
pawn Код:
new
    Matrix[X_SIZE][Y_SIZE],
    Iterator:Matrix<X_SIZE * Y_SIZE>
;

public OnGameModeInit()
{
    //Example cells:
    for(new x = 0; x != 3; ++x) {
        for(new y = 0; y != 3; ++y) {
            Matrix[x][y] = x * y;
            Iter_Add(Matrix, x * Y_SIZE + y);
        }
    }

    //Retrieving random cell:
    new
        rnd = Iter_Random(Matrix),
        x = rnd / Y_SIZE,
        y = rnd % Y_SIZE
    ;
   
    printf("Cell at (%d, %d) value is equal %d", x, y, Matrix[x][y]);

    return 1;
}
Ok, what I need now is a way to get frontier cells only.
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: 3 Guest(s)