Take turns with the Ai taking 1, 2, or 3 sticks. Whoever takes the last stick loses. The more games you allow the Ai to run against itself, the better it will be when you play against it. I recommend having the Ai play itself around 250 times, if you want a fair game. anything after 500 is generally unbeatable, especially if the Ai goes first. Please answer questions only with digits, and not words. (say '100', not 'one hundred'.) You can play against the Ai as many times as you want. and allow it to train itself between matches. To make the Ai worse at matchsticks. Click the green flag, and allow it to train less than it was allowed to train previously.
This project only took about 7 hours, and was surprisingly easy for what it is. The more you allow the Ai to play against itself, the smarter it becomes.