MENU

Fun & Interesting

Coding Challenge 154: Minimax Algorithm for Tic Tac Toe

The Coding Train 839,585 5 years ago
Video Not Working? Fix It Now

In this challenge I take the Tic Tac Toe game from coding challenge #149 and add an AI opponent for a human player by implenenting the Minimax algorithm. Code: https://thecodingtrain.com/challenges/154-tic-tac-toe-minimax ?️ p5.js Web Editor Sketch: https://editor.p5js.org/codingtrain/sketches/0zyUhZdJD ? Previous video: https://youtu.be/ZCXkvwLxBrA?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH ? Next video: https://youtu.be/R3C2giDfmO8?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH ? All videos: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH References: ? Geeks for Geeks - Minimax Algorithm in Game Theory: https://www.geeksforgeeks.org/minimax-algorithm-in-game-theory-set-1-introduction/ ? Minimax on Wikipedia: https://en.wikipedia.org/wiki/Minimax Videos: ? Algorithms Explained - minimax and alpha-beta pruning: https://youtu.be/l-hh51ncgDI ? Livestream Archive: https://youtu.be/rv98KUFtF9U Related Coding Challenges: ? #94 2048 Sliding Puzzle Game: https://youtu.be/JSn-DJU8qf0 ? #149 Tic Tac Toe: https://youtu.be/GTWrWM1UsnA Timestamps: 0:00 Introduction to the challenge 2:17 Explanation of the Minimax algorithm 8:20 Start Coding 12:54 Check to see if anybody won 14:16 Recursively check the max score for all the spots (AI) 16:51 Recursively check the min score for all the spots (Human) 18:15 Refactor using min() and max() 19:05 Fix bugs 21:13 Final output 22:46 Ideas and Suggestions Editing by Mathieu Blanchette Animations by Jason Heglund Music from Epidemic Sound ? Website: http://thecodingtrain.com/ ? Share Your Creation! https://thecodingtrain.com/guides/passenger-showcase-guide ? Suggest Topics: https://github.com/CodingTrain/Suggestion-Box ? GitHub: https://github.com/CodingTrain ? Discord: https://discord.gg/hPuGy2g ? Membership: http://youtube.com/thecodingtrain/join ? Store: https://standard.tv/codingtrain ?️ Twitter: https://twitter.com/thecodingtrain ? Instagram: https://www.instagram.com/the.coding.train/ ? Coding Challenges: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH ? Intro to Programming: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA ? p5.js: https://p5js.org ? p5.js Web Editor: https://editor.p5js.org/ ? Processing: https://processing.org ? Code of Conduct: https://github.com/CodingTrain/Code-of-Conduct This description was auto-generated. If you see a problem, please open an issue: https://github.com/CodingTrain/thecodingtrain.com/issues/new #beginners #tictactoe #minimaxalgorithm #games #p5js #javascript

Comment