Random function does not work as i wish to
<p>Im trying to make a Pacman, so im using an array[8][8], in which i have a PacMan, 2 ghosts, walls, and points that the Pacman can eat. as the pacman eats points you start to get empty spaces.</p>

<p>So i decidad to make a function random that ramdonly assign Fruits ONLY to the empty spaces, but the problem is that as more empty spaces you get the fruits start going crazy and appear all over my array. I would like to have always the same chances of getting fruits despite of the empty spaces i have.</p>

<p>Here are the methods im using, help please.</p>

<pre><code> public void AppearFruit()
{
    for(int i= 0; i&lt;_world.length; i++){
        for(int j= 0; j&lt;_world.length; j++){
            Random as = new Random(); 
            int fru = as.nextInt(20); 
            if(fru==10){
                if(_world[i][j] instanceof Empty){
                    _world[i][j] = new Fruit(i,j);  
                }  
            }           
        }
    }
}

public void DisappearFruit()
{

    for(int i= 0; i&lt;_world.length; i++){
        for(int j= 0; j&lt;_world.length; j++){
            if (_world[i][j] instanceof Fruit){
                if(contfru&gt;=3) {
                    _mundo[i][j] = new Empty(i,j);
                    contfru=0;
                }
            }
        }
    }
}
</code></pre>
