Compare commits

..

No commits in common. "c69d0b96d52ce620dcfe6799f9b9ce49ce6f18a3" and "e400106b55d3f76ff14c2ab370f70d146bfda2b1" have entirely different histories.

5 changed files with 29 additions and 23 deletions

View File

@ -2,11 +2,8 @@
#include <Arduino.h>
#include "Config.h"
#include "Board.h"
#include "Move.h"
#include "Movegen.h"
#include "Types.h"
Board b = Board();
@ -47,11 +44,9 @@ void setup() {
b.make({0x64, 0x54, P_EMPTY});
b.make({0x34, 0x44, P_EMPTY});
b.make({0x63, 0x43, P_EMPTY});
b.print();
//b.print();
b.make({0x44, 0x53, P_EMPTY});
b.print();
b.unmake();
b.print();
//b.print();
int elapsed = micros() - startTime;
Serial.print(elapsed);

12
Board.h
View File

@ -80,11 +80,8 @@ Board::Board() {
}
void Board::print() {
Serial.println(F("BOARD:"));
for(char i = 7; i >= 0; i--) {
for(byte j = 0; j < 16; j++) {
if(j == 8)
Serial.print("| ");
Serial.print(field[i*16 + j], HEX);
Serial.print(" ");
}
@ -247,20 +244,17 @@ void Board::prev_unmove() {
}
void Board::store_unmove(Unmove u) {
byte *ub = (byte*) &u;
for(byte i = 0; i < sizeof(u); i++) {
field[PTR_UNMOVE] = ub[i];
for(size_t i = 0; i < sizeof(u); i++) {
next_unmove();
field[PTR_UNMOVE] = ub[i];
}
}
Unmove Board::read_unmove() {
Unmove u;
byte* ptr = (byte*) &u;
for(int i = sizeof(u) - 1; i >= 0; i--) {
prev_unmove();
ptr[i] = field[PTR_UNMOVE];
#ifdef _ACF_CLEAR_UNMOVE
field[PTR_UNMOVE] = 0;
#endif
prev_unmove();
}
return u;
}

View File

@ -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

View File

@ -1,4 +0,0 @@
#ifndef __MOVEGEN_H_INC
#define __MOVEGEN_H_INC
#endif

24
Types.h
View File

@ -20,6 +20,29 @@ enum Piece: byte {
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";
Piece char_to_piece(char c) {
for(byte i = 0; i < 0b1111; i++) {
@ -31,5 +54,6 @@ Piece char_to_piece(char c) {
char piece_to_char(Piece p) {
return CHAR_STRS[p];
}
#endif // _ACF_FAST_PIECE
#endif