Impasse Rule + History. - #3
Conversation
…with the initialSfen
…ogi and checkshogi
| } | ||
|
|
||
| if (isImpasse(this)){ | ||
| return Outcome(result: GameResult.tryRule, winner: turn); |
There was a problem hiding this comment.
We will need a new GameResult 'Impasse27'. 'TryRule' is for dobutsu only.
| return copyWith(initialSfen: sfen); | ||
| } | ||
|
|
||
| History copyWith({ |
There was a problem hiding this comment.
I think the fields that are nullable will need 'uniqueObjectInstance,' like it's here for example:
| return ConsecutiveAttacks(sente, 0); | ||
| } | ||
|
|
||
| int call(Side side) { |
There was a problem hiding this comment.
Maybe better name like 'side' to be consistent (
Line 94 in 53693ed
| const int necessaryGoteScore = 27; | ||
|
|
||
| bool isImpasse(Position position) { | ||
| if ((position.rule != Rule.shogi && position.rule != Rule.annanshogi && position.rule != Rule.checkshogi) || position.isCheck()) { |
There was a problem hiding this comment.
More readable would be having the impassable variants elsewhere:
final impassableRules = {
Rule.shogi,
Rule.annanshogi,
Rule.checkshogi,
};
And then
impassableRules.contains(position.rule)
| final board = parseBoardSfen(rule, boardPart); | ||
| if (board.isError()) return Failure(board.exceptionOrNull()!); | ||
|
|
||
| //History |
There was a problem hiding this comment.
In scalashogi we only look for last lion dest - https://github.com/WandererXII/scalashogi/blob/9a1c2c3ae9167da60f47366e922b2f84c8bcda4e/src/main/scala/format/forsyth/Sfen.scala#L39
We are not necessarily parsing the initial position.
| required this.turn, | ||
| required this.history, | ||
| this.lastDest, | ||
| this.lastLionCapture, |
There was a problem hiding this comment.
this.lastDest and this.lastLionCapture are now essentially covered by History right? So we should probably remove these. Same in position.
|
Also could you please add '@useResult' to methods in History.dart returning History? |
Implemented the Impasse Rule from Issue #1 and History from issue #2. All tests pass.