- // Build corresponding key code for the opposite color: "KBPKN" -> "KNKBP"
- const string swap_colors(const string& keyCode) {
-
- size_t idx = keyCode.find('K', 1);
- return keyCode.substr(idx) + keyCode.substr(0, idx);
- }
-
- // Get the material key of a position out of the given endgame key code
- // like "KBPKN". The trick here is to first build up a FEN string and then
- // let a Position object to do the work for us. Note that the FEN string
- // could correspond to an illegal position.
- Key mat_key(const string& keyCode) {
+ // Get the material key of a Position out of the given endgame key code
+ // like "KBPKN". The trick here is to first forge an ad-hoc fen string
+ // and then let a Position object to do the work for us. Note that the
+ // fen string could correspond to an illegal position.
+ Key key(const string& code, Color c) {