diff options
| author | tslil <tslil@posteo.de> | 2021-01-16 14:52:56 -0500 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2026-08-28 19:37:41 +0100 |
| commit | 2ad167622077b875a3d4157d27690a575c9248af (patch) | |
| tree | 37beb7087d2d8cb4f5a70e8eba02bed68370a288 /include/ct1986.c | |
| parent | 50b9955b040005e489127a11cf9c1648438a6266 (diff) | |
Starting work on MCU port
Diffstat (limited to 'include/ct1986.c')
| -rw-r--r-- | include/ct1986.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/include/ct1986.c b/include/ct1986.c index a3b089e..4537fa5 100644 --- a/include/ct1986.c +++ b/include/ct1986.c @@ -186,8 +186,8 @@ ct1986_minimax(const uint8_t cur_depth, const uint8_t max_depth, float optimal = (min) ? infty : -infty; // Step across the board - for (uint8_t row = 0; row < board_size; row++) { - for (uint8_t col = 0; col < board_size; col++) { + for (uint8_t row = 0; row < 5; row++) { + for (uint8_t col = 0; col < 5; col++) { // Try all valid actions for this square. Is it empty? const uint8_t loc = THE_COORDS(col, row); const uint8_t count = COUNT_AT(loc); @@ -198,17 +198,17 @@ ct1986_minimax(const uint8_t cur_depth, const uint8_t max_depth, // better than manually unrolling this. Sufficiently smart // compilers? - uint16_t colours_backup[board_size]; - uint8_t celldat_backup[board_size], drops[board_size-1]; + uint16_t colours_backup[5]; + uint8_t celldat_backup[5], drops[5-1]; // Back up the row of the board - for (uint8_t y = 0; y < board_size; y++) { + for (uint8_t y = 0; y < 5; y++) { colours_backup[y] = colours[THE_COORDS(col, y)]; celldat_backup[y] = celldat[THE_COORDS(col, y)]; } for (enum MOVE_DIRECTION dir = M_UP; dir <= M_RIGHT; dir++) { // Back-up the column once we start looking horizontally if (dir == M_LEFT) { - for (uint8_t x = 0; x < board_size; x++) { + for (uint8_t x = 0; x < 5; x++) { colours_backup[x] = colours[THE_COORDS(x, row)]; celldat_backup[x] = celldat[THE_COORDS(x, row)]; } @@ -217,7 +217,7 @@ ct1986_minimax(const uint8_t cur_depth, const uint8_t max_depth, // just try everything... // For every number of steps - for (uint8_t steps = 1; steps < board_size && steps <= count; steps++) { + for (uint8_t steps = 1; steps < 5 && steps <= count; steps++) { uint8_t idx, carry; for (idx = 0; idx < steps; idx++) drops[idx]=0; idx = 0; @@ -227,7 +227,7 @@ ct1986_minimax(const uint8_t cur_depth, const uint8_t max_depth, drops[idx]++; do { if (carry) { drops[++idx]++; carry = 0;} - if (drops[idx] > count || drops[idx] > board_size) { + if (drops[idx] > count || drops[idx] > 5) { drops[idx] = 1; carry = 1; } } while (carry && idx < steps); @@ -247,12 +247,12 @@ ct1986_minimax(const uint8_t cur_depth, const uint8_t max_depth, }); // Reset the board data if (dir <= M_DOWN) { - for (uint8_t y = 0; y < board_size; y++) { + for (uint8_t y = 0; y < 5; y++) { colours[THE_COORDS(col, y)] = colours_backup[y]; celldat[THE_COORDS(col, y)] = celldat_backup[y]; } } else { - for (uint8_t x = 0; x < board_size; x++) { + for (uint8_t x = 0; x < 5; x++) { colours[THE_COORDS(x, row)] = colours_backup[x]; celldat[THE_COORDS(x, row)] = celldat_backup[x]; } |
