Deathmatch: creatures fight! 

This guide will tell you what the deathmatch is, what are its rules, what can be changed in the default settings and how to run a sample battle between two creatures.

Table of contents:

  1. Introduction
  2. Quick start
  3. Description
  4. Sample battle
  5. Statistics

Introduction

The idea of the deathmatch is that each team of users provides a genotype of their combatant (designed manually or evolved), and then these creatures compete. The teams try to design a creature that can win against the opponents. All tricks are allowed!

Deathmatch or Player vs All is a widely-used gameplay mode integrated into many shooter and real-time strategy computer games (the other popular mode is "capture the flag"). Usually, the goal of a deathmatch game is to kill (or "frag", from the military term) as many other players as possible until a certain condition or limit is reached, commonly being a frag limit or time limit. Once one of these conditions is met, the match is over and the winner is the player that accumulated the greatest number of frags.

The deathmatch is defined by three things: goal, combatants, and rules. The combatants in games are usually the human players or AI bots, and their main goal is to kill other players. In a team version, the players gather in groups of i.e. 5 units and try to kill players from other teams. Details depend on the rules, which determine physics forces that influence the position of player, define what does it mean to attack, kill another player and so on. It is also possible to provide some special rules which change the behavior (i.e. invisibility – the opponents cannot see you, but you can see them). Sometimes the goal might be also altered and in addition to "fragging" other players, one has to defend a crucial area ("King of the Hill") or capture some objects in the game ("Capture the Flag").

Quick start

You should read below to learn more about this experiment, however, if you really want to try it quickly, here are some hints.

To start the deathmach, each team has to prepare their combatant genotype. For demonstration purposes, there is a deathmatchsample.gen file with two sample genotypes: "Food Finder" and "HP Box Finder".

Ready, steady, GO!

First, you need to download this archive and unpack the contents of the scripts directory to the Framsticks "scripts" folder.

You should select the experiment definition using menu: Simulation->Parameters, or press CTRL+P. From the dropdown combo pick "deathmatch" and click "OK".

Now you have to prepare some genotypes in the gene pool. You can load deathmatchsample.gen to start off with it. After you loaded your genotypes, go again to the Parameters window and press "Initialize experiment".

The simulation is now running, and when the stopping conditions are met, the simulation will stop by itself. You can then check the output files with statistics to see who won and what happened during the deathmatch.

You can also change any parameters described below – they can influence the results of the battle. Please be aware that the default settings where picked to be quite fair, and messing with these parameters can lead to an unbalanced game. Still feel free to experiment! :)

Included files

  • scripts/deathmatch.expdef – the main experiment definition. You will find comments for the code, feel free to look inside it to understand deeper how the experiment works.
  • scripts/deathmatch-levels.inc – the definition of available levels. If you add your own, new level by editing this script file, remember to change the maximum value of the property "level" in deathmatch.expdef.
  • scripts/deathmatch-smellPopulation.neuro – a variation of smell-food neuron. It was modified to smell a population given by the property "pop" in genotype definition, instead of looking for food in population #1.
  • scripts/deathmatch-utils.inc – helper methods not strictly connected with the deathmatch mechanics.
  • deathmatchsample.gen – sample genotypes for deathmatch.
  • gp/teamsEnergy.gp – sample gnuplot script for plotting energy flow chart.
  • gp/teamsMembers.gp – sample gnuplot script for plotting team size chart.

Description

In Framsticks, we can implement a deathmatch ruleset that will allow creatures to fight against each other. To do so, one has to take some assumptions about the behavior in different situations that can occur during a battle. In other words, we need to define our goal, combatants and rules.

Goal

We provide a standard team deathmatch, which means that the goal of a team is to eliminate other teams from the game. The winner can be only one and it is the last team that survives the gauntlet.

However, a tie is possible between the teams if the last creatures from different teams will be killed at the same time and no creature will be alive on the battle field. This is called a "total annihilation" and there are no winners in this case.

