Auto draw king-pawn fortresses#733
Conversation
…square to some destination(s), given certain forbidden squares.
…ne of its reachable squares.
…, and benchmark some functions.
…ide to move is attacking the enemy king.
|
hey, csv related notes:
|
…omposition), refactor so that `playerHasInsufficientMaterial` is no longer expressed in terms of `opponentHasInsufficientMaterial`. Fixes test failure from previous commit.
| if destinations.intersects(forbidden) || destinations.contains(startSquare) then | ||
| throw IllegalArgumentException( | ||
| "`destinations` contains either the start square or some forbidden square" | ||
| ) |
There was a problem hiding this comment.
We don't throw exceptions in scala. If the function cannot compute its response type for every combination of its arguments, then it returns a Try[], an Either[] or an Option[].
| frontier = frontier.fold(Bitboard.empty) { (newFrontier, sq) => | ||
| newFrontier | (sq.kingAttacks & ~skip) | ||
| } | ||
| end while |
There was a problem hiding this comment.
We almost never do procedural programming in scala. We almost never use var, while or return.
The only rare exception is for extreme performance optimization, after production profiling and benchmark testing.
|
@lenguyenthanh Thanks for the feedback. I've addressed your first point, but for the second I've been having some trouble implementing it. If you'd be able to help here that would be appreciated. |
I'll take a look 👍 |
|
Hey @lenguyenthanh, just following up on this. |
I'm vacationing atm, will look in early February |
@lenguyenthanh i think you forgot |
No, but I'm procastinating 🙏 |
maybe need include this |
|
@SergioGlorias Should be pretty straightforward to handle other pieces. The bfs algorithm in core/src/main/scala/InsufficientMatingMaterial.scala can be applied to other pieces, just with the set of 'forbidden' squares being only the squares that friendly pawns are on (unless I'm missing some edge case). But to keep things simple maybe that should be tackled after/if this PR is merged. |

Auto draw under these conditions:
This kind of fortress isn't super common, but it does come up from time to time. E.g., I got it in two games from this month (rare):