standards ish.
This commit is contained in:
parent
d42990d57b
commit
1db219f5f1
12
src/main.cpp
12
src/main.cpp
@ -20,7 +20,7 @@ struct game_state {
|
||||
char board[TILE_COUNT];
|
||||
};
|
||||
|
||||
int check_win_condition(struct game_state * gs, char player) {
|
||||
int check_win_condition(game_state * gs, char player) {
|
||||
int i;
|
||||
for( i = 0 ; i < 3 ; i++){
|
||||
//rows
|
||||
@ -38,7 +38,7 @@ int check_win_condition(struct game_state * gs, char player) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void display_game_state(struct game_state * gs){
|
||||
void display_game_state(game_state * gs){
|
||||
printf("turn %i:\n",gs->turn);
|
||||
for(int i = 0; i < 3; i++){
|
||||
for(int j = 0; j < 3 ; j++){
|
||||
@ -51,7 +51,7 @@ void display_game_state(struct game_state * gs){
|
||||
}
|
||||
}
|
||||
|
||||
void player_turn(struct game_state * gs, char player, int input)
|
||||
void player_turn(game_state * gs, char player, int input)
|
||||
{
|
||||
if(input > TILE_COUNT && input < 0)
|
||||
fprintf(stderr,"ERR: player input not in range.");
|
||||
@ -63,7 +63,7 @@ void player_turn(struct game_state * gs, char player, int input)
|
||||
}
|
||||
}
|
||||
|
||||
void game_turn(struct game_state * gs,int player_input){
|
||||
void game_turn(game_state * gs,int player_input){
|
||||
gs->turn++;
|
||||
player_turn(gs, 'O', player_input);
|
||||
display_game_state(gs);
|
||||
@ -73,7 +73,7 @@ void game_turn(struct game_state * gs,int player_input){
|
||||
display_game_state(gs);
|
||||
}
|
||||
|
||||
int exists_empty_tile(struct game_state * gs){
|
||||
int exists_empty_tile(game_state * gs){
|
||||
int i;
|
||||
for( i = 0; i < TILE_COUNT ; i++)
|
||||
if(!gs->board[i])
|
||||
@ -83,7 +83,7 @@ int exists_empty_tile(struct game_state * gs){
|
||||
|
||||
int main(){
|
||||
srand(time(NULL));
|
||||
struct game_state gs = {0,0};
|
||||
game_state gs = {0,0};
|
||||
while(exists_empty_tile(&gs) && gs.turn != -1){
|
||||
game_turn(&gs, get_player_input());
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user