Skip to content

Instantly share code, notes, and snippets.

@lucasreta
Created December 3, 2020 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucasreta/851826d84362a3b2a89a3f0a3bc594de to your computer and use it in GitHub Desktop.
Save lucasreta/851826d84362a3b2a89a3f0a3bc594de to your computer and use it in GitHub Desktop.
reduced version of cligol's main.c file for medium article
#include "headers/config.h"
#include "headers/custom_string.h"
void compute (int neighbors[BOARD_HEIGHT][BOARD_WIDTH], int board[BOARD_HEIGHT][BOARD_WIDTH]);
void randomize (int board[BOARD_HEIGHT][BOARD_WIDTH]);
void clear () { printf ("\033[H\033[J"); }
void show (int board[BOARD_HEIGHT][BOARD_WIDTH]);
void move (int board[BOARD_HEIGHT][BOARD_WIDTH]);
void display_loop (struct t_board *board, int controllable);
void file_write (int board[BOARD_HEIGHT][BOARD_WIDTH]);
struct t_board file_read_or_create ();
int main (int c, char **v)
{
struct t_board board = file_read_or_create ();
int display = (c > 1) ? atoi (v[1]) : 0;
int controllable = (c > 2) ? atoi (v[2]) : 0;
if (display != 1)
{
move (board.grid);
}
else
{
display_loop (&board, controllable);
}
file_write (board.grid);
return 0;
}
// +100 lines of function implementations...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment