aboutsummaryrefslogtreecommitdiff
path: root/src/ctaklm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ctaklm.c')
-rw-r--r--src/ctaklm.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/ctaklm.c b/src/ctaklm.c
index d790769..0948fa7 100644
--- a/src/ctaklm.c
+++ b/src/ctaklm.c
@@ -22,6 +22,7 @@
#include <string.h>
#include <tak.h>
+#include <tps.h>
#include <negamax.h>
static const char *blk = "\033[41m", *wht = "\033[44m";
@@ -220,7 +221,7 @@ handle_turn(char *line) {
uint8_t new_win = (won == 0xFF);
switch (do_ptn(line)) {
// Errors
- case PTN_INVALID: { puts("Invalid PTN."); return -1; break; }
+ case ACT_INVALID_PTN: { puts("Invalid PTN."); return -1; break; }
case ACT_ILLEGAL: { puts("Illegal action."); return -1; break; }
case ACT_OVERFLOW: {
puts("Move would cause internal overflow, select another.");
@@ -244,7 +245,6 @@ handle_turn(char *line) {
break;
}
// Valid, append to game log
- case PTN_VALID:
case ACT_OK: {
append_to_gamelog(line, 0);
if (auto_board) print_board();
@@ -274,7 +274,7 @@ load_ptn(const char* fn) {
if (fh == NULL) return EXIT_FAILURE;
int space1, space2;
- enum E_RESULT r;
+ enum ACT_RESULT r;
ssize_t read;
size_t alloc_size;
@@ -315,7 +315,6 @@ load_ptn(const char* fn) {
if (line) free(line);
fclose(fh);
-
return EXIT_SUCCESS;
}
@@ -348,16 +347,12 @@ negamax_turn(void) {
float minimax = negamax_generate();
putchar('\n');
// Failed to find a move?
- if (minimax <= -infty) {
- puts("Opponent failed to find a move!");
- return EXIT_FAILURE;
- } else {
- printf("Result: %s (%.2f, checked %.1e)\n",
- negamax_ptn,
- minimax*100.0,
- num_check);
- return handle_turn(negamax_ptn);
- }
+ if (minimax <= -infty) puts("Opponent concedes!");
+ printf("Result: %s (%.2f, checked %.1e)\n",
+ negamax_ptn,
+ minimax*100.0,
+ num_check);
+ return handle_turn(negamax_ptn);
} else {
return EXIT_FAILURE;
}
@@ -366,8 +361,9 @@ negamax_turn(void) {
static int
input_is_not_turn(const char *line) {
if (!strcmp(line,"help")) {
- puts("Valid commands: auto (board|info), board, depth [0-9], eval, help,\
-info, load, log, new, play (b|w), self-play, square <col><row>, <PTN>.");
+ puts("Valid commands: auto (board|info), board, depth [0-9], eval,\
+ help, info, load <file.ptn>, log, new, play (b|w), self-play, square\
+ <col><row>, tps, <PTN>.");
} else if (!strcmp(line,"board")) {
print_board();
} else if (!strcmp(line,"info")) {
@@ -385,6 +381,10 @@ info, load, log, new, play (b|w), self-play, square <col><row>, <PTN>.");
puts(gamelog);
} else if (!strcmp(line,"new")) {
new_game(5);
+ } else if (!strcmp(line,"tps")) {
+ char buf[1000];
+ generate_tps(buf);
+ puts(buf);
} else if (!strcmp(line,"self-play")) {
while (negamax_turn() == 0);
} else if (!strncmp(line,"depth",5)) {