bhlangonijr / chesslib

chess library for legal move generation, FEN/PGN parsing and more
Apache License 2.0
231 stars 80 forks source link

How to configure legal moves? #117

Open rabestro opened 2 months ago

rabestro commented 2 months ago

In Dice Chess, the King can move to a square that is under attack.

I want to use the library for Dice Chess game. How I can configure it?

https://dicechess.com/rules

bhlangonijr commented 2 months ago

chesslib doesn't natively support Dice Chess, but you can implement it with some additional logic. You could create a new class and method (e.g., DiceMoveGenerator#generateLegalMoves(Board)) that calls MoveGenerator#generatePseudoLegalMoves(Board). Instead of using Board#isMoveLegal to filter out illegal moves, you can write a custom method that allows moves that would normally be considered illegal, such as the king moving into an attacked square.