summaryrefslogtreecommitdiff
path: root/src/game_loop.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/game_loop.c')
-rw-r--r--src/game_loop.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/game_loop.c b/src/game_loop.c
index 2c70ce2..2af20bd 100644
--- a/src/game_loop.c
+++ b/src/game_loop.c
@@ -34,11 +34,18 @@
#define STREQ(a, b) (strcmp(a, b) == 0)
static enum player_color current_player;
+#define other_player (current_player == WHITE ? BLACK : WHITE)
enum player_color get_current_player(void) { return current_player; }
-SCM scm_get_current_player(void) {
- switch (current_player) {
+SCM scm_get_current_player() {
+ return scm_player_from_c_player(current_player);
+}
+
+SCM scm_get_other_player() { return scm_player_from_c_player(other_player); }
+
+SCM scm_player_from_c_player(enum player_color player) {
+ switch (player) {
case WHITE:
return scm_from_utf8_symbol("white");
case BLACK:
@@ -85,7 +92,6 @@ enum player_color game_loop(char *player_one_strategy_path,
}
current_player = WHITE;
-#define other_player (current_player == WHITE ? BLACK : WHITE)
while (has_valid_moves(get_board(), current_player)) {
struct move move = current_player_move(
@@ -95,11 +101,11 @@ enum player_color game_loop(char *player_one_strategy_path,
}
}
-#undef other_player
-
if (player_one_strategy_path == NULL || player_two_strategy_path == NULL) {
rl_clear_history();
}
return get_winner(get_board(), current_player, white_score, black_score);
}
+
+#undef other_player