
Education > AI SK
AI SK is a java applet that extends the original Storm Keep game. It is a demonstration of artificial intelligence using a neural net. The applet knows how to play Storm Keep, and uses a neural net to make gameplay decisions.
I started out by writing an interface for Storm Keep that would allow a java program to automatically make all the decisions necessary to play the game.
The interface allows the applet to build buildings, train members of the population in various roles, create tools, perform research, and spend turns.
Each decision, whether it be to build a certain structure, train a specific unit type, or do certain research, is represented by a single "neuron" in the neuron net, with each neuron having a weight. This weight represents whether that particular decision is considered a "good" decision by the applet. The applet automatically adjusts these weights as it trains itself. Neurons with a higher weight are more likely to be chosen in future iterations of gameplay.
The applet is able to judge "good" decisions by their result on the overall "power" level of their kingdom after a specified number of turns. Decision series that lead to a higher power level have their weights increased, while decision paths that lead to lower power levels have their weights decreased. I also put in some limiters on weight change in decisions made further down the path, since early poor decisions can skew the accurate assessment of later decisions.
The applet shown is currently hard-coded to make twenty decisions each turn, and spend thirty turns total before evaluating its power level. The user is able to set the number of times that the applet will do this. Each iteration makes the applet smarter and smarter, and the user can see that a pattern will start to emerge. This pattern represents a series of decisions that the applet has decided (completely on its own) are a good set of choices in order to maximise power level after 30 turns of play. The applet allows the user to see the development of the neural net in real-time as AI SK teaches itself to play the game better.