diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..79f4f43f8b0d4a4772a359230be953cab145bf53 --- /dev/null +++ b/README.md @@ -0,0 +1,56 @@ +# Game of life + +simple c implementation of [Conway's game of life](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life). + +## usage + +- download /clone the src folder. +- use the folling template: + +```c +#include "gol.h" +#include <stdio.h> +const unsigned int ROUNDS = 2; + +//for each colmn print the value +void print_colmn(unsigned int value) +{ + printf("%d", value); +} + +//print each row +void print_row(unsigned int line) +{ + printf("\n"); +} + +int main(int argc, char **argv) +{ + //setup a game of life struct with (24*5 cells) + gol *game = gol_setup(3, 5); + //set dead/alive cells + game->current[7] = 28; // set --- (blinker) + unsigned int round = 0; + while (1) + { + printf("round: %d \n", round++); + //print current fields + gol_each(game, &print_colmn, &print_row); + if (round > ROUNDS) + { + break; + } + //evolve one time step + gol_tick(game); + } + //free everything + gol_free(game); +} +``` + +## test + +```bash +make test +echo $? +``` \ No newline at end of file diff --git a/library.json b/library.json new file mode 100644 index 0000000000000000000000000000000000000000..05a0ccf84908f3095192877c1c0f29923e7a6703 --- /dev/null +++ b/library.json @@ -0,0 +1,27 @@ +{ + "name": "gameOfLife", + "version": "1.0.0", + "description": "A simple game of life lib", + "keywords": "gol, Game of life, John Conway", + "repository": { + "type": "git", + "url": "https://gitlab.com/clemo/gameOfLife/" + }, + "authors": [ + { + "name": "Clemens Burger", + "email": "clemo@cbcode.at", + "url": "https://cbcode.at" + } + ], + "license": "MIT", + "homepage": "https://gitlab.com/clemo/gameOfLife/-/blob/master/README.md", + "frameworks": "*", + "platforms": "*", + "export": { + "include": [ + "src/*.c[pp]", + "src/*.h" + ] + } +} \ No newline at end of file