HOME    C++    JAVA    TUTORIALS    PROJECTS    SMALL PROGRAMS    CONTACT    LINKS   
 
 

Small programs


GA Spore city layout
 

Genetic Algorithm calculating the optimal city layout in spore

Donwload

Spore city layout (source included, Matlab)

What is it?

Spore is a gaming where you evolve from a single cell organism to taking over the galaxy.
In this quest for galaxy domination you eventually get to a stage called civilization stage where you build your own city (this is also used in the space age).
This can be a bit tricky, you have a few building to choose from. A factory which decreases the happiness of the people,
entertainment building that increases the happiness of people and last a normal house.
These buildings can only be placed at certain locations and each location has links to other locations. Linking together
Different building either gives bonuses in increased happiness or spice (sort of money) production or can reduce happiness.

This Matlab script calculates the optimal city layout and displays a picture of how you should place the buildings.
The algorithm is a standard Genetic Algorithm which is a subtype of Evolutionary Algorithms. I thought it was fitting
to use an Evolutionary Algorithm for a game based of evolution.

For those that are not interested in the algorithm behind this but only in the result you can look at the screenshots below.

SCREENSHOTS

Min happiness: -6
Happiness: -6
Spice: 180
Min happiness: -5
Happiness: -5
Spice: 168
Min happiness: -4
Happiness: -4
Spice: 156
Min happiness: -3
Happiness: -3
Spice: 156
Min happiness: -2
Happiness: -2
Spice: 144
Min happiness: -1
Happiness: -1
Spice: 144
Min happiness: 0
Happiness: 0
Spice: 132
Min happiness: 1
Happiness: 2
Spice: 132
Min happiness: 2
Happiness: 2
Spice: 132
Min happiness: 3
Happiness: 3
Spice: 120
Min happiness: 4
Happiness: 4
Spice: 108
Min happiness: 5
Happiness: 5
Spice: 108


Portions of this website were created using the free web resources available at www.elated.com and are copyright Elated Communications Ltd 1996-2002