Model of the game world

Introduction

The main characters of the game are robots. Robots are produced by bases. Battles are held on a limited territory, called field. The field contains a number of bases, each is either owned by one of the teams or neutral. Neutral bases do not produce robots. Every robot is owned by certain team and a base can only produce robots for its owner.

The goal of each team is to capture all the bases in the field and destroy all enemy robots. Bases can be captured by robots, and robots are also capable of shooting enemy robots. Robots have limited view and shooting range. Robots of a team can communicate by broadcasting messages. Transmission range is also limited.

 

Battlefield

A field is represented by a hexagonal mesh of cells. It consists of N rows with M cells in each row. Each cell has 6 neighbor cells and is identified by a pair of numbers (x, y), 0 ≤ x ≤ M, 0 ≤ y ≤ N, where y is the row’s number and x is the cell’s number in a row (i.e. column number). Even rows are shifted right for a half of the cell size, as compared to odd rows. For any two cells of the field a distance is defined as a minimal number of moves (to a neighbor cell) to reach one cell from another (Fig.1).

Fig. 1. Distance between cells

Each cell may either be empty or contain a robot or a base. Each cell may contain one object (robot or base) only. Movement across the field consists of sequence of moves from one cell to another neighbor cell. Each direction of the movement is enumerated with numbers from 1 to 6, as shown in Fig. 2 (0 denotes absence of movement).

 

Fig. 2. Movement directions

 

 

Acting entities

Entities in the field are bases and robots.

Base is a static entity (it doesn’t move). A base is represented by a tuple <x, y, team, hitpoints, cooldown>. Numbers x and y define the position of the base in the field. The number team defines the number of the team that owns this base. The value of "−1" denotes a neutral base. The hitpoints is the number of shoots the base has received and the cooldown is the time left before the next robot is to be produced by the base.

Robot is a mobile entity (it can move). A robot is represented by a tuple <x, y, team, hitpoints, cooldown, memory>. The numbers x and y define current robot’s coordinates, the team is the number of robot’s owner team, the hitpoints is the current health of the robot (amoung of damage it can withstand before dying). The cooldown parameter denotes the remaining time to reload weapons. The memory variable contains the robot’s memory state.



Additional model parameters

There is a number of model parameters, which are used to define certain game characteristics:

  • Maximum of robot hitpoints (to kill a robot)
  • Maximum of base hitpoints (to capture a base)
  • Robot construction time (base cooldown)
  • Robot weapon reload time (robot cooldown)
  • Robot view range
  • Robot shooting range
  • Robot transmission range
  • Size of a memory variable (in bytes)
  • Size of messages (in bytes)

 


Functioning of the model

Model functions synchronously cycle by cycle. Each cycle represents time unit of the model time. Each cycle consists of the following sequence of steps:

  1. Processing of bases
  2. Processing of robots’ perception
  3. Transfer of messages
  4. Decision making by robots
  5. Shooting
  6. Damage processing
  7. Movement of robots

More details on each step:

  1. For each non-neutral base that has positive cooldown the value of the cooldown is decremented. Each non-neutral base with zero cooldown and an empty neighbor cell consturcts a robot in an empty cell. The robot constructed has hitpoints set to zero and zero cooldown. The base’s cooldown is set to (robot_construction_time − 1). The cooldown is raised even if no robot was constructed due to absence of empty neighbor cells.
  2. For each robot, the list of robots and bases that are within the view range of the robot is prepared. For each such object the robot receives information, i.e. object’s location and team number.
  3. For each robot, the messages (broadcasts) of other friendly transmitting robots within transmission range are passed to this robot.
  4. Based on the received information and its internal state (memory), each robot decides on the action within current cycle. An action consists of three independent subactions: movement (which direction to move or stay), shooting (yes/no and coordinates of the cell to shoot if “yes”) and transmission (yes/no and limited sequence of bytes if “yes”). 
  5. Damage value of every object in the field is set to zero. Each shoot decision is processed. Only robots with zero cooldown are allowed to shoot. If that is the case, the cooldown is set to (reload_time − 1). If the cell which the robot shoots to is within its shooting range and enemy robot or enemy/neutral base is located in the cell, then the target’s damage is incremented by the number of hits. Shooting friendly bases or robots is not allowed (damage is not incremented).
  6. Damage received by robots and bases is substracted from their hitpoints. If hitpoints value of a robot reaches zero, the robot is destroyed (its cell turns empty). If hitpoints value of a base reaches zero and damage was done solely by single team, then the base ownership is converted to attacker team with hitpoints set to base_health and cooldown set to robot_construction_time. If hitpoints value of a base reaches zero and damage was done by more than one team, then the damage is nullified and changes to the base’s hitpoints value are reverted.
  7. If a robot desires to move to another cell, its coordinates are changed accordingly. The target cell must be empty and no other robots must be willing to move there in the same cycle. If the cell is not empty or more than one robot wishes to move there, then the robots don’t move this cycle.