fixed move generation
This commit is contained in:
@ -123,7 +123,10 @@ struct gameState_t newGameState(uint_least64_t *board, char *FEN) {
|
||||
else playerCastle->longCastle = true;
|
||||
}
|
||||
}
|
||||
if(*++FEN == '-') ++FEN;
|
||||
if(*++FEN == '-'){
|
||||
++FEN;
|
||||
gameState.enPassantTo = NOT_SELECTED;
|
||||
}
|
||||
else {
|
||||
gameState.enPassantTo = *FEN++ - 'a';
|
||||
gameState.enPassantTo += (BOARD_SIZE - *FEN++) * BOARD_SIZE;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#include "chess/move.h"
|
||||
#include "chess/types.h"
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@ -20,3 +21,35 @@ void printPieceMask(uint_least64_t mask) {
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
void fieldToString(uint_least8_t field, char *output) {
|
||||
output[0] = 'a' + field % BOARD_SIZE;
|
||||
output[1] = '0' + BOARD_SIZE - field / BOARD_SIZE;
|
||||
output[2] = '\0';
|
||||
}
|
||||
|
||||
void printMove(const struct move_t move) {
|
||||
char src[3];
|
||||
char dst[3];
|
||||
fieldToString(move.src, src);
|
||||
fieldToString(move.dst, dst);
|
||||
printf("%s%s", src, dst);
|
||||
if(move.srcPiece != move.dstPiece) {
|
||||
char piece;
|
||||
switch(move.dstPiece) {
|
||||
case ROOK:
|
||||
piece = 'R';
|
||||
break;
|
||||
case BISHOP:
|
||||
piece = 'B';
|
||||
break;
|
||||
case QUEEN:
|
||||
piece = 'Q';
|
||||
break;
|
||||
case KNIGHT:
|
||||
piece = 'N';
|
||||
break;
|
||||
}
|
||||
printf("%c", piece);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user