Search Based Software Engineering

project - Evolutionary Game

by André Karge - andre.karge@uni-weimar.de

General

You have to develop an evolutionary algorithm for the game EGame. EGame consists of two populations. You are in charge of one population and have to control its breeding behaviour.

The game can be found at link

Submission Date: 2019-08-01 23:59 <!-- We will make a tournament where your genetic algorithms compete against each other! The results (and the tournament) will also be presented at the open lab night of this years summaery (2018-07-13). The winner will also get a price :) !

The tournament is open for everyone - so feel free to invite your friends to submit a solution. --> picture of game

(The graphics are not final yet and will be changed in the future)

After some time, there will be breeding time. At this point, your breeder will be called, allowing to breed new individuals. However, you can only add as much individuals as there are dead inidividuals in your population. (Hint: you can still use the dead individuals dna to perform breeding but you have to remove the dead individuals from the population in order to add new ones afterwards)


Individuals

individual

Each population consist of individuals. The maximum number of individuals is defined by the game environment.

Individuals move over the playground and try to seek / avoid every element on it. Each individual has certain traits which control how they perceive their environment, how strong a desire is to move to / repell from certain objects and what special abilities they develop to get advantage.

To survive, they have to eat. This could be food, poison, health potions or corpses.

By default, all individuals lose an amount health over time. If their health reaches 0, they are marked as dead and create a corpse at the position they died.

Also, they are able to attack individuals of the opponent population or be attacked by them or additional predators.

Predators

predator

Predators are a special kind of individuals which are not controlled by users. They spawn from time to time on the playground. All predators can only perceive individuals (of both populations) and corpses. They desire to seek and attack individuals and eat their corpses. Individuals can be adjusted to avoid predators. Predators move slower than individuals but that doesn't mean that they are not able to catch them.


Traits

There are three types of traits: perception, desire, and abilities Each attribute of these three traits is a value between 0 and 1.

But, the sum of all attributes of a trait has to be always 1!

Perception

perception

Perception defines how much an individual is able to perceive its environment (a radius around the individual). It is divided into these perceptions:

  • food
  • poison
  • health potions
  • opponents
  • corpses
  • predators

If one of these perceptions is 1, then it will have all of its perception focused on it and will not perceive elements of the remaining classes at all. (Sum has to be 1)

Desires

Desires define how strong individuals are attracted / repelled from certain elements. It is divided into these desires:

  • seek food
  • dodge poison
  • seek health potions
  • seek opponents
  • seek corpse
  • dodge predators

Again, if one of the desires is 1, then it will only concentrate to fulfill it (by all costs), while ignoring everything else. (Sum has to be 1)

Abilities

Individuals can have additional abilities to ease their life or to get advantage on certain things.

  • increased armor (reduce the damage taken by opponents / predators)
  • increased speed (increase own maximum speed)
  • increased strength (increase damage dealt to opponents)
  • poison resistance (reduce damage taken by poison)
  • toxicity (deal damage to attacking opponent / predator)

(These have also be summed up to 1)


Items

This are the items which can be consumed by individuals

Food


Food increases the health if consumed.

Poison


Poison increases a poison value of the individual. All individuals start with 1 poison and for each consumed poison, this value is increased by 1. The poison value controls how much health is reduced each frame (If the poison value is high, the health will be reduced faster) The amount of poison damage is only reduced by the poison resistance ability. But the posion value can be reset by consuming a health potion.

Health Potions


Health potions increase the health by a small amount and also reset the poison value back to 1 if consumed.

Corpses


Corpses are only spawned after an individual (or a predator dies). They increase the health by a small amount but also increase the poison value (based on a fraction of the deceased individuals poison) of the individual who eats it.


Task

Write your own Breeder class to define the breeding of your population. You know, a genetic algorithm consits of these parts: initialization, selection, copy, crossover, mutation.

This class should implement two interfaces: initialize_population and breed. Initialize will get the number of individuals a population can have at maximum and the color of the population. It should return a (python) list of individuals. breed will get the current population (consisting of living and dead individuals) and should, again, return a population after the breeding procedure.

An example can be found at genetic_algorithm/breeder.py

Each individual has a get_dna() method to access its current traits. You should come up with your own assess_fitness method, which defines what makes up a good and a bad individual.

You can pass the new dna created by your genetic algorithm to the constructor of a new individual.

You are allowed to use the dna of a deceased individual, too. (Keep in mind that new individuals should spawn at the position of a surviving individual and not somewhere on the playground)


Hints

DNA This is how the DNA of an individual looks like:

# dna = [perception, desires, abilities]
# perception = [food, poison, health_potion, opponent, corpse, predator]
# desires = [seek_food, dodge_poison, seek_potions, seek_opponents, seek_corpses, dodge_predators]
# abilities = [armor, speed, strength, poison_resistance, toxicity]

dna = [[0.3, 0.7, 0, 0, 0, 0], [0.3, 0, 0.6, 0.1, 0, 0], [0.3, 0.2, 0, 0, 0.5]]

Dead or Alive Individuals have a bool value named dead. If it is True, the individual is dead.

Statistics You have access to individuals statistics. It consist of:

  • time survived (in amount of frames)
  • food eaten
  • poison eaten
  • consumed potions
  • consumed corpses
  • enemies attacked
  • attacked by opponents
  • attacked by predators
  • food seen
  • poison seen
  • potions seen
  • opponents seen
  • predators seen
  • corpses seen

Note: It could be that some of the code will be changed because the game is still in development! We will try avoid marginal changes. But, the breeder interfaces should stay as they are

If you find any bugs, please contact me: andre.karge@uni-weimar.de or open an issue on github: https://github.com/digital-bauhaus/EGame/issues