Created
March 30, 2013 00:53
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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