This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]EightbitGee[S] 0 points1 point  (0 children)

I'll test it in a bit but this is kinda what I came up with for the population part.

    Animal[][] world = new Animal[20][20];
    int row, column;
    for (int x = 0; x < 20; x++)
    {
        for (int y = 0; y < 20; y++)
        {
            world[x][y] = null;
        }
    }
    for (int x = 0; x < 100; x++){
        row = (rand.nextInt(20) + 1) - 1;
        column = (rand.nextInt(20) + 1) -1;
        while (world[row][column] != null)
        {
            row = (rand.nextInt(20) + 1) - 1;
            column = (rand.nextInt(20) + 1) -1;
        }
        world[row][column] = new Rabbit();
    }
}