diff options
Diffstat (limited to 'src/game_loop.c')
-rw-r--r-- | src/game_loop.c | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/src/game_loop.c b/src/game_loop.c index 26cb988..67c9ea0 100644 --- a/src/game_loop.c +++ b/src/game_loop.c @@ -40,46 +40,46 @@ struct move (*player_one_get_move)(); struct move (*player_two_get_move)(); static struct move current_player_move(enum player_color current_player, - FILE *player_one_strategy, - FILE *player_two_strategy) { - struct move move = {-1, -1}; - - if ((current_player == WHITE && player_one_strategy == NULL) || - (current_player == BLACK && player_two_strategy == NULL)) { - move = prompt_get_move(current_player); - } else if (current_player == WHITE) { - move = get_scm_move(player_one_strategy); - } else if (current_player == BLACK) { - move = get_scm_move(player_two_strategy); - } - - return move; + char *player_one_strategy_path, + char *player_two_strategy_path) { + struct move move = {-1, -1}; + + if ((current_player == WHITE && player_one_strategy_path == NULL) || + (current_player == BLACK && player_two_strategy_path == NULL)) { + move = prompt_get_move(current_player); + } else if (current_player == WHITE) { + move = get_scm_move(player_one_strategy_path); + } else if (current_player == BLACK) { + move = get_scm_move(player_two_strategy_path); + } + + return move; } -enum player_color game_loop(FILE *player_one_strategy, - FILE *player_two_strategy) { - initialize_board(); +enum player_color game_loop(char *player_one_strategy_path, + char *player_two_strategy_path) { + initialize_board(); - if (player_one_strategy == NULL || player_two_strategy == NULL) { - using_history(); - } + if (player_one_strategy_path == NULL || player_two_strategy_path == NULL) { + using_history(); + } - current_player = WHITE; + current_player = WHITE; #define other_player (current_player == WHITE ? BLACK : WHITE) - while (has_valid_moves(current_player)) { - struct move move = current_player_move(current_player, player_one_strategy, - player_two_strategy); - if (apply_move(get_board(), current_player, move)) { - current_player = other_player; - } + while (has_valid_moves(current_player)) { + struct move move = current_player_move(current_player, player_one_strategy_path, + player_two_strategy_path); + if (apply_move(get_board(), current_player, move)) { + current_player = other_player; } + } #undef other_player - if (player_one_strategy == NULL || player_two_strategy == NULL) { - rl_clear_history(); - } + if (player_one_strategy_path == NULL || player_two_strategy_path == NULL) { + rl_clear_history(); + } - return get_winner(); + return get_winner(); } |