grid and ra,dom grid done
This commit is contained in:
parent
5e45df9159
commit
1172072971
|
|
@ -8,4 +8,4 @@ public class Main {
|
|||
mjf.setVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ public class Grid {
|
|||
private int height;
|
||||
private int[][] grid;
|
||||
private int rando;
|
||||
private Random rand = new Random();
|
||||
public Grid(int width, int height) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
|
@ -31,10 +32,13 @@ public class Grid {
|
|||
public void fillRandom(float randomness) {
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
int rando = Random.nextInt(100);
|
||||
int r= (int) randomness*100;
|
||||
if(rando<r) {
|
||||
grid[y][x] = 1;}
|
||||
int rando = rand.nextInt(100);
|
||||
int r = (int) (randomness * 100);
|
||||
if (rando < r) {
|
||||
grid[y][x] = 1;
|
||||
} else {
|
||||
grid[y][x] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue