IN101 project on Conway's Game of Life
Macros | Functions
naive_conway.h File Reference

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

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

Go to the source code of this file.

Functions

int naive_count_neighbors (universe u, int row, int column, bool consider_torus)
 Count alive neighbors of a cell in a given universe. More...
 
universe naive_step (universe u, bool consider_torus)
 Get a naive universe's next iteration.
Decrements the universe's step_nb parameter by one. More...
 
universe naive_simulation (universe u, bool print_to_console, bool generate_images, bool consider_torus)
 Get the final state of a universe, according to its step_nb parameter. More...
 

Detailed Description

Header file for a naive implementation of Conway's game of life simulation.

Author
Victor Colomb (vic.c.nosp@m.ol@h.nosp@m.otmai.nosp@m.l.fr)
Date
2021-02-22

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.

Stepper works the following way:

API

Function Documentation

◆ naive_count_neighbors()

int naive_count_neighbors ( universe  u,
int  row,
int  column,
bool  consider_torus 
)

Count alive neighbors of a cell in a given universe.

Parameters
uuniverse
row
column
consider_torustrue to consider the universe as a torus
Returns
number of alive neighbors of the given cell

◆ naive_simulation()

universe naive_simulation ( universe  u,
bool  print_to_console,
bool  generate_images,
bool  consider_torus 
)

Get the final state of a universe, according to its step_nb parameter.

Parameters
uuniverse
print_to_consoletrue to print each step to the console
generate_imagestrue to generate images
consider_torustrue to consider the universe as a torus
Returns
the universe's final state

◆ naive_step()

universe naive_step ( universe  u,
bool  consider_torus 
)

Get a naive universe's next iteration.
Decrements the universe's step_nb parameter by one.

Parameters
uuniverse
consider_torustrue to consider the universe as a torus
Returns
the given universe's next iteration