Snack Break Problem #22
Posted on February 16, 2017 by OldPalHappy
Last Challenge
Last challenge was to re-create the game "SUPERHOT", and we had a total of 4 people submit their creations, in order of the first to submit to the last:
I had an extreme amount of trouble trying to decide who should win, therefor, everybody is a winner! All 4 winners shall get the snack break tag for a week. Good luck on the next snack break!
~ shayner32
This week's challenge
I'm excited for this challenge! This is a fun, simple problem that can be applied to many things. In short, this challenge is to make a winning move in a game of Tic Tac Toe. As an example:
local function ReturnMove(board, side) --// Code should return: return [[ x_o _xo o_x ]] end ReturnMove( [[ x_o _xo o__ ]], "x" )
If the side parameter is o, then you would go in the same place but with an o.
You can be assured that there will always be a winning move for your code. You can make it so if there isn't a winning move the function returns false, or a random move if you wish.
Advanced Challenge
For anyone who can make the best move for a board without a direct winning move will get a special shoutout on the next snack break. This means that the algorithm would never lose in a regular game of tic-tac-toe. The computer would play perfect. You can do anything so long as it works, but I would personally recommend using the minimax algorithm.
Submission
In order to submit your attempt, simply message me, OldPalHappy, here with the model or place, open sourced. If you would like, you can also message me on discord or via the forum messaging system with a link to your code.
Commentary
Leave a Comment