Hey everybody! In the spirit of learning, here are some ideas you can try and implement if you finished the video and are looking to add a bit more to this project. Exercise: Allow the players to put in their names so it doesn't just say "Player 1" and "Player 2" Exercise: Add a timer to the game so that each player only has a certain amount of time to make a decision (hint: checkout the built in "time" module) Exercise: Add an option to replay the game when it ends. Also add a game counter to keep track of how many times each player has won. Challenge Exercise: Add a single player mode with some AI functionality for the second player. It doesn't need to be a fancy algorithm, just think about how you can have the program make a valid move. Once you get it working, see if you can come up with something better! Happy coding!
Thank you! This was a great learning experience for me to follow along with and rebuild. Taught me some new tricks as a beginner to Python and was useful for fulfilling a project requirement for my course work.
Omg, i really need to learn a lot. I tried to do this exercise by my self and ended up contemplating bout suicide, I wish I was a pro like you at problem solving
Hiya. I may make it look easy, but what you don't see behind this tightly edited video is the years of experience I've had with problems like this. When I started learning to code, I could barely wrap my head around even simple tasks. Now I'm a lot more confident, but still learning. With some time and patience, I have confidence everything will click for you! Wishing you all the best in your coding journey : )
It was a great tutorial, very easy to follow. But one thing i am not able to grasp completely. Why did we call the check_turn function to check who the winner is? I mean the check turn function only returns the number of turn. Or what i am able to understand is, that as soon as the player 1 (let's say) is done with their final winning turn, this function return that and the winner is declared! please help me understand this. thankyou! And once again, great tutorial!
thank you for an amazing video. However im a little confused about line 19 in main file. How does that check if there is an X or O. The last part isnt even a dictionary. Id appreciate a response thanks :)
We start by equaling the previous turn to the current turn (Line 19). Because there's an infinite number of things the player can enter other than a correct board position, the idea is that we assume whatever they give us is invalid input. If they provide invalid input, we don't change the turn. If they actually give us an valid board position, then we increment the turn counter. When the next iteration of the loop occurs, it will check to see if the turn counter when up or not by comparing it to the previous turn. If it didn't, then our assumption that the player would give us something wrong is correct. so we want to print an error message for them.
Hi! I think your logic is great here! I am very much a beginner in python and am curious if you have any *hints* to implemting another game play? does turn = 0 need to be reset somehow? I am trying to implent best 2/3 gameplay to your code. I feel very far off. I started as: if finished: if what_turn(turn) == 'X': print("Player1 is the Winner!") else: print("Player2 is the Winner!") else: print("NO game!") print('Do you want to play again?(Y/N)') play_again = input().lower() gameplay = True if play_again == 'n': gameplay= False print(' Thanks for playing!')
Glad you enjoyed the video! One way to approach it could be to place all the game logic from this video inside another while loop. So you'll have two loops, with the code from this video nested inside. Something like while program is running: **all tic tac toe logic code from this video** check above results and update score set whether the loop can end or not (if someone has won the 2/3) Print winner
is it after an if? if it is, it should be if prev_turn == turn: so if theres no if, you only need to put only one "="; prev_turn = turn "==" checks if two values are equal, "=" is (for example) to assign a value to a variable AND OF COURSE, IM STILL LEARNING TOO, i've started coding 2 weeks ago, i could be completely wrong, but thats what i understood ATM
Hi. That would technically work for the purpose of a single use game. But from what I understand, I think using exit() is generally a practice best avoided for production type code. Using exit() will just end the program. If we wanted to say, allow the players to replay the game without having to run the script again, exit() wouldn't be the best approach. The loop approach allows us to do things such as encapsulating our code into other loops.
Hey everybody! In the spirit of learning, here are some ideas you can try and implement if you finished the video and are looking to add a bit more to this project.
Exercise: Allow the players to put in their names so it doesn't just say "Player 1" and "Player 2"
Exercise: Add a timer to the game so that each player only has a certain amount of time to make a decision (hint: checkout the built in "time" module)
Exercise: Add an option to replay the game when it ends. Also add a game counter to keep track of how many times each player has won.
Challenge Exercise: Add a single player mode with some AI functionality for the second player. It doesn't need to be a fancy algorithm, just think about how you can have the program make a valid move. Once you get it working, see if you can come up with something better!
Happy coding!
Good to see you back! You still have, by far, the best tutorial on the Game States I've ever seen.
Really appreciate the support!
Truth
Thank you! This was a great learning experience for me to follow along with and rebuild. Taught me some new tricks as a beginner to Python and was useful for fulfilling a project requirement for my course work.
Happy to hear!
Omg, i really need to learn a lot. I tried to do this exercise by my self and ended up contemplating bout suicide, I wish I was a pro like you at problem solving
Hiya. I may make it look easy, but what you don't see behind this tightly edited video is the years of experience I've had with problems like this. When I started learning to code, I could barely wrap my head around even simple tasks. Now I'm a lot more confident, but still learning. With some time and patience, I have confidence everything will click for you! Wishing you all the best in your coding journey : )
Great to see you back! You are the best Pygame youtuber and your tutorials help me a TON.
Thanks for the support! Got some Pygame stuff planned for the near future : )
This is a well put together tutorial video. Thanks for making it!
Your turtorials are amazing! You deserve more support!
Thank you!
bruh you literally destroy programmer who are making hour length video just for this simple code
Appreciate the kind words : )
i have just started python and it was very good experience thanks
its not working, at 2:03 draw_board has a red line underneath it so it isnt working im doing everything the video tells me to
Thank you for the video. I tweaked the code so that you could choose 1 or 2 players and play the computer.
Nice work! Happy to see you were to take my project and create something even better : )
such an awesome tutorial.
It was a great tutorial, very easy to follow. But one thing i am not able to grasp completely. Why did we call the check_turn function to check who the winner is? I mean the check turn function only returns the number of turn. Or what i am able to understand is, that as soon as the player 1 (let's say) is done with their final winning turn, this function return that and the winner is declared! please help me understand this. thankyou!
And once again, great tutorial!
Fantastic work!
Thank you!
Underrated
Appreciate it!
amazing video!! 3:11 which keys did you use to convert them instantly? or was it cropped part of the video?
Thank you! Unfortunately that was just a copy paste from a notepad on a different monitor haha.
@@CDcodes kk, gotu. thank ou for being honest
Thank you
thank you for an amazing video. However im a little confused about line 19 in main file. How does that check if there is an X or O. The last part isnt even a dictionary. Id appreciate a response thanks :)
We start by equaling the previous turn to the current turn (Line 19). Because there's an infinite number of things the player can enter other than a correct board position, the idea is that we assume whatever they give us is invalid input. If they provide invalid input, we don't change the turn. If they actually give us an valid board position, then we increment the turn counter. When the next iteration of the loop occurs, it will check to see if the turn counter when up or not by comparing it to the previous turn. If it didn't, then our assumption that the player would give us something wrong is correct. so we want to print an error message for them.
"churn" lol
Thank you!
Happy to Help!
This is amazing, thanks
You're very welcome!
Hi! I think your logic is great here! I am very much a beginner in python and am curious if you have any *hints* to implemting another game play? does turn = 0 need to be reset somehow?
I am trying to implent best 2/3 gameplay to your code. I feel very far off. I started as:
if finished:
if what_turn(turn) == 'X':
print("Player1 is the Winner!")
else:
print("Player2 is the Winner!")
else:
print("NO game!")
print('Do you want to play again?(Y/N)')
play_again = input().lower()
gameplay = True
if play_again == 'n':
gameplay= False
print('
Thanks for playing!')
Glad you enjoyed the video! One way to approach it could be to place all the game logic from this video inside another while loop. So you'll have two loops, with the code from this video nested inside. Something like
while program is running:
**all tic tac toe logic code from this video**
check above results and update score
set whether the loop can end or not (if someone has won the 2/3)
Print winner
Amazing
I don't understand how prev_turn == turn results in an invalid entry. Can someone help me understand?
is it after an if? if it is, it should be
if prev_turn == turn:
so if theres no if, you only need to put only one "="; prev_turn = turn
"==" checks if two values are equal,
"=" is (for example) to assign a value to a variable
AND OF COURSE, IM STILL LEARNING TOO, i've started coding 2 weeks ago, i could be completely wrong, but thats what i understood ATM
yo is that visual code? or smth cuz i see it familiar
It is replit link in the description
my code isn't that great (it's almost twice as long as yours) but the game works perfectly.
Congrats on building the game! Working code is always better than pretty code that doesn't
Which application are you using??
replit, link is in the description
can it be run on vs code?
It sure can
there's a correction in the exit section if choice=='q' it should'nt be playing =false instead ......if choice =='q' exit()
Hi. That would technically work for the purpose of a single use game. But from what I understand, I think using exit() is generally a practice best avoided for production type code. Using exit() will just end the program. If we wanted to say, allow the players to replay the game without having to run the script again, exit() wouldn't be the best approach. The loop approach allows us to do things such as encapsulating our code into other loops.
@@CDcodes then we'll have to write additional line of code to restart the game
Ok always x wins.. 🤣
Thank you