aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ctaklm.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/ctaklm.c b/src/ctaklm.c
index 5ad7e8e..e2d8cc1 100644
--- a/src/ctaklm.c
+++ b/src/ctaklm.c
@@ -139,25 +139,25 @@ print_square(const uint8_t col, const uint8_t row) {
static void
print_info(void) {
- printf("Turn: %d\nActive player: %s%s%s%s\n",
- ply/2,
+ printf("Turn: %2d, %s%s%s%s\n",
+ ply/2 + 1,
(ply & 1) ? blk : wht,
(ply & 1) ? "Black" : "White",
rst,
(ply < 2) ? " (counter-play start)" : "");
- printf("Flats remaining: %sWhite%s %02d, %sBlack%s %02d\n",
- wht,rst,white_count & 127,
- blk,rst,black_count & 127);
- printf("Caps remaining: %sWhite%s %d, %sBlack%s %d\n",
- wht,rst,white_count >> 7,
- blk,rst,black_count >> 7);
+ printf("Flats remaining: %s%02d%s, %s%02d%s\n",
+ wht,white_count & 127,rst,
+ blk,black_count & 127,rst);
+ printf("Caps remaining: %s%d%s, %s%d%s\n",
+ wht,white_count >> 7,rst,
+ blk,black_count >> 7,rst);
}
char *gamelog = 0;
uint8_t auto_board = 0xFF, auto_info = 0xFF;
static void
-append_to_gamelog(char *line, const uint8_t win_line) {
+append_to_gamelog(const char *line, const uint8_t win_line) {
// I _could_ dynamically compute the size but ... don't let
// `perfect' be the enemy of `good' ?
char prepend[8];
@@ -195,7 +195,7 @@ handle_turn(char *line) {
// Track win state
uint8_t new_win = (won == -1);
switch (do_ptn(line)) {
- // Errors
+ // Errors
case PTN_INVALID: { puts("Invalid PTN."); break; }
case ACT_ILLEGAL: { puts("Illegal action."); break; }
case ACT_OVERFLOW: {
@@ -222,8 +222,8 @@ handle_turn(char *line) {
case PTN_VALID:
case ACT_OK: {
append_to_gamelog(line, 0);
- if (auto_info) print_info();
if (auto_board) print_board();
+ if (auto_info) print_info();
break;
}
}
@@ -244,7 +244,9 @@ main(int argc, char **argv) {
char *line;
while((line = linenoise("ctaklm> ")) != NULL) {
- if (!strncmp(line,"board",6)) {
+ if (!strncmp(line,"help",5)) {
+ puts("Valid commands: auto (board|info), board, help, info, log, square, new [56], <PTN>.");
+ } else if (!strncmp(line,"board",6)) {
print_board();
} else if (!strncmp(line,"info",5)) {
print_info();
@@ -260,7 +262,7 @@ main(int argc, char **argv) {
printf("Automatic info display %s.\n",
(auto_info) ? "Enabled" : "Disabled");
} else {
- puts("Usage: auto (board|info)");
+ puts("Usage: auto (board|info).");
}
} else if (!strncmp(line,"square",6)) {
if (strnlen(line, 9) >= 9
@@ -276,7 +278,7 @@ main(int argc, char **argv) {
} else if (strnlen(line,5) >= 5 && line[4] >= '5' && line[4] <= '6') {
new_game(line[4]-'0');
} else {
- puts("Usage: new [56]\n");
+ puts("Usage: new [56].");
}
} else {
handle_turn(line);