Find Chess960 starting position identifier: Difference between revisions
Find Chess960 starting position identifier (view source)
Revision as of 13:34, 21 July 2023
, 9 months agoSmall improvement to coding.
m (Added language identifier.) |
m (Small improvement to coding.) |
||
Line 574:
for ( String position : positions ) {
validate(
System.out.println("Position " + position + " has Chess960 SP-ID = " + calculateSPID(position));
}
Line 588:
pieces.merge(ch, 1, (oldV, newV) -> oldV + 1);
}
Set<Map.Entry<Character, Integer>> correctPieces =▼
Set.of(Map.entry('R', 2), Map.entry('N', 2), Map.entry('B', 2), Map.entry('Q', 1), Map.entry('K', 1));▼
if ( ! pieces.entrySet().equals(correctPieces) ) {
throw new AssertionError("Chess position contains incorrect pieces.");
Line 643 ⟶ 642:
private static Map<List<Integer>, Integer> knightsTable;
▲
}
|