Combatants

As this deathmatch is a team deathmatch, framstick creatures are grouped in teams and the basic rule is: "My team vs WORLD!". The number of teams and team size can be set in experiment parameters under the section "Team".

There are two methods of forming a team – either it consists of a given number of random creatures created from the gene pool, or it is build in such a way that Team 0 has creatures of genotype 0 from gene pool, Team 1 has creatures of genotype 1 from the gene pool, and so on.

Each creature can be descibed by a few parameters:

  • energy – each creature starts with creatureStartingEnergy. This tells how many attacks the creatures can survive. If the energy drops below 0, the creature will die.
  • bonus damage energy – increased by collecting specific items on the battlefield, and decreases with time to a minimum of 0. This is used to calculate bonus damage during creature attacks.
  • attack cooldown – after each attack, this value is set to attackCooldown, and decreases with time to a minimum of 0. If it is higher than 0, the creature cannot attack.

The behavior of the creature is dependent on its genotype, but there are no restriction on its structure: you can use all elements you want for your creature.

The starting locations of the creature depend on the team it is assigned to. Each team has its own spawning location which is placed near the boundaries of the world in some radius from the center of the map, but for each team, the angle is different. So if we have 2 teams, they will spawn on the opposite sides of the world, but if we have 5 teams, the first will be placed at the angle of 0 (=360*0/5) in given radius from the center of the map, and the next team will be placed at the angle of 360*1/5 degrees, the third one will be at the angle of 360*2/5, and so on. The creatures will be rotated randomly (but you can modify script source to make them face the center of the map). If there is no free space for a creature in the spawning area, this may cause two creatures to be born in the same location and collisions will occur right from the start of the simulation.

Collectibles

There are two types of collectibles, and both disappear upon collection.

HP Box – when a creature picks the HP Box, its energy will be increased by the amount of energy the HP Box had.
Weapon Box – when a creature picks a Weapon Box, its bonus damage energy will be increased by the amount of energy the Weapon Box had.

The timespan of each collectible can be changed in experiment settings under the section "Collectibles".

Battle rules

Battle system consists only of attacks, which are executed during collisions between two creatures. To make it simple, we define one creature as the attacker and the other one as the defender, which is the attacked creature.

The equation for the value EnergyLoss that will be substracted from the energy of the defending creature is given below:

EnergyLoss = friendlyFireDamageMultiplier * ( diceRollsSum * creatureDamage + bonusDamageModifier )

As you can see, the formula is based on the dice rolls. The attacker rolls X times a K-sided dice which gives diceRollsSum. Both X and K can be set in experiment settings and they are set by default to X=5 and K=1 to reduce randomness in the encounter. The sum of the rolls is then multiplied by creatureDamage, which can also be adjusted in the settings. The result is then increased by the creature's bonusDamageModifier (which rises when a creature collects Weapon Upgrade packs). The bonusDamageModifier is calculated by multiplying creature bonus damage energy by upgradeMultiplier. If the fighting creatures are from the same team and friendlyFireDamageMultiplier modifier is not 0, then the calculated number is multiplied by the friendlyFireDamageMultiplier modifier. The computed EnergyLoss value is substracted from the defender's actual energy value. If the energy of the defender drops below 0, the defender will be killed.

However, the attacks cannot occur one after another. There is an attackCooldown property, which tells how many simulation steps must pass between two consecutive attacks of a given creature. This can be interpreted as the "weapon reload time" that is present in many games.

Each parameter used to change the behavior of attack can be adjusted in experiment settings under the "Attack rules" section. The default values of these parameters ensure that results of the battles will not be too random.

Sudden Death mode

The Sudden Death mode is a guarantee that the simulation will be finished at some point. During this mode, each creature will lose a small amount of health points every simulation step. This can be set up in the experiment parameters and can be interpreted as "aging" of the creatures.

