diff options
| author | tslil clingman <tslil@posteo.de> | 2021-01-16 19:37:18 -0500 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2026-08-28 19:37:41 +0100 |
| commit | 50a7c0f04fe0fda1aaec08bb86eea75cf4664d63 (patch) | |
| tree | 23e7c1a11df4bfa1fbb7f55beb2439366c762f7e /src/mcu.c | |
| parent | 153453f34107fb5eb861c79e1f7f8b14b8649581 (diff) | |
It works, but it's too slow
Diffstat (limited to 'src/mcu.c')
| -rw-r--r-- | src/mcu.c | 70 |
1 files changed, 69 insertions, 1 deletions
@@ -2,7 +2,75 @@ #include <tak.h> #include <ct1986.h> +#define EXIT_SUCCESS 0 +#define EXIT_FAILURE -1 + +/* + * static int + * handle_turn(char *line) { + * // Track win state + * uint8_t new_win = (won == 0xFF); + * switch (do_ptn(line)) { + * // Errors + * case PTN_INVALID: { return EXIT_FAILURE; break; } + * case ACT_ILLEGAL: { return EXIT_FAILURE; break; } + * case ACT_OVERFLOW: { return EXIT_FAILURE; break; } + * // Game has ended + * case GAME_END: { + * // Did it end this turn? + * if (new_win) { + * switch (won) { + * case WIN_DRAW: { break; } + * case WIN_FLAT_BLACK: { break; } + * case WIN_FLAT_WHITE: { break; } + * case WIN_ROAD_BLACK: { break; } + * case WIN_ROAD_WHITE: { break; } + * } + * } + * if (! new_win) return EXIT_FAILURE; + * break; + * } + * // Valid, append to game log + * case PTN_VALID: + * case ACT_OK: { break; } + * } + * return EXIT_SUCCESS; + * } + */ + +static void +dot(const uint8_t depth) { + PORTD ^= _BV(4); +} + + +static int +ct1986_turn(const uint8_t max_depth) { + // Prepare progress bar + // Run the minimax + float minimax = ct1986_generate(max_depth); + // Failed to find a move? + if ((minimax <= -infty && (ply & 1) == 1) + ||(minimax >= infty && (ply & 1) == 0)) { + // puts("] Opponent concedes!"); + return EXIT_FAILURE; + } else { + do_ptn(ct1986_ptn); + return EXIT_SUCCESS; + } +} + + int main(void) { - while(1); + DDRD = _BV(0) | _BV(4); + PORTD = 0; + + reset_state(5); + ct1986_display_progress = ˙ + PORTD = _BV(0) | _BV(4); + ct1986_turn(1); + PORTD = 0; + + while (1); return 0; } |
