This is a small project of mine, completed in one day. I initally made it for a bet with a colleague, who told me he was unbeatable in this very simple game. So I created this bot to show him, that even he would lose.
This one just randomly selects a avaiable slot on the board. Nothing more there
This one iterates through all available slots and if there is a move the human player could make in order to win, it blocks it. if there isn't it just chooses the next available slot.
This one was a bit tricky and the algorithm behind is called minimax I think. But after reading a few tutorials about it, it is clear to me know what it does. It basically iterates through all available moves, makes a move, switches the perspective to the humans perspective and calls it self. So it recursively gets all possibillities the game could end and chooses the best move to make in order to win
To be honest: I don't know if I even come back to this, but in case I do there are a few things I would want to add:
- Maybe an online mode (very low priority)
- There is always more one can add to something like that