3939 *
4040 */
4141#include < Arduino.h>
42- // #include <Wire .h>
42+ #include < math .h>
4343#include " MicroChess.h"
44+ // #include <Wire.h>
4445
4546// //////////////////////////////////////////////////////////////////////////////////////
4647// The game board
@@ -457,7 +458,7 @@ long make_move(piece_gen_t & gen)
457458 gen.cutoff = True;
458459 }
459460 else {
460- game.alpha = max (game.alpha , gen.move .value );
461+ game.alpha = max (( long ) game.alpha , ( long ) gen.move .value );
461462 }
462463 }
463464 else {
@@ -474,7 +475,7 @@ long make_move(piece_gen_t & gen)
474475 gen.cutoff = True;
475476 }
476477 else {
477- game.beta = min (game.beta , gen.move .value );
478+ game.beta = min (( long ) game.beta , ( long ) gen.move .value );
478479 }
479480 }
480481 else {
@@ -1174,7 +1175,7 @@ void set_game_options()
11741175
11751176 // Set the maximum ply level to continue if a move takes a piece
11761177 // The quiescent search depth is based off of the max ply level
1177- game.options .max_quiescent_ply = min (game.options .maxply + 1 , game.options .max_max_ply );
1178+ game.options .max_quiescent_ply = min (( long ) game.options .maxply + 1 , ( long ) game.options .max_max_ply );
11781179
11791180 // set the 'live update' flag
11801181 // game.options.live_update = False;
@@ -1196,17 +1197,29 @@ void set_game_options()
11961197 for (uint8_t pass = 0 ; pass < total_passes; pass++) {
11971198 for (uint8_t pin = 0 ; pin < ARRAYSZ (pins); pin++) {
11981199 pinMode (pins[pin], INPUT);
1199- some_bits ^= digitalRead (pins[pin]) << (analogRead (A2) % 42u );
1200+ #ifndef ESP32
1201+ some_bits ^= digitalRead (pins[pin]) << (analogRead (A2) % 42u );
1202+ #else
1203+ some_bits ^= digitalRead (pins[pin]) << (analogRead (2 ) % 42u );
1204+ #endif
12001205 }
12011206 }
12021207 uint8_t bits = (game.options .seed >> 11 ) & 0xFF ;
12031208 game.options .seed +=
12041209 bits +
1205- (uint32_t (analogRead (A0)) << 24 ) +
1206- (uint32_t (analogRead (A1)) << 16 ) +
1207- (uint32_t (analogRead (A2)) << 17 ) +
1208- (uint32_t (analogRead (A3)) << 11 ) +
1209- uint32_t (analogRead (A4)) +
1210+ #ifndef ESP32
1211+ (uint32_t (analogRead (A0)) << 24 ) +
1212+ (uint32_t (analogRead (A1)) << 16 ) +
1213+ (uint32_t (analogRead (A2)) << 17 ) +
1214+ (uint32_t (analogRead (A3)) << 11 ) +
1215+ uint32_t (analogRead (A4)) +
1216+ #else
1217+ (uint32_t (analogRead (2 )) << 24 ) +
1218+ (uint32_t (analogRead (2 )) << 16 ) +
1219+ (uint32_t (analogRead (2 )) << 17 ) +
1220+ (uint32_t (analogRead (2 )) << 11 ) +
1221+ uint32_t (analogRead (2 )) +
1222+ #endif
12101223 uint32_t (micros ());
12111224
12121225 game.options .seed += some_bits;
@@ -1221,7 +1234,11 @@ void set_game_options()
12211234void setup ()
12221235{
12231236 // The baud rate we will be using
1237+ #ifndef ESP32
12241238 static long constexpr baud_rate = 1000000 ;
1239+ #else
1240+ static long constexpr baud_rate = 115200 ;
1241+ #endif
12251242
12261243 // Send out a message telling the user what baud rate to set their console to
12271244 // using each baud rate one at a time, so that our message will be seen no
@@ -1258,13 +1275,15 @@ void setup()
12581275 init_led_strip ();
12591276
12601277 // Initialize the LED indicators
1278+ #ifndef ESP32
12611279 static uint8_t constexpr pins[] = { DEBUG4_PIN, DEBUG1_PIN, DEBUG2_PIN, DEBUG3_PIN };
12621280 for (uint8_t pin : pins) {
12631281 pinMode (pin, OUTPUT);
12641282 direct_write (pin, HIGH);
12651283 delay (200 );
12661284 direct_write (pin, LOW);
12671285 }
1286+ #endif
12681287
12691288 // Initialize the continuous game statistics
12701289 uint32_t state_totals[6 ] = { 0 , 0 , 0 , 0 , 0 , 0 };
0 commit comments