Closed guiguil81 closed 2 days ago
Hey @guiguil81, thanks!
The reason for the two different objects is Board
is used to validate the rules and piece movements of a game and represents the state of the game at a given position. This is why it has methods like legalMoves(for:)
and move(pieceAt:to:)
.
On the other hand, Game
manages all the positions in a game and is used so you can navigate between the different positions (forward, backward, variations, etc).
The two exist separately and you can use either as you see fit, it's not necessary to use both in all cases (but you will have to make moves in two different places if you want them to be in sync).
As for game state, you can use the BoardDelegate
to receive updates when the game ends with checkmate or stalemate (see didEnd(with:)
). Unfortunately it does not update when the king is in check but that is a good idea for a future improvement.
Thanks for answer!
Now I understand the logic between Board
and Game
thank you.
Yes, maybe it's a good improvement to see if king is in check haha
Thanks you for this package, and I can't wait to see further improvement!
Thank you! I've opened #38 to track that improvement.
Hi !
I found your package and for me it's just a amazing package thank you !
I work on projet and i want to build a basic chessBoard game. For now i create a Board model and i create a board like board().
But i don't understand why you separate Board class and Game class ? if i want to implement chessBoard game i need to create Board and Game and make move on both ?
I see on Board class you have private isKingInCheck method. But it's private, if i implement a Game and a Board i don't have method for display game state ? like kinIsCheck ok checkmate etc ?
Thanks