ahhhaha
This commit is contained in:
parent
f3c22f0916
commit
5e45df9159
|
|
@ -1,10 +1,11 @@
|
||||||
package backend;
|
package backend;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public class Grid {
|
public class Grid {
|
||||||
private int width;
|
private int width;
|
||||||
private int height;
|
private int height;
|
||||||
private int[][] grid;
|
private int[][] grid;
|
||||||
|
private int rando;
|
||||||
public Grid(int width, int height) {
|
public Grid(int width, int height) {
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
|
|
@ -26,4 +27,15 @@ public class Grid {
|
||||||
throw new IndexOutOfBoundsException("Grid position out of range");
|
throw new IndexOutOfBoundsException("Grid position out of range");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -256,6 +256,7 @@ public class Simulator extends Thread {
|
||||||
* maybe just make a constructor in there
|
* maybe just make a constructor in there
|
||||||
* and use it here
|
* and use it here
|
||||||
*/
|
*/
|
||||||
|
maingrid.fillRandom(chanceOfLife);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLoopingBorder() {
|
public boolean isLoopingBorder() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue