I took some of the things I’ve created in the past and put them into one place. Then I made a tic-tac-toe game and today I just added a dots and boxes game. the games are neat.
contains:
a lion I built in 2008
a bunch of turrets that I made a couple years ago
a big icosphere I generated a couple years ago
the new user machine that I wrote last summer
the point-in-polygon raycasting algorithm for zone detection that I shared a few months ago
yuss. I made a perfect tic tac toe bot that you can play against. It can play X or O and rotates the board randomly when it thinks so it doesn’t always just pick the same spot.
This is the logic for the perfect bots, in order:
1: If you can win, win
2: If you can block, block
3: (this gets run multiple times for the different orientations)
Now make an algorithm without hard coded strategies for a variable N by M board size when you win when you have X in a row, that creates a game tree and then chooses the option that will provide the best results ? And maybe alpha-beta pruning if for some reason you have a game space that is too large (probably not). Difficulty of the bot is related to the maximum depth of the game tree and the probability for it to make a random move (to not pick the best strategy)
That would have to be for the dots and boxes game. Tic-tac-toe is already solved 3 moves ahead when the default response is to win or block. Dots and boxes has way more possible branches.
added easy and hard bots for dots and boxes. the easy one moves randomly and captures any squares that can be captured. the hard one doesn’t make any 3-sided boxes until there are no other moves left.
I made a three-player version of dots and boxes. The order is red, green, blue. They wait .2 seconds before moving. The first player gets to pick which players are bots. You can make all of them bots and the game goes fast.
You will not win if you play the perfect bots. You will not lose if you also play perfectly. You will win if you play perfectly against the easy bots (or against a human who does not play perfectly.)