diff options
| author | tslil clingman <tslil@posteo.de> | 2021-01-21 01:37:07 -0500 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2026-08-28 19:37:41 +0100 |
| commit | bb4d6da7d75de116c2fb6bd50ed96d5c478afd66 (patch) | |
| tree | d867ef7848f0eb00d86c3956522633eea6b394f7 /src | |
| parent | e1c9a014420648b2799509016b4fc52dec19bc2d (diff) | |
Slight fix to game loop
Diffstat (limited to 'src')
| -rw-r--r-- | src/ct1986.c | 13 | ||||
| -rw-r--r-- | src/ctaklm.c | 8 |
2 files changed, 11 insertions, 10 deletions
diff --git a/src/ct1986.c b/src/ct1986.c index 49a1075..f697877 100644 --- a/src/ct1986.c +++ b/src/ct1986.c @@ -159,11 +159,12 @@ main(int argc, char **argv) { lcd = fopen("/dev/lcd", "w"); if (lcd == NULL) return EXIT_FAILURE; + fprintf(lcd, "%sB", esc); + fflush(lcd); + human = 0; negamax_cnn1986_search_depth = 3; new_game(5); - fprintf(lcd, "%sB", esc); - fflush(lcd); char *line = NULL; ssize_t read; @@ -182,13 +183,15 @@ main(int argc, char **argv) { human = 1; } } - } else if (read == -1) { + } else { playing = 0; break; } } - negamax_cnn1986_turn(); - human = 0; + if (playing) { + negamax_cnn1986_turn(); + human = 0; + } } fclose(lcd); diff --git a/src/ctaklm.c b/src/ctaklm.c index da807c8..95d8678 100644 --- a/src/ctaklm.c +++ b/src/ctaklm.c @@ -440,13 +440,11 @@ main(int argc, char **argv) { } } } else { - read = -1; - human = 1; + playing = 0; + break; } } - if (read == -1) { - playing = 0; - } else { + if (playing) { negamax_cnn1986_turn(); human = 0; } |
