Skip to content

Instantly share code, notes, and snippets.

@CrazyPython
Created September 7, 2019 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CrazyPython/7fe9bdd19d05be458ec84276cf01a79e to your computer and use it in GitHub Desktop.
Save CrazyPython/7fe9bdd19d05be458ec84276cf01a79e to your computer and use it in GitHub Desktop.
int[3] newArr;
{
int i = 0;
foreach (int id; neighborhood) {
if (id != 0)
newArr[i++] = id;
}
}
int nextColor;
if (newArr[0] == newArr[1]) {
nextColor = newArr[0];
} else if (newArr[0] == newArr[2]) {
nextColor = newArr[0];
} else if (newArr[1] == newArr[3]) {
nextColor = newArr[1];
} else {
// no majority, pick a random one
nextColor = newArr[truerandint(3)];
}
nextGrid[x][y] = nextColor;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment