[C#] Game Of Life: Rückwärts
-
Hallo Leute!
Ich habe einen GameOfLife-Algorythmus. Aber wie mache ich das er rückwärts rechnet?
Ich weiß wirklich nicht mehr weiter...
public void Game(bool back) { CellMatrix<bool> tmp = new CellMatrix<bool>( this.Matrix.Width, this.Matrix.Height); for (int y = 0; y < this.Matrix.Height; y++) { for (int x = 0; x < this.Matrix.Width; x++) { int neighbours = Neighbours(x, y); if (back) { // ... // } else { if (this.Matrix[x, y]) { // Cell is living if ((neighbours < 2) || (neighbours > 3)) tmp[x, y] = false; else tmp[x, y] = true; } else if (neighbours == 3) tmp[x, y] = true; else tmp[x, y] = false; } } } this.Matrix = tmp; }CellMatrix: Ist eine Matrix-Klasse von mir
Neighbours(): WIviele nachbarn?Ich hoffe, das ist alles verständlich.
Aber wie rechne ich denn nun rückwärts?
Danke schonmal im Vorraus.

-
Wie soll das gehen? Im Allgemeinen gibt es mehrere mögliche Vorgängerzustände.
-
vielleicht gelingt es dir, diese regeln umzudrehen:
Death
If an occupied cell has 0, 1, 4, 5, 6, 7, or 8 occupied neighbors, the organism dies (0, 1: of loneliness; 4 thru 8: of overcrowding).
Survival
If an occupied cell has two or three neighbors, the organism survives to the next generation.
Birth
If an unoccupied cell has three occupied neighbors, it becomes occupied.
-
Algorithmus schreibt man mit i.
-
Anmerker schrieb:
Algorithmus schreibt man mit i.
das hätte den alten Al-Hwarizmi auch nicht gestört
