It is easy to program the actors with game strategies which makes them intelligent - meaning that they are able to learn from their actions. In the following example a PacMan character moves around in a one dimensional grid. The player can place power-pills inside the cells by clicking them. The kobold eats them as soon as it reaches the filled cells. The pills rot after a predefined amount of time, loose their power and become poisonous. If the kobold eats a rotten pill, it falls ill. The next time it could eat a rotten pill, it knows about its bad power and does not eat it. The pills can have three different colors. At the start of the game, one of the color is set randomly to be the healthy pill-color. The rotten pills get the next possible color. This procedure ensures that it is impossible for the kobold to know the healthy pills from the rotten ones at the start of the game
Program code
// KoboldApp.java |
int idStart = (int)(Math.random() * 3) | the color (Sprite ID) of the pill is set randomly |
setPaintOrder(Kobold.class); setActOrder(Kobold.class); |
the kobold appears in front of the pill ( the pill disappears behind the kobold) |
Pill.getPixelColor(new Point(20, 20) | returns the color of the pill |