You are on page 1of 6

Evolved Creatures

COSC343 - Assignment 2
Alex Gregory 4115039

COSC343 - EVOLVED CREATURES 1


How the simulation works
The simulation differs from the assignment specifications in a few key ways. These
changes were made on an ad hoc basis to improve the evolved performance of the
creatures within the peculiarities of this environment.

Crossover

Its imperative that a crossover makes sense. My thinking was that, if the child is to
inherit some characteristics of the parents in a meaningful way, they should receive both
the action and the weight for that action from the same parent. For this reason, rather
than a simple crossover point, individual characteristic sets are mapped from parent A
and parent B into the child.

Selection Mechanism

Parents are chosen through a weighted random roulette style process. In the first few
generations, if the environment was sufficiently adverse, wed see that perhaps just one
creature would survive the length of the generation. The performance of the selection
algorithm was greatly improved in circumstances where there were alive creatures when
we heavily prioritised those creatures in the selection algorithm above dead creatures.

This means that, when there are alive creatures, it becomes highly unlikely that a dead
(even a recently dead one) creature will be selected for pass their genes onto the next
round.

Between creatures that are alive, there is effectively a standard roulette wheel style
selection weighted off their energy level at the end of that round.

Selection Mechanism - elitism

COSC343 - EVOLVED CREATURES 2


At each round the creature that has the highest energy level is asexually reproduced into
the next round. Keeping the best solution at each round intact in the next one appeared to
confer a performance advantage to the genetic algorithm, which is why I added this in.

How creatures work out what to do

The motivations or impulses from which the creature decides what to do are added
together and the largest one is selected.

e.g.
- there is a monster next to my left so (my chromosone informs me that) I should go to
the right (if legal) (weight 0.5)
- there is a strawberry to my right so (my chromosone informs me that) I should go to the
right (if legal) (weight 0.9)
- there is a strawberry south of me so (my chromosone informs me that) I should go
South (if legal) (weight 0.9)
- then:
The largest impulse is to the right (1.4), so Ill do that.

n by m arrays

The creature, monsters and food item operate within a space of 30x30. The dimensions n
and m are both 32. This means there is a buffer around the creature space which means
algorithms the creature (and monster) use to check their surroundings are simplified.

COSC343 - EVOLVED CREATURES 3


- Performance

3,000
total energy levels at end of each

2,250
generation

1,500

750

0
generation 15 30 45 60 75 90 105 120 135 150 165 180 195

40
Remaining creaures at end of each generation

30

20

10

0
generation14 28 42 56 70 84 98 112 126 140 154 168 182 196

From the above graphs, its apparent that perhaps the large number of generations wasnt
so necessary. Graphs are useful - this wasnt apparent when watching the numbers. It
seemed at the time that incremental gains in the remaining energy level continued well
past 50-100 generations. I could well be wrong!

COSC343 - EVOLVED CREATURES 4


Average population Fitness (including dead)
Average populational fitness graph. energy drain is continued which results in negative
values. This means that we punish early deaths harder than later ones, which seems to
make sense!

50
Average population energy

37.5

25
level (fitness)

12.5

-12.5

-25 Minimum

-37.5
generation16 32 48 64 80 96 112 128 144 160 176 192

What this means


In this simulation, the neighbourhood was limited to the region that the creature
inhabited, as well as the squares N, E, S and W of this. Creatures quickly evolved to go
towards and eat strawberries when they saw them.

Initially, I had only placed one strawberry at each strawberry drop location. I increased
this to a uniform 5, because I ran in to issues with competition hampering the
evolutionary algorithm.

Competition meant that, as the group of creatures evolved, their performance might
actually decrease due to scarcity. Rather than one lucky creature getting all the
strawberries because none of the others were interested, they would compete and exhaust
the supply very quickly. I found that, rather than reducing the number of steps per
generation, or number of creatures (made for a poor variety in behaviours), it was better
to offer a relative abundance of strawberries.

Creatures were slower to evolve to move away from monsters. Creatures developed
strange behaviours regarding mushrooms. Probably the most evolutionarily beneficial
was to not eat and ignore (let a mushroom have no bearing on your movements.

COSC343 - EVOLVED CREATURES 5


Why I used Java
I used Java because of my familiarity with it through COMP160 and COSC241. Both in
terms of Data Structures and manipulation, but also through a little graphics work in
COMP160.

It seemed to work sufficiently well for our purposes here.

How to run the simulation


Download the zip file and export the folder to somewhere on your computer.

Open all the java files in DrJava.

Compile

Click run.

COSC343 - EVOLVED CREATURES 6

You might also like