Created
March 21, 2020 08:41
-
-
Save ApprenticeGC/03259d1e0e30ea525cfba90d7217f38f to your computer and use it in GitHub Desktop.
Show rule validation from Debug
This file contains 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
void Start() | |
{ | |
int GetAliveCountOfNeighbors(int[] neighbors) => neighbors.Aggregate(0, (acc, next) => acc + next); | |
{ | |
// 0 0 0 | |
// 0 1 0 | |
// 0 0 0 | |
var statusOfCurrentCell = 1; | |
var statusOfCurrentNeighbors = new[] {0, 0, 0, 0, 0, 0, 0, 0}; | |
var statusOfNextGeneration = GetNextGenerationStatus(statusOfCurrentCell, statusOfCurrentNeighbors); | |
var neighborAliveCount = GetAliveCountOfNeighbors(statusOfCurrentNeighbors); | |
Debug.Log($"current cell: {statusOfCurrentCell} alive neighbors: {neighborAliveCount} -> next generation status: {statusOfNextGeneration}"); | |
} | |
{ | |
// 0 0 0 | |
// 0 1 0 | |
// 0 0 1 | |
var statusOfCurrentCell = 1; | |
var statusOfCurrentNeighbors = new[] {0, 0, 1, 0, 0, 0, 0, 0}; | |
var statusOfNextGeneration = GetNextGenerationStatus(statusOfCurrentCell, statusOfCurrentNeighbors); | |
var neighborAliveCount = GetAliveCountOfNeighbors(statusOfCurrentNeighbors); | |
Debug.Log($"current cell: {statusOfCurrentCell} alive neighbors: {neighborAliveCount} -> next generation status: {statusOfNextGeneration}"); | |
} | |
{ | |
// 0 1 0 | |
// 0 1 0 | |
// 0 0 1 | |
var statusOfCurrentCell = 1; | |
var statusOfCurrentNeighbors = new[] {0, 0, 1, 0, 0, 0, 1, 0}; | |
var statusOfNextGeneration = GetNextGenerationStatus(statusOfCurrentCell, new[] {0, 0, 1, 0, 0, 0, 1, 0}); | |
var neighborAliveCount = GetAliveCountOfNeighbors(statusOfCurrentNeighbors); | |
Debug.Log($"current cell: {statusOfCurrentCell} alive neighbors: {neighborAliveCount} -> next generation status: {statusOfNextGeneration}"); | |
} | |
{ | |
// 0 1 0 | |
// 1 1 0 | |
// 0 0 1 | |
var statusOfCurrentCell = 1; | |
var statusOfCurrentNeighbors = new[] {0, 0, 1, 1, 0, 0, 1, 0}; | |
var statusOfNextGeneration = GetNextGenerationStatus(statusOfCurrentCell, new[] {0, 0, 1, 1, 0, 0, 1, 0}); | |
var neighborAliveCount = GetAliveCountOfNeighbors(statusOfCurrentNeighbors); | |
Debug.Log($"current cell: {statusOfCurrentCell} alive neighbors: {neighborAliveCount} -> next generation status: {statusOfNextGeneration}"); | |
} | |
{ | |
// 0 1 1 | |
// 1 1 0 | |
// 0 0 1 | |
var statusOfCurrentCell = 1; | |
var statusOfCurrentNeighbors = new[] {0, 0, 1, 1, 0, 0, 1, 1}; | |
var statusOfNextGeneration = GetNextGenerationStatus(statusOfCurrentCell, new[] {0, 0, 1, 1, 0, 0, 1, 1}); | |
var neighborAliveCount = GetAliveCountOfNeighbors(statusOfCurrentNeighbors); | |
Debug.Log($"current cell: {statusOfCurrentCell} alive neighbors: {neighborAliveCount} -> next generation status: {statusOfNextGeneration}"); | |
} | |
{ | |
// 0 1 1 | |
// 1 0 0 | |
// 0 0 1 | |
var statusOfCurrentCell = 0; | |
var statusOfCurrentNeighbors = new[] {0, 0, 1, 1, 0, 0, 1, 1}; | |
var statusOfNextGeneration = GetNextGenerationStatus(statusOfCurrentCell, new[] {0, 0, 1, 1, 0, 0, 1, 1}); | |
var neighborAliveCount = GetAliveCountOfNeighbors(statusOfCurrentNeighbors); | |
Debug.Log($"current cell: {statusOfCurrentCell} alive neighbors: {neighborAliveCount} -> next generation status: {statusOfNextGeneration}"); | |
} | |
{ | |
// 0 0 1 | |
// 1 0 0 | |
// 0 0 1 | |
var statusOfCurrentCell = 0; | |
var statusOfCurrentNeighbors = new[] {0, 0, 1, 1, 0, 0, 0, 1}; | |
var statusOfNextGeneration = GetNextGenerationStatus(statusOfCurrentCell, new[] {0, 0, 1, 1, 0, 0, 0, 1}); | |
var neighborAliveCount = GetAliveCountOfNeighbors(statusOfCurrentNeighbors); | |
Debug.Log($"current cell: {statusOfCurrentCell} alive neighbors: {neighborAliveCount} -> next generation status: {statusOfNextGeneration}"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment