MAS Hunting
Introdution
In the following report will be presented the process development of the game MAS Hunting for the course of Autonomous Systems.The game is a simulation of a hunt in a forest that will be recreated through a natural-inspired MAS composed of several animal-agents and a hunter-agent. So the relevant aspects are: the autonomy of components, the self-organisation, the ability of evolution of the agent in the environment and the non linear dynamics.Inspiration
MAS Hunting is inspired by the predator–prey model that wants to study the dynamics of two rival species. At the base of the model is the simple concept that to survive the predator has to eat the prey. So the transfer of energy represents the interaction between the two populations and the system may evolve either to overpopulation, extinction or periodical evolution. These dynamics have been encoded for the first time in the Lotka-Volterra equation ( http://en.wikipedia.org/wiki/Lotka%E2%80%93Volterra_equation ).The Game
MAS Hunting is a single-player game. The player can control a hunter in a forest where there are also prey and predators. The goal of the game is prevent the extinction of the prey and survive for a time limit by killing the hungry predators. Let's move on to describe the main aspects of the game.First of all the forest (environment) is a two-dimensional grid cells and the movements (and trajectory of the shots of the hunter) can be diagonal, vertical or horizontal. An animal, prey or predator, has a vital energy and can perform one of this three actions: move, eat, reproduce. Each movement costs energy to the animal as long as it becomes hungry and needs to feed.The prey move until they run out of energy and at that point they stop in a cell to eat grass as long as they are filled. The reproduction happens if two prey are in the same cell and are not hungry; it costs half energy at the parents. A prey dies if it's eaten by a hungry predator.The predators move randomly until they become hungry and dangerous. When a predator is hungry and is about to move, it checks if there is a prey in the eight surrounding cells and move to it. In fact the hungry predators can only eat a prey that is in their own cell. Attention because if the hungry predators do not find a prey can also bite the hunter. The reproduction of predators has the same dynamics of the prey. At last a predator dies if it runs out of vital energy or if it's hit by an hunter's bullet. The hunter has three lives and can move, shoot to kill the hungry predators and have to load the rifle once the cartridges are over. If he's bitten three times by a hungry predator, the hunter dies and the game is over.At the end of the game, if the hunter and at least a prey are alive, points are awarded as follows: three points for every hungry predator killed, five points for each prey remained alive and ten points for each hunter's life remained.Requirements
Design and build a software prototype of the game MAS Hunting described in the previous section.Analysis
Glossary
Term | Description |
---|---|
FOREST | Environment of the system modelled as a two-dimensional grid cells in which the other entities are situated |
PREY | Autonomous and active entity that moves, eats and reproduces |
PREDATOR | Autonomous and active entity that moves, eats the prey (or bites the hunter) and reproduces |
HUNTER | Autonomous (or controlled by the player) and active entity that can moves and shoot bullets |
BULLET | Autonomous and active entity created by the hunter who can kill the hungry predators |
- Modelling in writing of the Agents, focusing on recognition of fundamental behaviours
- Creation of statechart
- Construction of the agent using a software program
Agent | Rules |
---|---|
PREY | Move randomly in the Forest. Check to see if you’re out of energy and become hungry (you must eat grass). Check to see if you should reproduce (do you have enough energy to have an offspring). |
PREDATOR | Move randomly in the Forest. Check to see if you become hungry (you must find and eat a prey or bit the hunter). Check to see if you should reproduce (do you have enough energy to have an offspring). Check to see if you’re out of energy (die). |
HUNTER | Move in the Forest trying to stay away from predators. Check to see if there is a hungry predator and shoots to the nearest. Check to see if the cartridges are over and load the rifle. |
BULLET | Move along the trajectory of the shot in the Forest. Check to see if there is a hungry predator to hit and kill him (then die). Check to see if you’re out of energy (die). |
Interaction between agents
The following UML Sequence Diagram (with some abuse of notation) provides a simplification of the interactions between agents:Interaction with the Environment
Agent | Interaction |
---|---|
PREY | Check if there is another prey in the same cell for reproduction. (not hungry) |
PREDATOR | Check if there is another predator in the same cell for reproduction. (not hungry) Check if there are prey or the hunter in the eight surrounding cells to attack. (hungry) Check if there is a prey in the same cell to eat. (hungry) Check if there is the hunter in the same cell to bit. (hungry) |
HUNTER | Check if there are predators in the eight surrounding cells to get away. Check if there is a hungry predator to shoot or if there are more to choose the nearest. |
BULLET | Check if there is a hungry predator in the four surrounding cells to kill. |
Prey Agent and Predator Agent Statecharts
Hunter Agent and Bullet Agent Statecharts
Abstraction gap
In this part we want to fill up the gap between the model and the technology implementation.We have to choose an agent-based tool-kit that allows us to have:- a flexible environment to dynamically add (reproduction prey and predators, bullet's hunter) and remove agents (prey eaten by the predator, predator hit by a bullet)
- possibly based on grid environment in which the agent can move and interact
- not extremely complex because we want to quickly build a prototype
Implementation
For implementing a model in NetLogo we have to work on three tabs:- Interface: The Interface is the main tab where you interact with your model and see your agents behaviour and visualize data. It can contain buttons, slider bars, switches, monitor boxes, and plots in addition to the environment the agents live in (the larger black window).
- Info: The Info tab simply contains textual information for the user on how to best understand and use the model.
- Code: The Code tab is a textual environment that contains the code that defines the rules which determine the behavior and attributes of the agents in the model.
breed [prey a-prey]
breed [predators predator]
breed[hunters hunter]
breed[bullets bullet]
prey-own [energy hungry eat_time]
predators-own[energy hungry]
hunters-own[target vision cartridges charge_time ready_to_shoot]
bullets-own[energy]
breed [predators predator]
breed[hunters hunter]
breed[bullets bullet]
prey-own [energy hungry eat_time]
predators-own[energy hungry]
hunters-own[target vision cartridges charge_time ready_to_shoot]
bullets-own[energy]
- prey have a vital energy, a variable to indicate if they are hungry and a variable that indicates the time taken to eat grass (eat_time).
- predators have a vital energy and a variable to indicate if they are hungry (red color).
- the hunter has: a variable that indicates the nearest hungry predator to shoot (target); a variable that indicates the the number of patches in which the hunter can see a hungry predator (vision);a variable that indicates the number of shots remained (cartridges); a variable that indicates the time taken to load the rifle (charge_time); a variable that indicates if the hunter can shoot or not (ready_to_shoot).
- The bullets have a a variable that indicates the maximum range of the shoot (energy).