Header file for a naive implementation of Conway's game of life universe structure.
More...
#include <stdio.h>
#include <string.h>
Go to the source code of this file.
|
struct | universe |
| Structure representing a universe: width, height, number of simulation steps and current cells state. More...
|
|
Header file for a naive implementation of Conway's game of life universe structure.
- Author
- Victor Colomb (vic.c.nosp@m.ol@h.nosp@m.otmai.nosp@m.l.fr)
- Date
- 2021-02-17
Naive implementation of the Conway's game of life:
The universe's size if given and constant.
The universe state is recorded using a character list (string) following the convention .
for dead and o
for alive.
API
- structure
struct universe
recording height, width, number of steps and cell list of a universe
- type
universe
referring to the struct universe
structure
- function
naive_universe_get_cell
cell getter
- function
naive_universe_update_cell
cell setter, modifies the given universe
- function
print_naive_cells
to print a universe's cells state
- function
print_naive_universe
to print a universe to the console
- function
prettyprint_naive_universe
to pretty-print a universe to the console
◆ naive_universe_get_cell()
char naive_universe_get_cell |
( |
universe |
u, |
|
|
int |
row, |
|
|
int |
column |
|
) |
| |
Get a cell from a universe.
- Parameters
-
- Precondition
row
and column
should be inferior respectively to the height and width of the universe.
- Returns
.
if the cell is dead and 0
if it is alive
◆ naive_universe_update_cell()
void naive_universe_update_cell |
( |
universe |
u, |
|
|
int |
row, |
|
|
int |
column, |
|
|
char |
state |
|
) |
| |
Update a given cell from a universe to a given state.
- Parameters
-
u | universe |
row | |
column | |
state | true for alive, false for dead |
◆ prettyprint_naive_universe()
void prettyprint_naive_universe |
( |
universe |
u | ) |
|
Pretty-prints a universe to the console.
The universe is formatted as follows:
Universe width: {width}
Universe height: {height}
Number of steps: {number of steps}
Universe cells state:
=====================
- Parameters
-
◆ print_naive_cells()
Print a universe's cells state.
- Parameters
-
◆ print_naive_universe()
Print a universe to the console.
The universe is formatted as follows:
{width} {height}
{number of steps}
Array of cells, . representing a dead cell and 0 a live one.
- Parameters
-