Lugsole.net long logo

AI 21 Flags

Author: Lugsole

This is a demo of what can be done with a little AI in the web browser. This is an implementation of an AI that plays the "tye 21" that was played on the "Survivor" TV show. The game rules are quite simple. There are 21 flags and 2 teams/players. The players alternate turns every round. Every turn a team closes either one, two or three flags. The objective it to get the last flag.

How to get the AI to learn

There are four different AI variables to tune. These four variables are set to there default values and this gets the AI so that the AI will be near 99.99% confident for all known best moves that locks the opponent into not being able to win. The learning rate is set to 0.01 this means that the AI will learn at a relitivly constant rate increasing this number will make it learn faster and decreasing this number will make it learn slower. For this case the learning rate being large (0.1) is not that much of an issue. The minimum amount of tries is implemented so that an inital string of bad traning data does not screw up the data too much. This gives the AI the ability to correct itself over time. The maximum traning rounds is put in place so that if ot more realalisticy when ttraning takes for ever and there is not a clear correct andwer the computer stops waisting time and realizes it can not easily get the answer. The target confidence is another method for ending the traning session. This means that when the computer gains enough confidence that is knows the right answer it does not just keey tring to get a more accurate answer and just takes that answer.

Inital Matrix

\begin{bmatrix}00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\\end{bmatrix}

Table of stats

Input Correct Answer AI answer Traning rounds Confidence
1 1 0
2 2 0
3 3 0
4 0 0
5 1 0
6 2 0
7 3 0
8 0 0
9 1 0
10 2 0
11 3
12 0 0
13 1 0
14 2 0
15 3 0
16 0 0
17 1 0
18 2 0
19 3 0
20 0 0
21 1 0

Resulting Matrix

\begin{bmatrix}00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\00.00&00.00&00.00&00.00\\\end{bmatrix}

Play aginst the AI

How to play:

  • The reset AI button resets the AI back to a 'random' behavior
  • Since the player starts first, input your fist move to the "Your move" fieldand then click the "Make move" button.
  • After the players turn it the AI's turn. The AI will make a random move favoring its best move more.
  • You and the AI are only allowed to make moves of one, two or three.
  • After your turn it is the AI's turn. After the AI's turn it will be your turn. Who's turn it is can be determined by the "your turn" or "AI turn" just next to the Make move button
  • In order to make the AI decide what to do click the "Make Move" button.
turn