#include <Life001.h>
Public Member Functions | |
Life001 () | |
void | run () |
~Life001 () | |
Private Member Functions | |
void | fill () |
void | display () |
void | calculate () |
void | swap () |
Static Private Member Functions | |
static void | wait () |
static void | cls () |
Private Attributes | |
LifeMatrix * | fNow |
LifeMatrix * | fFuture |
Definition at line 9 of file Life001.h.
Life001::Life001 | ( | ) |
Game of Life invented by John Horton Conway © Bernhard Wagner, 2003.
Definition at line 219 of file Life001.cpp.
Life001::~Life001 | ( | ) |
void Life001::run | ( | ) |
Runs the game.
Definition at line 224 of file Life001.cpp.
References calculate(), display(), fill(), LifeMatrix::initRand(), and wait().
Referenced by LifeExercise::execute().
void Life001::fill | ( | ) | [inline, private] |
Fills the LifeMatrix with initial setting.
Definition at line 242 of file Life001.cpp.
References LifeMatrix::fill(), and fNow.
Referenced by run().
void Life001::display | ( | ) | [inline, private] |
Clears screen and displays the current LifeMatrix on stdout.
Definition at line 249 of file Life001.cpp.
References cls(), LifeMatrix::display(), and fNow.
Referenced by run().
void Life001::calculate | ( | ) | [inline, private] |
Death if an occupied cell has 0, 1, 4, 5, 6, 7, or 8 occupied neighbours, the organism dies (0, 1 neighbors: of loneliness; 4 thru 8: of overcrowding). Survival if an occupied cell has two or three neighbours, the organism survives to the next generation. Birth If an unoccupied cell has three occupied neighbors, it becomes occupied.
Definition at line 261 of file Life001.cpp.
References LifeMatrix::countNeighbours(), LifeMatrix::enliven(), fFuture, fNow, LifeMatrix::isAlive(), LifeMatrix::kill(), SIZE_X, SIZE_Y, and swap().
Referenced by run().
void Life001::swap | ( | ) | [inline, private] |
Swap future and now. Comparable to double buffering for raster graphics.
Definition at line 282 of file Life001.cpp.
Referenced by calculate().
void Life001::wait | ( | ) | [static, private] |
void Life001::cls | ( | ) | [static, private] |
Wrapper for clear screen functionality.
Definition at line 298 of file Life001.cpp.
Referenced by display().
LifeMatrix* Life001::fNow [private] |
Definition at line 55 of file Life001.h.
Referenced by calculate(), display(), fill(), swap(), and ~Life001().
LifeMatrix* Life001::fFuture [private] |