37 lines
685 B
C
37 lines
685 B
C
#ifndef GAMELOGIC_H
|
|
#define GAMELOGIC_H
|
|
|
|
#include <stdio.h>
|
|
#include <stdint.h>
|
|
#include <ncurses.h>
|
|
|
|
#define N 3
|
|
#define ROWS N
|
|
#define COLS N
|
|
#define DIAGS 2
|
|
#define TOTAL_SQUARES ROWS*COLS
|
|
#define DOF 2
|
|
|
|
typedef enum{OPEN, X, O} squarestate;
|
|
enum turn {X_TURN, O_TURN};
|
|
typedef struct position_t{
|
|
uint8_t row;
|
|
uint8_t col;
|
|
}position_t;
|
|
|
|
enum turn currturn;
|
|
// point tracker. make any of these = N and win
|
|
int8_t pts[ROWS+COLS+DIAGS];
|
|
int round_counter;
|
|
position_t cpos;
|
|
squarestate boardstate[ROWS * COLS];
|
|
void print_boardstate();
|
|
void init_gamestate();
|
|
int is_game_over();
|
|
void add_point();
|
|
void update_boardstate();
|
|
void update_gamestate(char input);
|
|
void main_loop();
|
|
|
|
#endif
|