Compare commits

..

No commits in common. "a995784aac58dcf375e8a19eb6565529e3f55e21" and "adb77a69901382fc9c3813953a2fb0a35da07b5b" have entirely different histories.

2 changed files with 6 additions and 47 deletions

View File

@ -8,7 +8,7 @@ Board b = Board();
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.begin(9600);
//char value;
//while(Serial.available() == 0) {

51
Board.h
View File

@ -93,59 +93,16 @@ void Board::print() {
void Board::make(Move m) {
// fill unmove struct with basic data
Unmove u;
u.revmov = field[PTR_REVMOV];
u.captured = field[m.sq_to];
u.sq_from = m.sq_from;
u.sq_to = m.sq_to;
byte piece_type = field[m.sq_from] & 0x8;
if(u.captured || piece_type == W_PAWN) {
field[PTR_REVMOV]++;
} else {
field[PTR_REVMOV] = 0;
}
// Calculate the move 'amount' (unique signature for dx,dy)
int sq_diff = (int)m.sq_from - (int)m.sq_to;
int sq_diff_abs = abs(sq_diff);
// TODO handle castling
// TODO handle castling rights
// TODO handle revmov clock
// TODO zobrist
// TODO do any castling testing
// Handle castling
if((m.sq_from & 0b111) == W_KING && sq_diff_abs == 2) {
// We are castling! After all, a king cannot move
// more than one position except when castling.
// Since we don't care about legality; just do it
byte castle_source = 0x70*black_moving();
if(sq_diff == 2) {
castle_source += 0x7;
}
byte castle_target = m.sq_from + (sq_diff/2);
field[castle_target] = field[castle_source];
field[castle_source] = P_EMPTY;
}
// Handle castling rights
// We are doing the simple way:
// unset it any time a move is made from the original position.
if(m.sq_from == 0x00)
field[PTR_SIDE_AND_CASTLERIGHT] &= ~0b00010;
if(m.sq_from == 0x07)
field[PTR_SIDE_AND_CASTLERIGHT] &= ~0b00100;
if(m.sq_from == 0x04)
field[PTR_SIDE_AND_CASTLERIGHT] &= ~0b00110;
if(m.sq_from == 0x70)
field[PTR_SIDE_AND_CASTLERIGHT] &= ~0b01000;
if(m.sq_from == 0x77)
field[PTR_SIDE_AND_CASTLERIGHT] &= ~0b10000;
if(m.sq_from == 0x74)
field[PTR_SIDE_AND_CASTLERIGHT] &= ~0b11000;
// TODO: test enpassant code more than basics
// TODO: test enpassant code
// handle enpassant capture
if(field[PTR_ENPASSANT] && (field[m.sq_from] & 0b111) == W_PAWN) {
@ -167,6 +124,8 @@ void Board::make(Move m) {
u.enpassant = field[PTR_ENPASSANT];
// handle enpassant setup (double pawn move)
// Calculate the move 'amount'
int sq_diff = (int)m.sq_from - (int)m.sq_to;
if(
(field[m.sq_from] & 0b111) == W_PAWN &&
(sq_diff == 32 || sq_diff == -32)