Skip to content

Track book index per game #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions Arduino.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#ifndef ARDUINO_H
#define ARDUINO_H
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define PROGMEM
#define pgm_read_byte(addr) (*(const uint8_t*)(addr))
#define pgm_read_word(addr) (*(const uint16_t*)(addr))
#define pgm_read_dword(addr) (*(const uint32_t*)(addr))
#define pgm_get_far_address(addr) ((uintptr_t)(addr))
#define HIGH 1
#define LOW 0
#define INPUT 0
#define OUTPUT 1
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
#define PORTB (*((volatile uint8_t*)0))
#define PORTD (*((volatile uint8_t*)0))
#define ESP32 1
#define __malloc_heap_start ((char*)0)
inline long random(long max) { return rand() % max; }
inline long random(long min, long max) { return min + rand() % (max - min); }
inline char* dtostrf(double val, signed char width, unsigned char prec, char* buf) { sprintf(buf, "%*.*f", width, prec, val); return buf; }
inline void strcpy_P(char* dest, const char* src) { strcpy(dest, src); }
class HardwareSerial {
public:
int available() { return 0; }
int availableForWrite() { return 0; }
int read() { return 0; }
size_t write(uint8_t) { return 1; }
size_t write(const char* s) { return printf("%s", s); }
size_t write(const char* s, size_t) { return printf("%s", s); }
void begin(long) {}
operator bool() const { return true; }
};
static HardwareSerial Serial;
inline void pinMode(int, int) {}
inline void digitalWrite(int, int) {}
inline void delay(int) {}
inline uint32_t millis() { static uint32_t t = 0; return t += 16; }
#endif // ARDUINO_H
7 changes: 7 additions & 0 deletions ArduinoUnitTests.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef ARDUINO_UNIT_TESTS_H
#define ARDUINO_UNIT_TESTS_H
#define unittest_setup() void unittest_setup()
#define unittest_teardown() void unittest_teardown()
#define unittest(name) void name()
#define unittest_main() int main(){unittest_setup(); test_mock(); unittest_teardown(); return 0;}
#endif // ARDUINO_UNIT_TESTS_H
4 changes: 4 additions & 0 deletions HardwareSerial.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#ifndef HARDWARESERIAL_H
#define HARDWARESERIAL_H
#include "Arduino.h"
#endif // HARDWARESERIAL_H
8 changes: 8 additions & 0 deletions avr/pgmspace.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef AVR_PGMSPACE_H
#define AVR_PGMSPACE_H
#include <stdint.h>
#define PROGMEM
#define pgm_read_byte(addr) (*(const uint8_t*)(addr))
#define pgm_read_word(addr) (*(const uint16_t*)(addr))
#define pgm_read_dword(addr) (*(const uint32_t*)(addr))
#endif // AVR_PGMSPACE_H
2 changes: 1 addition & 1 deletion chessutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ Bool check_serial()
// returns True if there is a move or False otherwise
Bool check_book()
{
static index_t index = 0;
uint8_t &index = game.book_index;

if (!game.options.openbook) { return False; }

Expand Down
1 change: 1 addition & 0 deletions game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ void game_t::init()
turn = White;

move_num = 0;
book_index = 0;

ply = 0;

Expand Down
3 changes: 3 additions & 0 deletions game.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ class game_t
// Increasing move number
uint8_t move_num;

// Index of the next opening book move
uint8_t book_index;

// The alpha and beta boundaries of our search envelope
long alpha;
long beta;
Expand Down
Loading