By default, the Sudden Death is turned off and will turn on only when a stagnation occurs. The stagnation is defined as a number of simulation steps during which there were no collisions between creatures yielding any energy change. However, if any fight occurs during the Sudden Death mode, this mode will be turned off and the counter of simulation steps before it will be turned on again will be reset.

Experiment parameters

The table below describes all the parameters that you can adjust.

SectionNameDefault valueDescription
Globallevel0The number of a predefined level to use for the battle (set to -1 for random level selection). Currently, there are three levels with flat ground and differing world sizes, but you can create your own, custom map as well.
stagnationInterval5000If no combat occurs during this number of steps, the Sudden Death mode is turned on (0 = Sudden Death mode all the time)
stagnationHealthReduce0.1If Suddent Death is turned on, creatures will lose this amount of HP each simulation step
debugfalseShow additional debug messages in the "Messages" Window
TeamteamCount1

The number of teams in the Deathmatch. If set to 1, the number of teams will be equal to the number of different genotypes in the gene pool, and each team will consist of only one unique genotype, i.e. Team 0 uses the first genotype, Team 1 uses the second genotype, etc.

Otherwise, the number of teams is equal to this parameter, and creatures for these teams are randomly picked from the available genotypes.

teamSize5Number of creatures per team
teamSpawningAreaSize20Spawning area size for team
creatureStartingEnergy300Starting energy of creature
Attack rulesdiceSides1Number of sides of dices
diceCount5Number of dices to roll per attack
creatureDamage10Basic damage multiplied by the result of dice roll
friendlyFireDamageMultiplier0.0Multiplier of energy taken when Creatures of the same team collide. Set to 0 for no friendly fire, set to 1 if full damage should be applied when fighting with own team member
attackCooldown1000Number of simulation steps between two consecutive attacks of a creature
CollectiblespickupNotStagnation100If true, picking up an item will restart counting towards stagnation. This results in longer battles
hpBoxStartingEnergy100Starting energy of a HP Box
hpBoxIdleEnergy0.0Amount of energy lost by a HP Box each simulation step
hpBoxProbability0.0005Probability of a HP Box being spawn in each step of simulation
hpBoxTotalCount10Maximum number of HP Boxes in the field
upgradeBoxStartingEnergy500Starting energy of an Upgrade Box
upgradeBoxIdleEnergy0.0Amount of energy lost by an Upgrade Box in each simulation step
upgradeBoxProbability0.0005Probability of an Upgrade Box being spawn in each step of simulation
upgradeBoxTotalCount10Maximum number of Upgrade Boxes in the field
upgradeBoxDecay0.1How fast upgrade fades from a creature. In each simulation step, the creature's damage bonus energy will be decreased by this amount until it reaches 0.
upgradeMultiplier0.1Multiplier of bonus damage

Sample battle

Now that you know how the deathmatch works, it is time for our first battle. We will use two creature genotypes – one will be standard, and the other will use the same genotype, but will be equiped with a different sensor.

The first team will be HP Box Finder. It was originally evolved by Miron Sadziak under the name "4 legged Food Finder", but now it is equiped with the "Smell Population neuron", which is configured to smell HP Boxes. Its genotype is:

lllfffX[0:2.420,2:-2,1 :-1][-1 :1,0:1,0:-1][-1:1](RRlllfffMMMX[|-1:-10]lllFFFMMMX[|-2:-1],fffIXlllfffMMMsX[|6:10,3:-10](RRlllfffMMMIX[|-4:-10]lllFFFMMMIX[|-5:-1][Sp,pop:0],,RRlllfffMMMIX[|-7:10]lllFFFMMMIX[|-8:-1][Sp,pop:0]),RRlllfffMMMX[|-10:10]lllFFFMMMX[|-11:-1.784])

The second team will consist of 4 legged Food Finders, the original creation of Miron Sadziak. Not only they move, but they can also turn in the direction of food, based on smell. Unfortunately for them, everything except themselves smells like food, so when we put two such creatures side by side, they will start to run in circles. The genotype is as follows:

