Skip to content

Commit

Permalink
Manos challenge (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
neongreen committed May 7, 2024
1 parent 98b984d commit b9c3d9e
Show file tree
Hide file tree
Showing 7 changed files with 212 additions and 15 deletions.
25 changes: 13 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
# Yet unannounced in Chess Simp Discord

* May 5, 2024: New challenge: Chess Simp — "This Is Why Chess Pieces Can Fly"
* May 7, 2024: New challenge: Chess Simp Discord (manossef) -- "The Gay Challenge"

# Already announced

* Sep 12, 2023: New challenge: Chess Simp — "The Unending Cycle of Revenge"
* May 5, 2024: New challenge: Chess Simp -- "This Is Why Chess Pieces Can Fly"
* Sep 12, 2023: New challenge: Chess Simp -- "The Unending Cycle of Revenge"
* Sep 12, 2023: Internal: keeping track of piece identity
* Sep 11, 2023: New challenge: Chess Simp "Odd Numbered Rank"
* Aug 29, 2023: New challenge: Chess Simp Discord "Alphabetical"
* Aug 26, 2023: New challenge: Chess Simp "Alternate Between Moving Pawns & Pieces"
* Aug 20, 2023: New challenge: Chess Simp "That Was Frustrating"
* Aug 19, 2023: New challenge: Chess Simp "If A King Moves, The Video Ends"
* Aug 19, 2023: New challenge: Chess Simp "This Is A Bit Too Aggressive"
* Sep 11, 2023: New challenge: Chess Simp -- "Odd Numbered Rank"
* Aug 29, 2023: New challenge: Chess Simp Discord -- "Alphabetical"
* Aug 26, 2023: New challenge: Chess Simp -- "Alternate Between Moving Pawns & Pieces"
* Aug 20, 2023: New challenge: Chess Simp -- "That Was Frustrating"
* Aug 19, 2023: New challenge: Chess Simp -- "If A King Moves, The Video Ends"
* Aug 19, 2023: New challenge: Chess Simp -- "This Is A Bit Too Aggressive"
* Aug 19, 2023: Internal: challenge method to signal that the challenge is explicitly lost
* Aug 18, 2023: "Open leaderboard" palette command
* Aug 17, 2023: New challenge: Chess Simp "A Check Will Ruin Everything"
* Aug 17, 2023: New challenge: Chess Simp "Poor Pawn Got Blundered 10 Times"
* Aug 17, 2023: New challenge: Chess Simp "Chess, But I'm A Real Simp"
* Aug 17, 2023: New challenge: Chess Simp -- "A Check Will Ruin Everything"
* Aug 17, 2023: New challenge: Chess Simp -- "Poor Pawn Got Blundered 10 Times"
* Aug 17, 2023: New challenge: Chess Simp -- "Chess, But I'm A Real Simp"

# Aug 17, 2023 started the changelog
# Aug 17, 2023 -- started the changelog
43 changes: 43 additions & 0 deletions golden-games/144d5348-37fb-41ff-9291-c2614243fd9b/depth-1.txt
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions golden-games/144d5348-37fb-41ff-9291-c2614243fd9b/depth-2.txt
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions golden-games/144d5348-37fb-41ff-9291-c2614243fd9b/depth-3.txt
Original file line number Diff line number Diff line change
@@ -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
75 changes: 75 additions & 0 deletions golden-games/144d5348-37fb-41ff-9291-c2614243fd9b/depth-4.txt
Original file line number Diff line number Diff line change
@@ -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
56 changes: 54 additions & 2 deletions src/challenges/chess-simp-discord.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Board } from '@/board'
import { getCapture, getMoveCoords, getMovePiece } from '@/move'
import { legalMovesForPiece_slow } from '@/move/legal'
import { Move, getCapture, getMoveCoords, getMovePiece } from '@/move'
import { legalMovesForPiece_slow, legalMoves_slow } from '@/move/legal'
import { Color, isBlackPiece, isPawn, isWhitePiece } from '@/piece'
import { Coord } from '@/utils/coord'
import { Uuid } from '@/utils/uuid'
Expand Down Expand Up @@ -238,6 +238,57 @@ class SimpDiscord_UnendingCycleOfRevenge implements Challenge {
}
}

class SimpDiscord_Manos implements Challenge {
meta: Challenge['meta'] = {
uuid: '144d5348-37fb-41ff-9291-c2614243fd9b',
title: '[manossef] The Gay Challenge',
link: 'https://discord.com/channels/866701779155419206/1236461054255566848/1237450553374539908',
challenge: `Approach him! 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, 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())
}

// 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 = (() => {
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()
boardAfterMove.executeMove(move)
return boardAfterMove.kings.white.pythagoreanDistance(board.kings.black)
})
)

// ...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 []
}
}
}

/**
* Challenges from the #video-suggestion channel on the Chess Simp Discord: https://discord.com/channels/866701779155419206/884667730891010048
*/
Expand All @@ -252,6 +303,7 @@ export const chessSimpDiscordChallenges: Map<
() => new SimpDiscord_Vampires(),
() => new SimpDiscord_Alphabetical(),
() => new SimpDiscord_UnendingCycleOfRevenge(),
() => new SimpDiscord_Manos(),
].map((challengeFn) => [
challengeFn().meta.uuid,
{ meta: challengeFn().meta, create: challengeFn },
Expand Down
2 changes: 1 addition & 1 deletion src/utils/coord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit b9c3d9e

Please sign in to comment.