Skip to content

Commit 718a7a0

Browse files
committed
add FUNDING.yml
1 parent 5ad9b84 commit 718a7a0

File tree

6 files changed

+69
-30
lines changed

6 files changed

+69
-30
lines changed

.github/.github/FUNDING.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# These are supported funding model platforms
2+
3+
github: ripred
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

MicroChess.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ enum print_t : uint8_t {
9797
#define getbit(_A, _B) ((char*)(_A))[(_B) / 8] & (0x80 >> ((_B) % 8))
9898

9999
// The max and min range for piece values
100-
#define MAX_VALUE ((long const)(LONG_MAX/2))
101-
#define MIN_VALUE ((long const)(0 - MAX_VALUE))
100+
#define MAX_VALUE ((long)(LONG_MAX/2))
101+
#define MIN_VALUE ((long)(0 - MAX_VALUE))
102102

103103
// The number of locations on the game board
104104
static index_t constexpr BOARD_SIZE = 64u;

MicroChess.ino

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@
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()
12211234
void 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 };

chessutil.cpp

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
*/
99
#include "HardwareSerial.h"
1010
#include <Arduino.h>
11+
12+
#ifndef ESP32
1113
#include <avr/pgmspace.h>
14+
#endif
15+
1216
#include "MicroChess.h"
1317
#include <stdarg.h>
1418
#include <ctype.h>
@@ -34,8 +38,7 @@ Color const book_t::side = White;
3438
piece_gen_t::piece_gen_t(move_t &m) :
3539
move(m),
3640
wbest(m),
37-
bbest(m)
38-
{
41+
bbest(m) {
3942
init(board, game);
4043
}
4144

@@ -45,8 +48,7 @@ piece_gen_t::piece_gen_t(move_t &m, move_t &wb, move_t &bb, generator_t *cb, Boo
4548
wbest(wb),
4649
bbest(bb),
4750
callme(cb),
48-
evaluating(eval)
49-
{
51+
evaluating(eval) {
5052
init(board, game);
5153
}
5254

@@ -202,16 +204,13 @@ int debug(char const * const progmem, ...) {
202204

203205

204206
#if ARDUINO_ARCH_RENESAS
205-
206207
#include <stdio.h>
207-
208208
char *dtostrf (double val, signed char width, unsigned char prec, char *sout) {
209209
char fmt[20];
210210
sprintf(fmt, "%%%d.%df", width, prec);
211211
sprintf(sout, fmt, val);
212212
return sout;
213213
}
214-
215214
#endif
216215

217216
// This function wraps the dtostrf(...) function combined with
@@ -297,8 +296,9 @@ Bool check_mem(index_t const
297296
} // check_mem(index_t const level)
298297

299298

299+
#ifndef ESP32
300300
void direct_write(index_t const pin, Bool const value) {
301-
#if not ARDUINO_ARCH_RENESAS
301+
#if not ARDUINO_ARCH_RENESAS
302302
if (!value)
303303
{
304304
if (pin > 1 && pin < 8 ) {
@@ -318,9 +318,7 @@ void direct_write(index_t const pin, Bool const value) {
318318
bitSet (PORTB, (pin-8)); // == digitalWrite(pin,HIGH) for pins 8-12
319319
}
320320
}
321-
322-
#else
323-
321+
#else
324322
if (!value)
325323
{
326324
if (pin > 1 && pin < 8 ) {
@@ -339,10 +337,12 @@ void direct_write(index_t const pin, Bool const value) {
339337
digitalWrite(pin, HIGH);
340338
}
341339
}
340+
#endif // #if not ARDUINO_ARCH_RENESAS
342341

343-
#endif // #if not ARDUINO_ARCH_RENESAS
344-
}
345-
342+
} // direct_write(index_t const pin, Bool const value)
343+
#else
344+
void direct_write(index_t const /* pin */, Bool const /* value */) { }
345+
#endif
346346

347347
#if 0
348348

@@ -855,9 +855,11 @@ void show_time(uint32_t ms)
855855
// runtime memory usage functions
856856
#include <unistd.h>
857857

858-
858+
#ifdef ESP32
859+
int freeMemory() { return 0; }
860+
#else
859861
int freeMemory() {
860-
#ifdef __arm__
862+
#ifdef __arm__
861863
// should use uinstd.h to define sbrk but Due causes a conflict
862864
// extern "C" { char* sbrk(int incr); }
863865
#else // __ARM__
@@ -872,4 +874,5 @@ int freeMemory() {
872874
#else // __arm__
873875
return __brkval ? &top - __brkval : &top - __malloc_heap_start;
874876
#endif // __arm__
875-
}
877+
}
878+
#endif

led_strip.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <stdint.h>
1111
#include "MicroChess.h"
1212

13-
#if not ARDUINO_ARCH_RENESAS
13+
#if not ARDUINO_ARCH_RENESAS && not ESP32
1414
#include <FastLED.h>
1515

1616
FASTLED_USING_NAMESPACE

pieces.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
*
88
*/
99
#include <Arduino.h>
10+
11+
#ifndef ESP32
1012
#include <avr/pgmspace.h>
13+
#endif
14+
1115
#include <stdint.h>
1216
#include "MicroChess.h"
1317

0 commit comments

Comments
 (0)