IN101 project on Conway's Game of Life
Classes | Typedefs | Functions
naive_universe.h File Reference

Header file for a naive implementation of Conway's game of life universe structure. More...

#include <stdio.h>
#include <string.h>
Include dependency graph for naive_universe.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  universe
 Structure representing a universe: width, height, number of simulation steps and current cells state. More...
 

Typedefs

typedef struct universe universe
 

Functions

char naive_universe_get_cell (universe u, int row, int column)
 Get a cell from a universe. More...
 
void naive_universe_update_cell (universe u, int row, int column, char state)
 Update a given cell from a universe to a given state. More...
 
void print_naive_cells (universe u)
 Print a universe's cells state. More...
 
void print_naive_universe (universe u)
 Print a universe to the console. More...
 
void prettyprint_naive_universe (universe u)
 Pretty-prints a universe to the console. More...
 

Detailed Description

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

Function Documentation

◆ naive_universe_get_cell()

char naive_universe_get_cell ( universe  u,
int  row,
int  column 
)

Get a cell from a universe.

Parameters
uuniverse
row
column
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
uuniverse
row
column
statetrue 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:
=====================
{universe cells}
Parameters
uuniverse

◆ print_naive_cells()

void print_naive_cells ( universe  u)

Print a universe's cells state.

Parameters
uuniverse

◆ print_naive_universe()

void print_naive_universe ( universe  u)

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
uuniverse