diff --git a/golden-games/144d5348-37fb-41ff-9291-c2614243fd9b/depth-1.txt b/golden-games/144d5348-37fb-41ff-9291-c2614243fd9b/depth-1.txt new file mode 100644 index 0000000..d56b29f --- /dev/null +++ b/golden-games/144d5348-37fb-41ff-9291-c2614243fd9b/depth-1.txt @@ -0,0 +1,43 @@ +1. d4 +0.02 +... Nc6 -0.18 +2. Kd2 +0.02 +... Nxd4 -1.00 +3. Ke3 -1.00 +... Nxe2 -2.00 +4. Ke4 -2.00 +... Nxg1 -5.00 +5. Ke5 -5.00 +... Nh6 -5.20 +6. Bxh6 -1.80 +... gxh6 -5.01 +7. Rxg1 -1.81 +... Bg7 -2.01 +8. Kd5 -2.01 +... Bxb2 -3.01 +9. Nc3 -2.81 +... Bxa1 -7.81 +10. Ke5 -7.81 +... Bxc3 -11.01 +11. Qd4 -10.81 +... Bxd4 -20.01 +12. Kd5 -20.01 +... Bxf2 -21.01 +13. Ke5 -21.01 +... Bxg1 -26.01 +14. Be2 -25.81 +... Bxh2 -26.81 +15. g3 -26.80 +... Bxg3 -27.81 +16. Kd5 -27.81 +... a5 -27.83 +17. a4 -27.81 +... Ra7 -28.01 +18. c4 -27.99 +... b5 -28.01 +19. axb5 -26.98 +... Bb7 -27.18 +20. Kc5 -27.18 +... d5 -27.20 +21. cxd5 -26.17 +... Qxd5 -27.40 +0-1 \ No newline at end of file diff --git a/golden-games/144d5348-37fb-41ff-9291-c2614243fd9b/depth-2.txt b/golden-games/144d5348-37fb-41ff-9291-c2614243fd9b/depth-2.txt new file mode 100644 index 0000000..2a0e59e --- /dev/null +++ b/golden-games/144d5348-37fb-41ff-9291-c2614243fd9b/depth-2.txt @@ -0,0 +1,15 @@ +1. d4 -0.18 +... Nc6 +0.02 +2. Kd2 -1.00 +... Nxd4 -0.80 +3. Ke3 -2.00 +... Nf5 -1.00 +4. Ke4 -1.20 +... e6 +0.19 +5. Ke5 -1.21 +... Qf6 -1.21 +6. Ke4 -2.21 +... Qh4 -1.01 +7. Ke5 -2.21 +... f6 #-1 +0-1 \ No newline at end of file diff --git a/golden-games/144d5348-37fb-41ff-9291-c2614243fd9b/depth-3.txt b/golden-games/144d5348-37fb-41ff-9291-c2614243fd9b/depth-3.txt new file mode 100644 index 0000000..137b20b --- /dev/null +++ b/golden-games/144d5348-37fb-41ff-9291-c2614243fd9b/depth-3.txt @@ -0,0 +1,11 @@ +1. d4 +0.02 +... Nc6 -0.37 +2. Kd2 -0.80 +... Nxd4 -1.80 +3. Ke3 -1.00 +... c5 -1.82 +4. Ke4 -1.22 +... Nf6 -2.22 +5. Ke5 #-1 +... Qc7 #-1 +0-1 \ No newline at end of file diff --git a/golden-games/144d5348-37fb-41ff-9291-c2614243fd9b/depth-4.txt b/golden-games/144d5348-37fb-41ff-9291-c2614243fd9b/depth-4.txt new file mode 100644 index 0000000..e58dad3 --- /dev/null +++ b/golden-games/144d5348-37fb-41ff-9291-c2614243fd9b/depth-4.txt @@ -0,0 +1,75 @@ +1. f4 -0.18 +... Nc6 +0.02 +2. Kf2 -0.78 +... Nh6 +0.02 +3. Ke3 -1.18 +... e6 -0.17 +4. Ke4 -1.21 +... d5 -0.21 +5. Ke3 -1.41 +... Bc5 -0.39 +6. d4 -4.41 +... Nxd4 -1.39 +7. c4 -6.39 +... Nc2 -5.17 +8. Kf3 -6.39 +... Nxa1 -5.17 +9. cxd5 -6.59 +... Qxd5 -6.20 +10. Qxd5 -7.40 +... exd5 -6.39 +11. f5 -7.44 +... Bxf5 -7.23 +12. Kf4 -11.42 +... Bxb1 -10.22 +13. Ke5 -12.61 +... Bxa2 -11.21 +14. Bxh6 -11.44 +... gxh6 -11.41 +15. Kf6 -14.43 +... Bd4 -12.23 +16. Kf5 -14.41 +... Bxb2 -12.41 +17. e4 -12.61 +... dxe4 -12.41 +18. Be2 -13.41 +... e3 -13.05 +19. Nf3 -13.25 +... Ke7 -13.23 +20. h4 -14.23 +... a5 -13.05 +21. h5 -14.24 +... Ra7 -13.24 +22. Rh4 -14.24 +... Bd5 -13.23 +23. Nh2 -14.44 +... Rg8 -13.40 +24. g3 -14.46 +... Bf6 -13.43 +25. Ra4 -14.46 +... Bc6 -13.43 +26. Rc4 -14.46 +... Rg7 -13.42 +27. g4 -14.45 +... a4 -13.43 +28. Bd3 -14.46 +... a3 -13.44 +29. Be2 -14.47 +... a2 -13.45 +30. g5 -15.50 +... hxg5 -14.47 +31. Rxc6 -16.49 +... bxc6 -16.48 +32. h6 -19.42 +... Ra5 -16.48 +33. Bb5 -19.69 +... Rxb5 -19.68 +34. Ke4 -22.63 +... e2 -19.69 +35. hxg7 -23.68 +... e1=Q -23.68 +36. Kd3 -25.83 +... Rc5 #-2 +37. g8=Q #-1 +... Rc3 #-1 +0-1 \ No newline at end of file diff --git a/src/challenges/chess-simp-discord.ts b/src/challenges/chess-simp-discord.ts index 0f5fd0b..75adaf3 100644 --- a/src/challenges/chess-simp-discord.ts +++ b/src/challenges/chess-simp-discord.ts @@ -243,21 +243,27 @@ class SimpDiscord_Manos implements Challenge { uuid: '144d5348-37fb-41ff-9291-c2614243fd9b', title: '[manossef] The Gay Challenge', link: 'https://discord.com/channels/866701779155419206/1236461054255566848/1237450553374539908', - challenge: `If my king has any legal moves that bring him closer to my opponent's king, I must immediately play the one that reduces that distance the most. If multiple moves are tied for the smallest distance, I can choose which one to play. Otherwise, if my king has any legal moves that do not alter his distance from my opponent's king, I am allowed to either play one of those moves or move any other piece (or pawn) of mine. I am, however, not allowed to make a move that would bring my king further away from my opponent's king. If none of my pieces (and pawns) other than my king have any legal moves, and all of my king's legal moves increase his distance from my opponent's king, I must play the move that increases the distance the least. If multiple moves are tied for the smallest distance from my opponent's king, I can choose which one to play. My first move must let my king out.`, + challenge: `Choose whatever move brings your king the closest (or at least the least far) to the opponent's king. Oh, and your first move has to let your king out.`, records: new Map([]), } - isMoveAllowed: Challenge['isMoveAllowed'] = ({ move, board }) => { - // TODO: first move - // we'll check this later + isMoveAllowed: Challenge['isMoveAllowed'] = ({ move, board, history }) => { + // First move is special + if (history.length === 0) { + // Just has to be one of the three pawn moves + return move.kind === 'normal' && ['d2', 'e2', 'f2'].includes(move.from.toAlgebraic()) + } - // TODO: rest of moves - const boardAfterMove = board.clone() - boardAfterMove.executeMove(move) + // Otherwise: "Whatever is the smallest possible distance to have after all moves, this has to be the new distance". // Distance between the kings after the proposed move. NB: the proposed move is not necessarily a king move! - const distanceAfter = boardAfterMove.kings.white.pythagoreanDistance(board.kings.black) + const distanceAfter = (() => { + const boardAfterMove = board.clone() + boardAfterMove.executeMove(move) + return boardAfterMove.kings.white.pythagoreanDistance(board.kings.black) + })() + // Best achievable distance const bestPossibleDistance = _.min( legalMoves_slow(board).map((move) => { const boardAfterMove = board.clone() @@ -266,9 +272,21 @@ class SimpDiscord_Manos implements Challenge { }) ) - // All the rules are essentially just "whatever is the smallest possible distance to have after all moves, this has to be the new distance" + // ...and they have to match return distanceAfter === bestPossibleDistance } + + highlightSquares: Challenge['highlightSquares'] = ({ board, history }) => { + // On the first move, highlight the three movable pawns to prevent confusion + if (history.length === 0) { + return ['d2', 'e2', 'f2'].map((algebraic) => ({ + coord: Coord.fromAlgebraic(algebraic), + color: 'blue', + })) + } else { + return [] + } + } } /** diff --git a/src/utils/coord.ts b/src/utils/coord.ts index ac23ce6..9797442 100644 --- a/src/utils/coord.ts +++ b/src/utils/coord.ts @@ -29,7 +29,7 @@ export class Coord { return this.x === other.x && this.y === other.y } - /** Convert to algebraic notation. */ + /** Convert to algebraic notation. Uses lowercase */ toAlgebraic(): string { return String.fromCharCode('a'.charCodeAt(0) + this.x) + (this.y + 1) }