From: d8ilvja@dtek.chalmers.se (Jakob Ilves)
Newsgroups: rec.games.xtank.programmer
Subject: Re: Big programs? - neural networks (long reply)
Date: 5 Oct 92 10:19:00 GMT
Organization: Chalmers University of Technology


(OK, this is a LOOONG article, but give it a chance, Thank you!)

In article <1992Oct3.122845.16732@cs.hw.ac.uk> scottd@cs.hw.ac.uk (Scott Dunn) writes:
>Hi,
>
>I have just got xtank and and it would appear with the ability to
>roll your own robots it could be an excellent framework for my
>dissertation.
>
>I was intending designing a neural network to steer a simulated car
>around a race track.  If I can change this to a neural net steering
>a tank it would save me a lot of work on a graphical front end.
>Plus the added benefit of having an excuse to play xtank :)

Hmm. Here at dtek.chalmers.se, we have a course called "programming
project" in the third grade. Some people choosed to write a kind of
"terrarium simulators" there you simulated a ground with various
gnats, obstacles etc. Three groups choosed this and one of them was
very ambitious, deciding to define a small language to program the
cute icky things with. I was very curious of this project and kinda
terrorised them a bit with various ideas :).

One of my ideas was to define a REALLY primitive way of programming
the gnats. (It COULD work for xtanks, at least in some extent)

The gnat (xtank) has a number of sensors which give it info about its
neighbourhood, its internal state (xtanks: info about obstacles,
bullets, own damage etc). Each sensor gives this info in some kind of
numerical value.

The gnat (xtank) has a number of signals coming out of its "brain"
(cockpit) which I will call "actuators" which control its behaviour.
Example: movement actions, eating, attack, mating, adjusting metabolic
its metabolic process (xtanks: rotate turrets, change speed, change
course, turn weapons on/off, fire etc).

Each of the actuators are computed using values from different sensors
and actuators. Old values might be used, for example, an actuator may
be calculated like this:

A1(0) = 0.1*A1(1) + 0.2A2(1) + 20*S2(0) + 10*S2(1) + 5*S2(2)

A1 is the actuator to be calculated. A1(1) and S2(1) are the values
that A1 and S2 had the previous frame, S2(0) is the current value of
S2 and S2(2) is the value two frames ago.

(The variables A1, A2 and S2 are taken from "nowhere" :)

By including both old and current values of a specific variable (in
the example S2) the gnat remembers a stimulation of sensor no 2 in
three frames. This could be acheived by allowing internal variables.
These variables are calculated like actuators, the main difference is
that they are not coupled directly to any actuator. However, the
internal variables might appear in the computation of a actuator or
internal variable. For example, to make the gnat "remember" a
stimulation of sensor 2 one might do like this:

I1(0) = 0.5*I1(1) + S2.

Then this I1 might appear in the computations where one wants to have
a "long term average" of S2 to be used.

The internal variables might be used to store values which makes the
gnat (xtank) "feel" afraid, angry, catious etc.

Writing these programs would be hell on earth, I know. But with a heck
of CPU, one could use evolutionary programming. For example, in xtank,
write a small, rudimentary program which makes the tanks go around and
killing foes. Then a tank dies, its program is forgotten. Upon
resurrection, it randomly picks a program from one of the live tanks
(using this kind of program of course) and mutates it a bit according
to a certain set of rules. The mutation could be everything from
adjusting a single coeffecient to adding a new internal variable (with
a simple definition) or maybe adjust a computation to include a new
term (a preferably small coeffecient followed by a value of a sensor,
actuator or an existing internal variable) or maybe deleting a term or
internal variable.

Drawbacks: How the fu.. should one represent the fact that there might
be various tanks in the neighbourhood? How to cope with all the
obstacles otherwise?

I think that a hybrid approach would be useful. First, you have a
predifined preprocessor, which in some way turns the xtank world into
a couple of numerical values. Then feed it into a gang of linear
equations as above. Also, one might define some fixed pieces of c-code
which keeps track of walls, no of enemies, internal state. These black
boxes of code have sensors and actuators. The actuators for a box
might be calculated as usual with mutating code.

Whew. A long article. Hope you like the ideas.

regards

HaJK aka IlvJa
(Jakob Ilves) <d8ilvja@dtek.chalmers.se>

Xref: sparky rec.games.xtank.programmer:509 rec.games.xtank.play:266