From fb99bf2cf28fe236ef06c5df30d6b8cbfad9897e Mon Sep 17 00:00:00 2001 From: tslil clingman Date: Fri, 5 Feb 2021 16:24:39 -0500 Subject: Correct line clearing behaviour, EXIT_FAILURE <~ -1 --- src/ctlm.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ctlm.c b/src/ctlm.c index 09900e3..13d5a97 100644 --- a/src/ctlm.c +++ b/src/ctlm.c @@ -221,12 +221,17 @@ handle_turn(char *line) { uint8_t new_win = (won == 0xFF); switch (do_ptn(line)) { // Errors - case ACT_INVALID_PTN: { puts("Invalid PTN."); return -1; break; } - case ACT_ILLEGAL: { puts("Illegal action."); return -1; break; } + case ACT_INVALID_PTN: { + puts("Invalid PTN."); + return EXIT_FAILURE; + } + case ACT_ILLEGAL: { + puts("Illegal action."); + return EXIT_FAILURE; + } case ACT_OVERFLOW: { puts("Move would cause internal overflow, select another."); return EXIT_FAILURE; - break; } // Game has ended case GAME_END: { @@ -252,7 +257,6 @@ handle_turn(char *line) { break; } } - return EXIT_SUCCESS; } @@ -333,7 +337,7 @@ negamax_display_progress(const uint8_t cur_depth, progress = 0; } progress++; - printf("\x1B[0GComputing: %.0f/%d @ D%d ", + printf("\x1B[0G\x1B[KComputing: %.0f/%d @ D%d", progress, length, init_depth); fflush(stdout); } @@ -346,7 +350,7 @@ negamax_turn(void) { num_check = 0; progress = 0; old_depth = 0; float minimax = negamax_generate(); putchar('\n'); - // Failed to find a move? + // Failed to find a non-losing move? if (minimax <= -infty) puts("Opponent concedes!"); printf("Result: %s (%.2f, checked %.1e)\n", negamax_ptn, -- cgit v1.2.3