lllfffX[0:2.420,2:-2,1 :-1][-1 :1,0:1,0:-1][-1:1](RRlllfffMMMX[|-1:-10]lllFFFMMMX[|-2:-1],fffIXlllfffMMMsX[|6:10,3:-10](RRlllfffMMMIX[|-4:-10]lllFFFMMMIX[|-5:-1][S:1],,RRlllfffMMMIX[|-7:10]lllFFFMMMIX[|-8:-1][S:1]),RRlllfffMMMX[|-10:10]lllFFFMMMX[|-11:-1.784])

The difference between the two creatures is that "HP Box Finder" will try to follow HP Boxes, while "Food Finder" will follow anything.

The default parameter settings will be used.

The above image shows the initial state of the simulation after using the "Initialize Experiment" button in Framsticks. As we can see, the two teams are starting at different locations, and they are facing the center of the map. Let's run the simulation!

The picture above was taken after some simulation steps, when some battles already occurred.

What is easy to notice is that non-walking creatures will most likely lose against mobile creatures. This is because moving creatures have a higher probability of picking up a HP Box, which will increase their energy and, in case of the Sudden Death mode, they will survive longer than the non-walking creatures. If the walking creatures do not pick any collectible, then there will be some probably of a tie. In extremely specific and rare situations, non-moving creatures might win with the mobile ones.

Let's find out what are the results of our engagement.

Statistics and analyses

This experiment can generate two kinds of statistics – team-wise and creature-wise. Both are provided as CSV-formatted text files. You can use gnuplot scripts that we provide to plot the statistics, or use other tools to plot charts.

Team-wise statistics is stored in the teams1.txt file. It contains information about energy flow for each team and in total, and also information about team sizes. This can be used to observe behaviors such as picking HP Boxes and activation of the Sudden Death mode.

The chart above illustrates the most common dynamics of energy flow during the simulation of "HP Box Finders" versus "Food Finders". However, sometimes the dynamics can be more interesting:

Suprisingly, there was one simulation run in which Food Finders actually killed HP Box Finders:

Lets look into this unexpected case. The creature-wise statistics will tell us more about it.

Creature-wise statistics is stored in the creatures1.txt file. It contains information about every single combatant. The rows are in ascending order according to the lifespan of the creatures. For each creature, the number of kills, assists and collectibles pick ups are counted. The total number of damage dealt and received, and creature lifespan are stored in the file as well.

The table above is for the typical scenario – HP Box Finders (Team 0) win. The data is compatible with the first chart of the energy flow. As you can see, some battles occured, and HP Box Finders picked more upgrades so they could survive longer during the battle. The battle finished with the Suddent Death mode, because Member 4 from Team 1 (Food Finders) has been dealt with only 250 damage out of the starting value of 300 HP points. This means that he lost 50 points because of the Sudden Death mode.

This time the table summarizes the unexpected case when Food Finders won the battle. However, HP Box Finders picked quite a lot of HP Boxes (hey, they were made to do so!). Still, they lost to a single veteran unit from Food Finders, who left alone, picked a tremendous number of upgrade boxes (43!). This gave him a total of 2150 bonus damage, if only this guy could use it immediately (2150 is the number of collected upgrade boxes multiplied by upgradeBoxStartingEnergy and upgradeMultiplier, 43*500*0.1). Even though the bonus damage fades after some time, he was able to finish his last two opponents in direct combat and had enough HP points to survive their attacks.

Still, in 10 consecutive battles between those two species, the result was 9:1 in favor of HP Box Finders, so the pickups have given them a tactical advantage over the opponents.


Framsticks Deathmatch was developed by Mateusz Cicheński during the Bio-inspired computing and systems lab. If you have any comments, suggestions or ideas, please contact him (alternate address) or the mentor.