Teaching an AI to play a simple game using Q-learning(practicalai.io) |
Teaching an AI to play a simple game using Q-learning(practicalai.io) |
- There are N (usually 21) tokens in a pile. - A turn consists of removing 1, 2, or 3 tokens from the pile. - The player who removes the final token is the winner. - The opponent will always take tokens equal to n mod 4 if that is a valid move, otherwise will play randomly (this is the optimal strategy). - The AI plays first.
You can see my write-up here: [1]. One of the most interesting things for me was visually inspecting the action scores (at the end) to see how the agent learned the optimal strategy over time. My configuration took 3000 games to reach the optimal strategy against against a strong opponent (opponent epsilon = 0.1), and substantially longer as the opponent starts to play worse.
[1] https://www.dropbox.com/s/eooqlhgg98zc398/Q-Learning%2B21.ht...
There's a mechanical version of an AI from the 60s called Dr. Nim. It doesn't learn to play, of course, but instead it has a 3-bit binary counter.