Skip to content

Instantly share code, notes, and snippets.

Created March 30, 2013 00:53
Show Gist options
  • Save anonymous/5274745 to your computer and use it in GitHub Desktop.
Save anonymous/5274745 to your computer and use it in GitHub Desktop.
Method that takes a seed in a int[][] filled with 2s to randomly generate select of 1s from initial seed position.
public void seedEarth(int coord1, int coord2, int probStat, int probDec) {
if(coord1 < gridSize && coord2 < gridSize && coord1 >= 0 && coord2 >= 0) {
if(grid[coord1][coord2]!= 1){
grid[coord1][coord2] = 1;
if(randomGen.nextInt(100) <= 100 - probStat) {
probStat = probStat + probDec;
seedEarth(coord1 -1,coord2, probStat, probDec);
}
if(randomGen.nextInt(100) <= 100 - probStat) {
probStat = probStat + probDec;
seedEarth(coord1, coord2-1, probStat, probDec);
}
if(randomGen.nextInt(100) <= 100 - probStat) {
probStat = probStat + probDec;
seedEarth(coord1+1, coord2, probStat, probDec);
}
if(randomGen.nextInt(100) <= 100 - probStat) {
probStat = probStat + probDec;
seedEarth(coord1, coord2+1, probStat, probDec);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment