Menu

Command Palette

Search for a command to run...

Cell

Represents a cell in the world.

Overview

The Cell class is a fundamental unit within the world grid, representing individual tiles that agents interact with. Each cell has properties like movement cost, location, whether it contains survivors and the agents on the cell. It also supports advanced features, including layered content and type-specific behaviors such as charging, fire, and killer properties.

Attributes

agent_id_list

AgentIDList

List of agent IDs present in the cell.

move_cost

int

The movement cost associated with the cell.

location

Location

The location of the cell on the map.

has_survivors

bool

If there are survivors in the cell.

Methods

get_top_layer()

Returns the top layer of the cell without removing it.

Returns

WorldObject | None

The top layer of the cell if it exists, or None if the cell has no layers.

Example:

# cell with survivor as top layer with default values
top_layer = cell.get_top_layer()
print(top_layer)
# Output: SV(0, 0, 0, 0)
 
# cell with no top layer 
top_layer = cell.get_top_layer()
print(top_layer)
# Output: None

is_charging_cell()

Determines whether the cell is of type CHARGING_CELL.

Returns

bool

True if the cell is a CHARGING_CELL, otherwise False.

Example:

# The cell is a CHARGING_CELL
print(cell.is_charging_cell())
# Output: True
 
# The cell is not a CHARGING_CELL
print(cell.is_charging_cell())
# Output: False

is_fire_cell()

Determines whether the cell is of type FIRE_CELL.

Returns

bool

True if the cell is a FIRE_CELL, otherwise False.

Example:

# The cell is a FIRE_CELL
print(cell.is_fire_cell())
# Output: True
 
# The cell is not a FIRE_CELL
print(cell.is_fire_cell())
# Output: False

is_killer_cell()

Determines whether the cell is of type KILLER_CELL.

Returns

bool

True if the cell is a KILLER_CELL, otherwise False.

Example:

# The cell is a KILLER_CELL
print(cell.is_killer_cell())
# Output: True
 
# The cell is not a KILLER_CELL
print(cell.is_killer_cell())
# Output: False

is_normal_cell()

Determines whether the cell is of type NORMAL_CELL.

Returns

bool

True if the cell is a NORMAL_CELL, otherwise False.

Example:

# The cell is a NORMAL_CELL
print(cell.is_normal_cell())
# Output: True
 
# The cell is not a NORMAL_CELL
print(cell.is_normal_cell())
# Output: False