A Java applet would be here.

Insight

Green dots are gobolds.
Magenta (purple) dots are goblins.
Gray dots are deadly walls.

The kobolds are in the dark stumbling around randomly.
The goblins are stumbling around, not so randomly.
The kobolds and goblins are mortal enemies.
When they can find their enemies, they slay them by bumping into them.
When they accidentally bump into their friends, their friends also die.
When they bump into a deadly wall, they die.
When they die, they are immediately replaced somewhere on the battlefield.

The goblins have a secret weapon, short-range infravision.
The infravision lets them see in the dark anything that is right next to them such as kobolds, other goblins, or deadly walls.

Unfortunately, the little goblin brains don't know how to use this infravision at first as it as a recent gift from their goblin god.
Using their limited brainpower, they must gradually learn to recognize the objects around them as either enemies to attack or allies or deadly walls to avoid.

You can toggle the goblin learning on and off by clicking your mouse on the checkbox.
Nothing terribly interesting happens until you turn it on so you may want to do so now.

You can scramble the goblin brains by clicking on the button.
This will undo any learning that has occurred.

You can test the goblin brain on a given scenario by using the grid of buttons with percentages.
Each of the buttons indicates a given direction from center, the position where the goblin would be if he were looking all around himself.
By clicking on the buttons, you can test the goblin brain on any one of 48 = 65_536 different possible scenes.
The percentages indicates what the goblin is likely to do given that scene.
As time goes on, the percentage chance to move towards a deadly wall or another goblin will drop to 0% whereas the percentage change to move to attack a hated kobold will increase to close to 100%.

Technical Stuff

The goblin brain is actually an artificial neural network.
The same neural network is used for all of the goblins.

There are 8 pixel positions immediately surrounding each goblin:

  1. North
  2. Northeast
  3. East
  4. Southeast
  5. South
  6. Southwest
  7. West
  8. Northwest.
Each time a goblin moves it scans the contents of each of the adjacent pixels to detect one of 4 different objects:
  1. Ether (empty space)
  2. Goblin
  3. Kobold
  4. Wall (deadly to the touch).
This information is used as input to the neural network.
The neural network has 8 positions * 4 possible objects = 32 inputs.
Only 8 of the 32 neural network inputs will be active at any one time.
A "1.0" is an active input; a "0.0" is an inactive input.
The first 4 of 32 inputs indicate what is in the North pixel.
If the first input is "on" (active), there is nothing (ether) to the North.
If the fourth input is on, there is deadly wall to the North.
The second 4 of the 32 inputs indicate what is in the Northeast pixel, etc.

The 32 inputs are passed through synaptic weights (variable connections) to the next layer of neurons, the hidden layer.
The hidden layer has 64 neurons.
The outputs of this next layer are passed through more synaptic weights to a final output layer.
The output layer has 8 output neurons.
When the output of the first of 8 output neurons is "on", the goblin will most likely go North.
When the output of the third of the 8 output neurons is "on", the goblin will most likely go East, etc.
When more than one output neuron is "on", the goblin will most likely move in the direction of the output neuron that is the "most on" (closest to 1.0 from a range of 0.0 to 1.0).
Output neurons that are "more on" have a higher probability of winning this competition to determine which way the goblin will move than output neurons that are "less on".

When goblin learning is on, performance feedback slowly tunes the neural network to improve its performance.
When a goblin bumps into a kobold and slays it, the winning output neuron that determined that move is rewarded and all other moves are discouraged.
When a goblin accidentally bumps into another goblin and kills it or touches a deadly wall and dies itself, the output neuron that determined that move is punished and all of the other potential moves are encouraged.

The reinforcement training algorithm is backpropagation with the desired target of the output neuron of the winning neuron set to 1.0 when the neuron is to be rewarded and 0.0 when the neuron is to be punished.
Training can take a long time. You may want to start the Java applet then disconnect from your Web server and let it run overnight.
I generally start to see results at about the time the numbers of killed goblins and kobolds exceed 1000.
You should be able to see the goblins learn to avoid running into deadly walls and each other while occasionally hunting down a nearby kobold.

The "Scramble Goblin Brains" button sets all of the synaptic weights to random values between -1.0 and 1.0.
Use this button to restart training from scratch.


http://www.alumni.caltech.edu/~croft/java/Insight/Insight.html
last updated 1996-09-06 by David Croft.
visitors since 1996-09-07