Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.