Knowing the Sensor Array

The sensor array is one of the most important data structures for the AI Agent tracks, as it is the link between the user created agents and the game. The sensor array will give all the necessary information about the game world, such as agent positions, obstacles, platforms and collectibles.

In this section we will explain how the sensors work and what information is captured by them.

The Sensor Array Structure

The sensor array has several types of information structures. However, the amount of such structures to be processed shortens once the game starts (as some of the information is static and is not required to be passed again through the sensors).

The positions of the objects in the structures are relative to their center, like shown in the following picture:

LevelPositions

Users should take note of two key methods in our abstract Agent: the Setup() and SensorsUpdated() methods.

Setup Method Parameters

The setup method is only called once, during the start-up phase of the game and will pass through its parameters all the sensor information.

CountInformation nI -- Number Information Structure

This structure contains the number of obstacles, the number of character specific platforms (Circle & Rectangle Platforms) and the total number of purple diamonds within the level. This information can be directly obtained by accessing the following structure fields:

  • ObstaclesCount -- Number of Obstacles
  • RectanglePlatformsCount -- Number of Rectangle Platforms
  • CirclePlatformsCount -- Number of Circle Platforms
  • CollectiblesCount -- Number of Collectibles

RectangleRepresentation rI -- Rectangle Information Structure

This structure contains the current information on the rectangle agent, such as position (X and Y), velocity (X and Y) and its current height. This information can be directly obtained by accessing the following structure fields:

  • X -- Rectangle Center X Position
  • Y -- Rectangle Center Y Position
  • VelocityX -- Rectangle X Velocity
  • VelocityY -- Rectangle Y Velocity
  • Height -- Rectangle Height

CircleRepresentation cI -- Circle Information Structure

This array contains the current information on the circle agent, such as position (X and Y) and velocity (X and Y). This information can be directly obtained by accessing the following structure fields:

  • X -- Circle Center X Position
  • Y -- Circle Center Y Position
  • VelocityX -- Circle X Velocity
  • VelocityY -- Circle Y Velocity

ObstacleRepresentation[] oI -- Obstacle Information Array

This array contains all the information about the obstacles (default obstacles, not character specific obstacles) in the level, such as the center coordinates of the platform (X and Y) and the platform’s height and width. The information for each ObstacleRepresentation in the array can be directly obtained by accessing the following structure fields:

  • X -- Obstacle Center X Position
  • Y -- Obstacle Center Y Position
  • Height -- Obstacle Height
  • Width -- Obstacle Width

ObstacleRepresentation[] rPI -- Rectangle Platform Information Array

This array contains all the information about Rectangle specific platforms in the level, such as the center coordinates of the platform (X and Y) and the platform’s height and width. The information for each ObstacleRepresentation that represents such a platform in the array can be directly obtained by accessing the following structure fields:

  • X -- Rectangle Platform Center X Position
  • Y -- Rectangle Platform Center Y Position
  • Height -- Rectangle Platform Height
  • Width -- Rectangle Platform Width

ObstacleRepresentation[] cPI -- Circle Platform Information Array

This array contains all the information about Circle specific platforms in the level, such as the center coordinates of the platform (X and Y) and the platform’s height and width. The information for each ObstacleRepresentation that represents such a platform in the array can be directly obtained by accessing the following structure fields:

  • X -- Circle Platform Center X Position
  • Y -- Circle Platform Center Y Position
  • Height -- Circle Platform Height
  • Width -- Circle Platform Width

CollectibleRepresentation[] colI -- Collectibles Information Array

This array contains the information about the coordinates (center X and Y positions) of all the collectibles (purple diamonds) in the level. The information for each CollectibleRepresentation that represents a colletible in the array can be directly obtained by accessing the following structure fields:

  • X -- Collectible Center X Position
  • Y -- Collectible Center Y Position

Rectangle area -- Game Area Information

Specifies the definition of the rectangle area in which the game unfolds.

double timeLimit -- Game Time Limit Information

Specifies the amount of time the agent has to solve the level during the competition.

SensorsUpdated Method Parameters

The SensorsUpdated method is called every few clicks and will accept as its parameters all the sensor information that is not static, such as the number of collectibles , the rectangle and circle agent information and the collectibles’ position information.

int nC -- Number of Collectibles

The current number of collectibles within the level.

RectangleRepresentation rI -- Rectangle Information Structure

This structure contains the current information on the rectangle agent, such as position (X and Y), velocity (X and Y) and its current height. This information can be directly obtained by accessing the following structure fields:

  • X -- Rectangle Center X Position
  • Y -- Rectangle Center Y Position
  • VelocityX -- Rectangle X Velocity
  • VelocityY -- Rectangle Y Velocity
  • Height -- Rectangle Height

CircleRepresentation cI -- Circle Information Structure

This array contains the current information on the circle agent, such as position (X and Y) and velocity (X and Y). This information can be directly obtained by accessing the following structure fields:

  • X -- Circle Center X Position
  • Y -- Circle Center Y Position
  • VelocityX -- Circle X Velocity
  • VelocityY -- Circle Y Velocity

CollectibleRepresentation[] colI -- Collectibles’ Information Array

This array contains the information about the coordinates (center X and Y positions) of all the collectibles (purple diamonds) in the level. The information for each CollectibleRepresentation that represents a colletible in the array can be directly obtained by accessing the following structure fields:

  • X -- Collectible Center X Position
  • Y -- Collectible Center Y Position

Capture Screenshot Tool

In order to not compromise the current sensor array structure, a separate method getScreenshot() was created. This method provides a clean image of the current game state. This tool was created having in mind agents that require pixel information as input in its approaches.

Since giving a Bitmap to the agents every few ticks would affect the game performance, unlike the SensorsUpdate method, this method is not called automatically. The agent has to take the initiative to obtain the screenshot. The method will return a reference to a Bitmap that corresponds to the game screen at the moment the method was called. A second call to this method will erase the previous reference, returning a new one.