Compare commits

..

2 Commits

Author SHA1 Message Date
Quinten Kock c69d0b96d5 Remove ACF_FAST_PIECE feature 2020-06-17 23:59:45 +02:00
Quinten Kock 0b75a0c169 Fancier printing 2020-06-17 23:59:13 +02:00
5 changed files with 23 additions and 29 deletions

View File

@ -2,8 +2,11 @@
#include <Arduino.h>
#include "Config.h"
#include "Board.h"
#include "Move.h"
#include "Movegen.h"
#include "Types.h"
Board b = Board();
@ -44,9 +47,11 @@ 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.print();
b.unmake();
b.print();
int elapsed = micros() - startTime;
Serial.print(elapsed);

12
Board.h
View File

@ -80,8 +80,11 @@ 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(" ");
}
@ -244,17 +247,20 @@ void Board::prev_unmove() {
}
void Board::store_unmove(Unmove u) {
byte *ub = (byte*) &u;
for(size_t i = 0; i < sizeof(u); i++) {
next_unmove();
for(byte i = 0; i < sizeof(u); i++) {
field[PTR_UNMOVE] = ub[i];
next_unmove();
}
}
Unmove Board::read_unmove() {
Unmove u;
byte* ptr = (byte*) &u;
for(int i = sizeof(u) - 1; i >= 0; i--) {
ptr[i] = field[PTR_UNMOVE];
prev_unmove();
ptr[i] = field[PTR_UNMOVE];
#ifdef _ACF_CLEAR_UNMOVE
field[PTR_UNMOVE] = 0;
#endif
}
return u;
}

3
Config.h Normal file
View File

@ -0,0 +1,3 @@
// 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

4
Movegen.h Normal file
View File

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

24
Types.h
View File

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