ANTWAR C++ SDK
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
Ant Struct Reference

Basic attacking unit. More...

#include <common.hpp>

Collaboration diagram for Ant:
Collaboration graph
[legend]

Public Member Functions

 Ant (int id, int player, int x, int y, int hp, int level, int age, AntState state)
 Construct a new ant with given information.
 
void move (int direction)
 Move the ant in a specified direction.
 
int max_hp () const
 HP limit of this ant.
 
int reward () const
 Reward for killing this ant.
 
bool is_alive () const
 Check if the ant is alive, including states AntState::Alive and AntState::Frozen.
 
bool is_in_range (int x, int y, int range) const
 Check if the ant stays in a circle with given point as the center.
 
bool is_attackable_from (int player, int x, int y, int range) const
 Check if the ant is attackable by a player from given position and range.
 

Public Attributes

int id
 
int player
 
int x
 
int y
 
int hp
 
int level
 
int age
 
AntState state
 
std::vector< int > path
 
int evasion
 
bool deflector
 

Static Public Attributes

static constexpr int AGE_LIMIT = 32
 
static constexpr int MAX_HP_INFO [] = {10, 25, 50}
 
static constexpr int REWARD_INFO [] = {3, 5, 7}
 

Detailed Description

Basic attacking unit.

Member Function Documentation

◆ is_alive()

bool Ant::is_alive ( ) const
inline

Check if the ant is alive, including states AntState::Alive and AntState::Frozen.

Returns
Whether the ant is alive.

◆ is_attackable_from()

bool Ant::is_attackable_from ( int  player,
int  x,
int  y,
int  range 
) const
inline

Check if the ant is attackable by a player from given position and range.

Parameters
xThe x-coordinate of the center point.
yThe y-coordinate of the center point.
rangeThe radius of the
Returns
Whether the ant is attackable.

◆ is_in_range()

bool Ant::is_in_range ( int  x,
int  y,
int  range 
) const
inline

Check if the ant stays in a circle with given point as the center.

Parameters
xThe x-coordinate of the center point.
yThe y-coordinate of the center point.
rangeThe radius of the circle.
Returns
Whether the ant stays in the area.

◆ move()

void Ant::move ( int  direction)
inline

Move the ant in a specified direction.

Parameters
directionIndex of the direction.

The documentation for this struct was generated from the following file: