-
Notifications
You must be signed in to change notification settings - Fork 874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Board State #119
Comments
Public API like this would be great: board: function() {
return board;
} |
BTW, why are there 128 squares on the board? var board = new Array(128); |
Maybe it could be like this then: board: function() {
var pieces = [];
for(var pos in SQUARES) {
var square = board[SQUARES[pos]];
if(square) {
// pieces.push({
// type: square.type,
// color: square.color,
// pos: pos,
// });
// pieces.push([pos[0], parseInt(pos[1]), square.type, square.color]);
// pieces.push([parseInt(pos[0], 18) - 10, parseInt(pos[1]) - 1, square.type, square.color === 'w']);
pieces.push([pos, square]);
}
}
return pieces;
} |
The internal board uses 128 squares because of the 0x88 move generation algorithm. During move generation, the algorithm can easily tell which squares are off the board by checking for a non-zero return from The FEN string ( The internal |
I wanted to use I guess looping through Would be nice though to have a programmatic way of accessing the state of the whole board, like Also, for example, if I want to use
|
@jhlywa Being unable to access the board state is inconvenient when building bots. Without the functionality, I have to convert every fen position into an array before I can evaluate it, which is unnecassary when It would be really awesome if this was part of the api :) |
@AlexeiDarmin The internal Would a simple 8x8 board array be more appropriate for your use case? |
@jhlywa I believe an 8x8 board would be fine, anything that is easily loop-able. For example: column based comparisons are inconvenient via the fen string such as checking for double pawns since some math needs to be done to calculate the columns. Visual example of how arrays make this easier.:
|
@AlexeiDarmin I've added a |
Thank you! It might also make sense to have an option to return only the list of squares where some piece are actually present. Consider an empty board with just a rook:
You could return: {
a8: 'r'
} |
When will this feature be added? |
How can I get the current board state? You have this variable
board
but it seems to be private, so is there a way to get the current board state?The text was updated successfully, but these errors were encountered: