I wrote a program that simulates the Game of Life. Basically the world is implemented by a bi-dimensional std::vector of bool. If the bool is true the cell is alive, if is false the cell is dead. The output of the program is the system at each time step, completely in ASCII code:
[ ][0][ ]
[ ][ ][0]
[0][0][0]
The problem is that the program runs obviously fast and each time step is printed too quickly: I can’t see how the system evolves. Is there some trick to slow down the output (or directly the program)?
EDIT: I’m on Mac OS X 10.7. My compiler is GCC 4.7.
You can use standard C++ (C++11):
Alternatively, you could use a library that lets you specify an interval at which to call your draw function. OS X has Grand Central Dispatch (a.k.a. libdispatch). Using GCD you could create a dispatch timer source that calls your draw function with a specified frequency.
libdispatch reference