View All Posts
read
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi

Watch as chat GPT takes on Stockfish, a world-class chess engine, in a thrilling match! See how GPT utilizes a chess plugin to improve its gameplay and compete against the best.

Related Content
Transcript

[0:00] I’m sure you all have seen people trying
[0:02] to play chess against chat GPT and
[0:04] complaining that it tries to make
[0:05] illegal moves or without right cheats
[0:07] the issue is that after a while it can’t
[0:09] remember where the pieces on the board
[0:11] are but as we saw in the previous video
[0:13] where you made a hangman plug-in we can
[0:15] give it a bit of help by adding in a
[0:17] plugin so I’ve made a chess plugin let’s
[0:19] see how chat GPT performs against
[0:21] stockfish
[0:23] let’s play chat GPT at chess so I’ve got
[0:27] my chest plugin installed and let’s
[0:29] start a new game
[0:32] so let’s play chess we’ll start off with
[0:35] him playing white and we’ll ask it to
[0:37] give us his best game
[0:38] so it’s gone off to our chess plugin and
[0:41] it should have done new game and our
[0:43] chest plugins returned the move history
[0:45] which is currently blank and the
[0:47] position of all the pieces so let’s see
[0:49] what move he makes so he’s going to
[0:51] start the game with E4
[0:53] so I’m no good at chess so I’m using
[0:56] stockfish to play against chat gp2
[0:58] slightly cheeky as stockfish is really
[1:00] good so let’s make the move E4 and we’ll
[1:03] see what stockfish recommends our
[1:04] response should be so currently
[1:06] stockfish is suggesting E6 as the best
[1:09] move so let’s make the move E6 and we’re
[1:13] getting a bit of a chat from chat GPT
[1:15] let’s see what you’ve got while I’m
[1:17] playing with stockfish so I’ve got quite
[1:19] a lot so he’s going to play the move d4
[1:21] which is the same as what stockfish is
[1:23] suggesting so let’s make the move d4 and
[1:26] see how we should respond now I would
[1:28] expect chat GPT to play the opening of
[1:30] the game very well as it should have
[1:32] memorized this for more the training
[1:34] data it’s had so let’s see what
[1:36] stockfish says so stockfish says D5 so
[1:39] we’ll make that move
[1:40] D5
[1:43] and let’s see how chat GPT continues the
[1:46] opening
[1:47] so if it follows What stockfish suggests
[1:49] then it should move its Knight to C3
[1:53] so he’s actually taken our Pawn so e x
[1:56] D5 so let’s make that move in stockfish
[2:00] and see how we should respond so we
[2:03] should respond by taking the pawn back
[2:05] so it looks like ex D5 is the move
[2:09] so let’s see what chat GPT does next
[2:13] so he’s moved his Knight out to F3 which
[2:16] is what stockfish says is the correct
[2:18] move now it’s like we should respond by
[2:20] mirroring what he’s done by bringing our
[2:22] night out to C6 so we’ll do the same so
[2:26] Knight C6 let’s see what chat GPT
[2:29] decides to do
[2:30] so he’s moving his Bishop out so Bishop
[2:33] to D3 so let’s make our move stockfish
[2:36] what should we do so it looks like we
[2:38] should move Knight to B4 which will
[2:40] threaten his Bishop so let’s make that
[2:42] move in stopfish and we’ll make the same
[2:44] move in chat GPT
[2:47] so he’s moving his Bishop to E2 so let’s
[2:50] move the bishop back and we should
[2:53] respond to that by developing our Bishop
[2:55] out to F5 so that seems to be the move
[2:58] that stockfish has decided on so Bishop
[3:01] F5 now let’s see what chat GPT decides
[3:04] to do now
[3:06] so he’s moved his Knight out to A3 which
[3:08] is what stockfish recommends so Knight
[3:11] A3 and according to stockfish we should
[3:14] move our Knight back to C6 so let’s move
[3:17] Knight C6
[3:19] now interestingly stockfish is
[3:21] suggesting moving the Knight back to B1
[3:23] where it started so let’s see if chat
[3:25] GPT does that move or if it’s something
[3:27] if it’s got something else up its sleeve
[3:29] so it’s decided to Castle so it’s
[3:31] castling kingside
[3:32] so according to stockfish we’re now
[3:34] going to bring our Bishop out and take
[3:36] the Knight so let’s do that bxa3
[3:43] so chat GPT has taken the bishop so we
[3:46] just need to take the bishop using the
[3:48] pawn
[3:50] so what’s our move now stockfish
[3:53] so Stockbridge says we should develop
[3:55] our Knight to F6 so let’s do that say
[3:59] Knight F6
[4:01] and let’s see what chap GPT decides to
[4:03] do
[4:04] according to stockfish he should move
[4:06] his look to B1 so let’s see what happens
[4:11] okay so instead he moved the pawn to C4
[4:14] so let’s do the same yeah let’s see what
[4:17] we should do stockfish so it looks like
[4:19] we should Castle kingside now let’s see
[4:21] what chat GPT does according to
[4:24] stockfish Black is now slightly better
[4:25] than white
[4:27] so he’s moved his Pawn to C5 so he’s
[4:30] trying to restrict the movement of our
[4:32] pieces so let’s see what we should do so
[4:34] stockfish says we should move our Knight
[4:36] to E4 so let’s do that so n E4
[4:41] now let’s see what chat GPT decides to
[4:44] do in response to that he should move
[4:46] his Rook to E1 but let’s see what
[4:49] happens so he’s developing his Bishop so
[4:51] Bishop B2 so that’s moving the bishop to
[4:55] there so it’s our move so what should we
[4:57] do stockfish move our Rook to E1 so
[5:00] let’s do that so Rook to E8 Rook E8 so
[5:04] let’s see what chat GPT thinks next
[5:08] so he’s moved his Rook to E1 which is
[5:10] what stockfish was recommending so in
[5:13] response we should move our Bishop to G4
[5:16] but let’s ask chat gbt what its strategy
[5:19] is
[5:21] so it says it’s got a few key principles
[5:23] so it started off trying to control the
[5:25] center by playing E4 and D4 then it
[5:28] focused on developing its pieces it
[5:30] castled to keep the king safe and now
[5:32] it’s trying to get Space Advantage by
[5:34] moving the C Pawn to C5 and it’s trying
[5:36] to coordinate its pieces so it’s played
[5:38] rookie one to centralize the Rooks so it
[5:41] seems fairly reasonable
[5:43] um let’s see what happens the game is
[5:45] still in the middle game phase and he’s
[5:46] going to continue to look for
[5:47] opportunities so let’s make the move
[5:49] that stockfish recommends so Bishop to
[5:52] G4
[5:54] and let’s see how chat GPT responds he
[5:57] should move the pawn up to H3 to chase
[6:00] the bishop away but let’s see what
[6:02] happens and that’s exactly what he’s
[6:04] done so H3 which should chase our Bishop
[6:07] away and it also provides some space for
[6:08] the king to move out of the way if he
[6:10] gets checked so according to stockfish
[6:12] we should just move our Bishop up one
[6:14] corner diagonally so Bishop H5
[6:18] so let’s see what’s chat GPT decides to
[6:20] do according to stockfish should move
[6:22] the Knight to D2 so let’s see what he
[6:25] does so he moves the Knight to E5 so
[6:27] that’s moving the Knight up to here
[6:30] um so let’s see stockfish says we should
[6:32] take the Knight so I guess that’s what
[6:34] we should do Knight X E5
[6:38] now according to stockfish we should
[6:40] take this bishop now the bishop is
[6:42] completely undefended so that does seem
[6:44] like a good move to me so let’s see what
[6:46] he does so I captured on Knight so
[6:49] actually he took the Knight interesting
[6:51] so let’s do the same and let’s see now
[6:53] we’re gonna take the bishop so
[6:55] interesting move so b x E2
[6:59] so let’s see how chat gbt responds it
[7:02] seems from stockfish that he should take
[7:03] the bishop using the queen so let’s see
[7:06] what happens
[7:07] so he uses his Rook so let’s take the
[7:11] bishop using the Rook now according to
[7:13] stockfish we should take this Pawn using
[7:16] our Knight so Knight X C5
[7:19] so let’s see what chat GPT does now
[7:23] so look C1 say centralizing his Rooks
[7:26] and putting pressure on our Knight so
[7:28] that does seem to have worked as our
[7:30] Knight has been chased away up to E6 so
[7:34] let’s make that move Knight E6 so taking
[7:37] our our Knight somewhere safe so let’s
[7:40] see what chat GPT should do next
[7:42] if you look at stockfish he should move
[7:45] his Rook to D2 but he’s moving his Queen
[7:48] to D2 so let’s see what happens there so
[7:52] Queen D2 so I’ll move should be to bring
[7:55] our Queen out so Queen to H4 so between
[7:59] H4 so let’s see how chap GPT responds to
[8:03] that according to this number I think
[8:05] that means Black’s winning quite easily
[8:07] against white
[8:08] um so we should beat chat GPT quite
[8:11] easily so he’s moving his Rook to E3
[8:16] so he’s trying to protect this Pawn here
[8:18] I’m not entirely sure why but let’s see
[8:20] what happens so according to stockfish
[8:23] we should move this Pawn forward to D4
[8:25] threatening The Rook so let’s try that
[8:28] so E4
[8:30] so let’s see what chat GPT does now so
[8:33] he’s moved his Rook to E4 he says he’s
[8:37] threatening the queen but the queen can
[8:39] just take the Rook because the Rook is
[8:40] completely undefended so let’s take the
[8:43] Rook so Queen X E4 now I think chat GPT
[8:46] is probably losing quite badly now we’re
[8:49] hemorrhaging pieces and stockfish really
[8:52] is out playing it completely
[8:56] so he’s made a slight mistake as well so
[8:58] he’s moved Queen xd4 but he thinks he’s
[9:01] captured Our Queen when actually he’s
[9:03] just captured a pawn he’s lost track of
[9:05] where the pieces are on the board so I
[9:07] think we’re about to lose our queen as
[9:09] well now so yes so stop fish is
[9:11] recommending take the queen using the
[9:13] Knight so Knight xd4 so as I kind of
[9:16] suspected at the start it’s quite easy
[9:19] for chat GPT to play the opening game
[9:21] where it has a whole bunch of openings
[9:24] memorized in its training data the mid
[9:26] game it does seem to struggle with
[9:28] particularly with knowing where pieces
[9:29] actually are and keeping track of them
[9:31] so it’s possible that we can help in the
[9:33] plugin to remind it where pieces are but
[9:35] we need to work out exactly how to
[9:37] represent that in a way that chat GPT
[9:39] can understand so it’s taking our Knight
[9:42] with the bishop and it’s about to lose
[9:44] the Bishops so Queen X D4 so I think at
[9:47] this point most people would probably
[9:49] resign because there’s not a lot left
[9:51] really for chat GPT to do
[9:54] so let’s make our move Rook e C8
[9:59] rook ac8 and let’s see how check GPT
[10:02] ends the game and we’re not far off from
[10:05] checkmate
[10:07] so Rook C1 check
[10:10] we move the king to H2 to Escape check
[10:12] but now it’s Checkmate basically we’ll
[10:15] make our move Queen to F4 and that’s
[10:18] check so here we block the check with
[10:20] the pawn and our next move is Checkmate
[10:23] so Queen xf2 Checkmate black wins game
[10:27] over for chat GPT
[10:29] so as I say it did very well at the
[10:31] start the mid game was slightly suspect
[10:33] and it sort of fell apart when it lost
[10:35] track of where the pieces were but as I
[10:37] say stockfish is an incredibly strong
[10:39] engine so it’s not surprising that it
[10:42] can beat chat GPT
[10:45] let’s ask Chachi BT where it all went
[10:48] wrong so where did it all go wrong chat
[10:51] GPT
[10:52] it says it has no feelings but I think
[10:54] it’s smarting right now so move seven
[10:57] let’s go back in time to move seven and
[11:00] see where it started to go wrong
[11:02] so na3
[11:05] this move developed the Knight to the
[11:06] edge of the board where it was less
[11:08] effective so yeah so Knight A3 is pretty
[11:12] much useless here it can’t do very much
[11:14] and then move 11 let’s see what it says
[11:17] about that so move 11 so C5 games space
[11:21] on the queen side but it weakened the D5
[11:23] square and allowed black to pay Knight
[11:26] to E4 let’s see if that makes any sense
[11:28] I’m not sure that makes any sense but
[11:30] I’m no chess expert well I still think
[11:33] it went wrong so move 20.
[11:35] so I move 20 Rook E3 it was intended to
[11:39] defend the king side pawns but it
[11:41] allowed black to play 20 D4 gaining
[11:43] Central space and pushing the Rook back
[11:45] so yeah so we moved Rook to E3 and that
[11:48] allowed him to move his Pawn forward
[11:50] threatening the rook and then last move
[11:52] 27 so it blocked the check from Black’s
[11:55] Queen but created a fatal weakness on F2
[11:57] so that was pretty much it so let’s load
[12:00] this into line chess and see where it
[12:02] went wrong with lychess
[12:05] okay so we can step through each move on
[12:07] live chess and we can see from this bar
[12:09] who’s winning at the time so we start
[12:12] off and we’re fairly evenly matched and
[12:15] it’s the French defense so black is
[12:17] playing the French defense so it’s still
[12:19] playing the French defense
[12:21] we’ve got the exchange variation
[12:24] so we’re still going and we’re still
[12:26] pretty evenly matched
[12:28] so now we bring out the French defense
[12:30] exchange variation so we brought out the
[12:33] kingside Knight into a standard position
[12:36] so and then black brings his night out
[12:39] and then we bring out the bishop
[12:42] and we’re still evenly matched so let’s
[12:45] see we’re still matched still matched
[12:47] still matched still matched still
[12:51] matched
[12:53] so now we get a slight Advantage towards
[12:55] black so this move here was obviously
[12:59] the first mistake that chat GPT made
[13:02] Castle in kingside makes no difference
[13:05] so yes I think chat GPT identifying the
[13:09] move of
[13:10] C5 was really the bit where it started
[13:13] to go really wrong for a white so we can
[13:16] see it it dips down immediately after
[13:18] that move
[13:19] and stay fairly stable
[13:26] and now when we lose our Knight that
[13:29] really is quite bad for white
[13:36] and now we’re losing why it’s losing
[13:39] very badly it’s pretty much going to be
[13:41] game over very soon and now White’s got
[13:44] no chance so stockfish has completely
[13:47] wiped out chat GPT
[13:49] but as I say no surprise chat GPT really
[13:52] isn’t supposed to be able to play chess
[13:54] not a surprise there but pretty
[13:56] interesting I think chat GPT playing
[13:58] against me it would wipe the floor with
[14:00] me because I am pretty bad at chess so
[14:02] it lost quite badly against stockfish
[14:04] but that’s no surprise I think there’s a
[14:07] lot of Promise here I’m going to try out
[14:08] gpt4 and see how well that performs and
[14:11] I think we can improve the plugin to
[14:13] help chat GPT remember where the pieces
[14:15] are it’s pretty exciting so stay tuned


HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
Blog Logo

Chris Greening

> Image

atomic14

A collection of slightly mad projects, instructive/educational videos, and generally interesting stuff. Building projects around the Arduino and ESP32 platforms - we'll be exploring AI, Computer Vision, Audio, 3D Printing - it may get a bit eclectic...

View All Posts