Ants: A Computer Assisted Bullshit for random based life form research
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

6.5 KiB

Ants: A Computer Assisted Bullshit for random based life form research

Screenshot

Ants screenshot

Disclaimer

This module is intended to run as a Python3 module and is provided AS IS under the WTFPL (See LICENSE).

This module has been tested on Linux and OpenBSD systems ONLY.

However it may run on all platforms supported by both Python3 and SDL2

Your Mileage May Vary.

Goal

This programm is a pure Computer Assisted Bullshiting project trying to demonstrate that ants may have a life based on random and basic reflexes only.

It also provides a way to understand the Python3 SDL2 library.

This project is NOT science, it's CAB.

TODO

  • War between different ant factions
  • Ant subclasses (worker, warrior, ...)
  • Allow swarming when farm reach a number of individuals

Requirements

This program will requires the Python3 environment managed with pip.

It also requires:

  • The SDL2 libraries (SDL2-image, SDL2-gfx, SDl2-ttf). These libraries should be available via your system's package manager.
  • The YAML format manipuation libraries
  • The GNU make utility program

On a Debian system, you may install Python3 and the needed libraries and tools using the following command:

sudo apt-get install python3 \
                     make \
                     libyaml-0-2 \
                     libsdl2-2.0.0 \
                     libsdl2-dev \
                     libsdl2-image-2.0-0 \
                     libsdl2-gfx-1.0-0 \
                     libsdl2-gfx-dev \
                     libsdl2-mixer-2.0-0 \
                     libsdl2-ttf-2.0-0 \
                     libsdl2-ttf-dev

Installation

First, clone the Git repository, cd into the ants directory and install the requirements with pip:

git clone https://git.mcos.nc/python/ants
cd ants/
sudo python3 -m pip install -r ./requirements.txt

Installing the program to your system should be done using the provided Makefile:

cd ants
make install

Uninstall

If ants has been installed with the provided Makefile, you should use the following command:

cd ants
make uninstall

Update

Keep your ants installation up to date using the following set of commands

cd ants
git pull origin master
make update

Note that some updates may provides breaking changes, you may have to adjust your existing configuration file.

Configuration

You'll find a bunch of parameters to play with in the application configuration file ants.yml.

This file can be found in the ${HOME}/.config/ants directory.

In most case, default values will do fine and mostly have self explainatory names.

If you're experiencing problems with the DejaVuSansMono.ttf like the following error message:

OSError: Cannot find /usr/share/fonts/TTF/DejaVuSansMono.ttf

Adjust your configuration according to your setup (the sdl::font::filename configuration parameter must be a valid full path to a True Type Font).

sdl:
  font:
    filename: /usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf

Run the Ants application

Once installed, run the application by executing the following command in any terminal

python3 -m ants

Ants color and status

Color Status
White Looking for food source
Red Hailing other ant (informations are exchanged)
Green Has food and is going back home
Pink Has no food and is going back to food source
Gold Has food but has lost the way back home
On the way back home Has food Lost Status code Color
True True True 7 Gold
True True False 6 Green
False False True 1 White
False False False 0 Pink

Ants behavior

An ant moves randomly on the playground seeking for food.

Ant records ants::max_memory last positions along the path it walked. This records would help the ant going back home.

When an ant find a food source, it collects up to ants::max_food from the source and walk all the way back to the farm, following back the recorded path history. While on the way back home with food, its color turns to green.

If the recorded history goes empty before the ant reach the farm, then the ant is lost (color: gold).

When the ant get back to farm with some food, it store the food to the farm and immediately go back to the source for more food and turns its color to pink.

Ants collisions

When two ants encounter, they turn their color to red and exchange some data according to the following matrix:

Ant #1 Status Ant #2 Status Data exchange Ant #1 final status
1 0 True 0
1 6 True 0
7 0 True 6
7 6 True 6

In all other cases, no data is exchanged.

Ants life

Each ant has a maximum life time set by ants::hp configuration parameter.

This life is decreased by one for each move. So an ant with a ants::hp set to 300 will make 300 moves.

If an ant carries some food when its life comes to 0, it will eat one ration and have it's life restored back to the initial ants::hp value.

So the only way for an ant to extend its life is to find food and to carry some at the right time.

When an ant has no more life, it dies.

Farms

Each farm produces ants at the cost of one food ration. When a farm as no more food in stock it stops producing ants. When an ant store food to the farm, then ants production restart immediately.

The initial food quantity of a farm can be set by the farms::food configuration parameter.

The number of farms on the playground is set buy the farms::max_farms configuration parameter.

Sources

A food source has a maximum food quantity set by the sources::food configuration parameter.

When an ant find a food source, it collects up to ants::max_food from the source.

The number of sources on the playground is set buy the sources::max_sources configuration parameter.