diff options
| author | tslil clingman <tslil@posteo.de> | 2021-01-16 14:52:56 -0500 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2026-08-28 19:37:41 +0100 |
| commit | 153453f34107fb5eb861c79e1f7f8b14b8649581 (patch) | |
| tree | 70fc8f9c28db34fdae7c69afd02ee7de7f95a9b7 /include | |
| parent | 63ff6ead5af940356ab8f591ceffb8ae4ecf814b (diff) | |
Starting work on MCU port
Diffstat (limited to 'include')
| -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 cf46bfa..ed5888f 100644 --- a/include/ct1986.c +++ b/include/ct1986.c @@ -177,8 +177,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); @@ -189,17 +189,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)]; } @@ -208,7 +208,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; @@ -218,7 +218,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); @@ -238,12 +238,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]; } |
