Compare commits
No commits in common. "c69d0b96d52ce620dcfe6799f9b9ce49ce6f18a3" and "e400106b55d3f76ff14c2ab370f70d146bfda2b1" have entirely different histories.
c69d0b96d5
...
e400106b55
|
|
@ -2,11 +2,8 @@
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
|
|
||||||
#include "Board.h"
|
#include "Board.h"
|
||||||
#include "Move.h"
|
#include "Move.h"
|
||||||
#include "Movegen.h"
|
|
||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
|
|
||||||
Board b = Board();
|
Board b = Board();
|
||||||
|
|
@ -47,11 +44,9 @@ void setup() {
|
||||||
b.make({0x64, 0x54, P_EMPTY});
|
b.make({0x64, 0x54, P_EMPTY});
|
||||||
b.make({0x34, 0x44, P_EMPTY});
|
b.make({0x34, 0x44, P_EMPTY});
|
||||||
b.make({0x63, 0x43, P_EMPTY});
|
b.make({0x63, 0x43, P_EMPTY});
|
||||||
b.print();
|
//b.print();
|
||||||
b.make({0x44, 0x53, P_EMPTY});
|
b.make({0x44, 0x53, P_EMPTY});
|
||||||
b.print();
|
//b.print();
|
||||||
b.unmake();
|
|
||||||
b.print();
|
|
||||||
|
|
||||||
int elapsed = micros() - startTime;
|
int elapsed = micros() - startTime;
|
||||||
Serial.print(elapsed);
|
Serial.print(elapsed);
|
||||||
|
|
|
||||||
12
Board.h
12
Board.h
|
|
@ -80,11 +80,8 @@ Board::Board() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Board::print() {
|
void Board::print() {
|
||||||
Serial.println(F("BOARD:"));
|
|
||||||
for(char i = 7; i >= 0; i--) {
|
for(char i = 7; i >= 0; i--) {
|
||||||
for(byte j = 0; j < 16; j++) {
|
for(byte j = 0; j < 16; j++) {
|
||||||
if(j == 8)
|
|
||||||
Serial.print("| ");
|
|
||||||
Serial.print(field[i*16 + j], HEX);
|
Serial.print(field[i*16 + j], HEX);
|
||||||
Serial.print(" ");
|
Serial.print(" ");
|
||||||
}
|
}
|
||||||
|
|
@ -247,20 +244,17 @@ void Board::prev_unmove() {
|
||||||
}
|
}
|
||||||
void Board::store_unmove(Unmove u) {
|
void Board::store_unmove(Unmove u) {
|
||||||
byte *ub = (byte*) &u;
|
byte *ub = (byte*) &u;
|
||||||
for(byte i = 0; i < sizeof(u); i++) {
|
for(size_t i = 0; i < sizeof(u); i++) {
|
||||||
field[PTR_UNMOVE] = ub[i];
|
|
||||||
next_unmove();
|
next_unmove();
|
||||||
|
field[PTR_UNMOVE] = ub[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Unmove Board::read_unmove() {
|
Unmove Board::read_unmove() {
|
||||||
Unmove u;
|
Unmove u;
|
||||||
byte* ptr = (byte*) &u;
|
byte* ptr = (byte*) &u;
|
||||||
for(int i = sizeof(u) - 1; i >= 0; i--) {
|
for(int i = sizeof(u) - 1; i >= 0; i--) {
|
||||||
prev_unmove();
|
|
||||||
ptr[i] = field[PTR_UNMOVE];
|
ptr[i] = field[PTR_UNMOVE];
|
||||||
#ifdef _ACF_CLEAR_UNMOVE
|
prev_unmove();
|
||||||
field[PTR_UNMOVE] = 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return u;
|
return u;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
3
Config.h
3
Config.h
|
|
@ -1,3 +0,0 @@
|
||||||
// CLEAR_UNMAKE is a feature that clears the unmake stack when it is not used.
|
|
||||||
// This is useful for making it more human readable
|
|
||||||
//#define _ACF_CLEAR_UNMAKE
|
|
||||||
24
Types.h
24
Types.h
|
|
@ -20,6 +20,29 @@ enum Piece: byte {
|
||||||
B_QUEN = 0b1111,
|
B_QUEN = 0b1111,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef _ACF_FAST_PIECE
|
||||||
|
Piece char_to_piece(char c) {
|
||||||
|
switch(c) {
|
||||||
|
case 'p': return W_PAWN;
|
||||||
|
case 'n': return W_KNGT;
|
||||||
|
case 'k': return W_KING;
|
||||||
|
case 'b': return W_BSHP;
|
||||||
|
case 'r': return W_ROOK;
|
||||||
|
case 'q': return W_QUEN;
|
||||||
|
|
||||||
|
case 'P': return B_PAWN;
|
||||||
|
case 'N': return B_KNGT;
|
||||||
|
case 'K': return B_KING;
|
||||||
|
case 'B': return B_BSHP;
|
||||||
|
case 'R': return B_ROOK;
|
||||||
|
case 'Q': return B_QUEN;
|
||||||
|
|
||||||
|
default: return P_EMPTY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else // _ACF_FAST_PIECE
|
||||||
|
|
||||||
const char CHAR_STRS[] PROGMEM = " pnkbrq PNKBRQ";
|
const char CHAR_STRS[] PROGMEM = " pnkbrq PNKBRQ";
|
||||||
Piece char_to_piece(char c) {
|
Piece char_to_piece(char c) {
|
||||||
for(byte i = 0; i < 0b1111; i++) {
|
for(byte i = 0; i < 0b1111; i++) {
|
||||||
|
|
@ -31,5 +54,6 @@ Piece char_to_piece(char c) {
|
||||||
char piece_to_char(Piece p) {
|
char piece_to_char(Piece p) {
|
||||||
return CHAR_STRS[p];
|
return CHAR_STRS[p];
|
||||||
}
|
}
|
||||||
|
#endif // _ACF_FAST_PIECE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue