Find Chess960 starting position identifier: Difference between revisions

m
Small improvement to coding.
m (Added language identifier.)
m (Small improvement to coding.)
Line 574:
for ( String position : positions ) {
validate("RQNBBKRN"position);
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;
private static 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));
 
}
871

edits