Design comparison
Solution retrospective
hello just finished the tictactoe challenge open for feedback :)
Community feedback
- @loki1205Posted 8 months ago
Hi, this is a great project, I tried playing with computer and the computer knows where exactly to block the move. How does it know that? What logiv are you using for computer?
1@alex931dPosted 8 months ago@loki1205 Hello, I'm using something called the minimax algorithm. It compares a lot of moves in a tree structure and finds the best outcome based on some rules!
In this small game, I programmed my CPU player to prioritize blocking over winning. The CPU gains 2 points for blocking instead of 1 for winning. Therefore, it will always try to block the opponent. Furthermore the CPU player knows the maximum score is infinity and minimum is -infinity and will always try to reach the best score!
1
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord