ChatGPT creates UNBEATABLE Tic-Tac-Toe Engine

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone welcome back to another code Meets World video today I'm going to be using chat GPT to make something else uh pretty cool so in a previous video I've had chat gbt make a forest Escape game I've had it make a Sudoku solving um python code and today I'm going to make a tic-tac-toe game in Python where we can play against the computer and how I'm gonna do that is by switching over to gpt4 the more powerful version of the two and I'm just going to ask it to [Music] we're basically asking um chat gbt to make a game in python or we can select the difficulty of the computer that we're playing against I think that could be really cool randomly decide who goes first and we show the board after every move so let's see what Chachi PT gives us okay so it looks like uh it just finished let's see what happens when we paste when we paste all of this in so let's copy the first bit and it's the second bit wonderful and then let's go ahead and run this and see what happens okay great so we get to select a difficulty what if I put in something not true nice okay so it does some input validation that's helpful so I'll go for easy first and what does easy actually mean so the get move easy oh okay so this is interesting it looks like it just does a random choice of a move so that shouldn't be too hard to crack let's go easy the computer goes first it looks like it went in the middle this is cool so I will go and position zero crates so then the computer goes there I will now go to position but if I go somewhere where there already is one what if I hit zero again hopefully it doesn't break oh excellent invalid move so yeah let me go to let me go to seven okay the computer's playing well so that would be zero one two three four that's a five I want to block and then this is going to be so I I gotta draw an easy difficulty let's do easy again I'll go in the middle I don't know this easy version is playing oh okay actually I just won if I go in six I won woohoo so okay let's try it let's try medium and what's the difference with medium it looks like it's trying to say if I have a winning position yeah if I have a winning position about to happen it will block me I think that's what it's doing so let's see if that's actually true so it went there if I go here it should block me at the top or right but it didn't so now I can just win that's weird it should have oh oh I see is it has zeros plugged in but I have an ax so I think it actually did the wrong thing I think I need to change this to X in order for it to block me let's see let's see if it's a lot stronger this time so it went there so I'm gonna go I'm gonna go right here and then it should block me yeah look see if I went there and then it's it's blocked me but I do have a winning position here because if I go for zero it can't stop me in the top and I win last but not least let's do hard the computer goes first there was a little bit of a lag there so I guess with hard it's going to try to use a Min map a Mini Max function to pick the ideal move every time so this should be much more challenging so I can block the block again and yeah it's gonna be it's gonna be a draw this one might be extremely challenging beat but maybe if I go first I can outsmart it yeah if I go six and then it's gonna win if I don't go one oh geez [Music] so I'm I'm no expert at tic-tac-toe but with this algorithm I'm not sure if I'm actually going to be able to beat it because I think it knows how to play the optimal moves every time which is actually pretty cool so hopefully you enjoyed this I'm going to leave a link in the description to the code I will upload to GitHub so that this is publicly accessible feel free to play around with it if anyone makes a really cool Improvement on it feel free to comment on the video and I'll check it out and maybe you'll look at it in one of my future videos so yeah thanks so much everyone and see you in the next video
Info
Channel: CodeMeetsWorld
Views: 599
Rating: undefined out of 5
Keywords:
Id: 9Ws9iQTU4r4
Channel Id: undefined
Length: 6min 21sec (381 seconds)
Published: Mon Jun 26 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.