ANTWAR C++ SDK
|
A module used for game state management, providing interfaces for accessing and modifying various types of information such as Entity, Economy, Pheromone, SuperWeapon and Operation. More...
#include <game_info.hpp>
Public Member Functions | |
GameInfo (unsigned long long seed) | |
template<typename T , typename Pred > | |
optional< T > | find_one (const std::vector< T > &v, Pred pred) const |
Find no more than one element in the given vector for which a predicate is true. | |
template<typename T , typename Pred > | |
std::vector< T > | find_all (const std::vector< T > &v, Pred pred) const |
Find all elements in the given vector for which a predicate is true. | |
std::vector< Ant > | all_ants () const |
Get all ants on the map. | |
std::vector< Ant > | ant_at (int x, int y) const |
Find all ants at a specific point. | |
optional< Ant > | ant_of_id (int id) const |
Find the ant of a specific ID. | |
int | ant_of_id_by_index (int id) const |
Find the ant of a specific ID and get its index in vector "ants". | |
std::vector< Tower > | all_towers () const |
Get all towers on the map. | |
optional< Tower > | tower_at (int x, int y) const |
Find the tower at a specific point. | |
optional< Tower > | tower_of_id (int id) const |
Find the tower of a specific ID. | |
void | build_tower (int id, int player, int x, int y, TowerType type=TowerType::Basic) |
Emplace a new tower at the back of vector "towers". | |
void | upgrade_tower (int id, TowerType type) |
Find the tower of a specific ID, then upgrade it. | |
void | downgrade_or_destroy_tower (int id) |
Find the tower of a specific ID and downgrade it if possible. Otherwise, erase it from vector "towers". | |
void | upgrade_generation_speed (int player_id) |
void | upgrade_generated_ant (int player_id) |
void | set_coin (int player_id, int value) |
Set the number of coins for a player. | |
void | update_coin (int player_id, int change) |
Update the number of coins for a player. | |
void | set_base_hp (int player_id, int value) |
Set the hp of base for a player. | |
void | update_base_hp (int player_id, int change) |
Update the hp of base for a player. | |
void | clear_dead_and_succeeded_ants () |
Clear ants of state "Success", "Fail" or "TooOld". | |
void | update_pheromone_for_ants () |
Update pheromone for each ant. | |
void | update_pheromone (const Ant &ant) |
Update pheromone based on the state of an ant. | |
void | global_pheromone_attenuation () |
Global pheromone attenuation. | |
int | tower_num_of_player (int player_id) const |
Count the number of towers of a player. | |
bool | is_operation_valid (int player_id, const Operation &op) const |
Check operation validness. | |
bool | is_operation_valid (int player_id, const std::vector< Operation > &ops, const Operation &new_op) const |
Check whether the newly added operation is valid, considering not only the operation itself, but also the operations added before and the player's coins. | |
int | get_operation_income (int player_id, const Operation &op) const |
Get the income of an operation BEFORE applied. The income could be negative, which means the operation costs money. | |
bool | check_affordable (int player_id, const std::vector< Operation > &ops) const |
Check whether a player can afford a set of operations. | |
void | apply_operation (int player_id, const Operation &op) |
Change buildings, targets and coin values based on the given operation. | |
int | next_move (const Ant &ant) const |
Get next moving direction for an ant based on the probability, randomly. | |
void | use_super_weapon (SuperWeaponType type, int player, int x, int y) |
Handle the operation of using a super weapon. | |
bool | is_shielded_by_emp (int player_id, int x, int y) const |
Check whether a point is shielded by EmpBluster for a player. | |
bool | is_shielded_by_emp (const Tower &tower) const |
Check whether a tower is shielded by EmpBluster. | |
bool | is_shielded_by_deflector (const Ant &a) const |
Check whether an ant is shielded by Deflector for a player. | |
void | count_down_super_weapons_left_time (int player_id) |
Count down left_time of super weapons for a player. Clear it if timeout. | |
void | count_down_super_weapons_cd () |
Count down cd of all types of super weapons. | |
void | show () const |
Print current information to file "info.out". | |
void | dump (std::ofstream &fout) const |
Dump current information with ofstream. | |
void | dump (const char filename[]) const |
Dump current information to file. | |
Static Public Member Functions | |
static int | destroy_tower_income (int tower_num) |
Calculate the income of detroying a tower for a player. | |
static int | downgrade_tower_income (int type) |
Calculate the income of downgrading a tower for a player. | |
static int | build_tower_cost (int tower_num) |
Calculate the cost of building a tower for a player. | |
static int | upgrade_tower_cost (int type) |
Calculate the cost of upgrading a tower. | |
static int | upgrade_base_cost (int level) |
Calculate the cost of upgrading a base's generation speed or level of generated ants. | |
static int | use_super_weapon_cost (int type) |
Calculate the cost of using a super weapon. | |
Public Attributes | |
int | round |
Current round number. | |
std::vector< Tower > | towers |
All towers on the map. | |
std::vector< Ant > | ants |
All ants on the map. | |
Base | bases [2] |
Bases of both sides: "bases[player_id]". | |
int | coins [2] |
Coins of both sides: "coins[player_id]". | |
double | pheromone [2][MAP_SIZE][MAP_SIZE] |
Pheromone of each point on the map: "pheromone[player_id][x][y]". | |
std::vector< SuperWeapon > | super_weapons |
Super weapons being used. | |
int | super_weapon_cd [2][SuperWeaponCount] |
Super weapon cooldown of both sides: "super_weapon_cd[player_id]". | |
int | next_ant_id |
ID of the next generated ant. | |
int | next_tower_id |
ID of the next built tower. | |
A module used for game state management, providing interfaces for accessing and modifying various types of information such as Entity, Economy, Pheromone, SuperWeapon and Operation.
|
inline |
Get all ants on the map.
|
inline |
Get all towers on the map.
|
inline |
Find all ants at a specific point.
x | The x-coordinate of the point. |
y | The y-coordinate of the point. |
|
inline |
Find the ant of a specific ID.
id | The ID of the target ant. |
|
inline |
Find the ant of a specific ID and get its index in vector "ants".
id | The ID of the target ant. |
|
inline |
Change buildings, targets and coin values based on the given operation.
player_id | Whose operation. |
op | The operation to be applied. |
|
inline |
Emplace a new tower at the back of vector "towers".
id | The ID of the new tower. |
player | The player id of the new tower. |
x | The x-coordinate of the new tower. |
y | The y-coordinate of the new tower. |
type | The type of the new tower (default type = TowerType::Basic). |
|
inlinestatic |
Calculate the cost of building a tower for a player.
tower_num | The number of towers (before building) of the player. |
|
inline |
Check whether a player can afford a set of operations.
player_id | The player. |
ops | The operation set. |
|
inlinestatic |
Calculate the income of detroying a tower for a player.
tower_num | The number of barracks (before destroying) of the player. |
|
inline |
Find the tower of a specific ID and downgrade it if possible. Otherwise, erase it from vector "towers".
id | The ID of the tower about to be destroyed. |
|
inlinestatic |
Calculate the income of downgrading a tower for a player.
type | The type of the tower before downgraded. |
|
inline |
Find all elements in the given vector for which a predicate is true.
v | A vector. |
pred | A predicate. |
|
inline |
Find no more than one element in the given vector for which a predicate is true.
v | A vector. |
pred | A predicate. |
|
inline |
Get the income of an operation BEFORE applied. The income could be negative, which means the operation costs money.
player_id | The player. |
op | The operation. |
|
inline |
Check operation validness.
player_id | The player. |
op | The operation. |
|
inline |
Check whether the newly added operation is valid, considering not only the operation itself, but also the operations added before and the player's coins.
player_id | The player. |
ops | Operations already added, with the newly added one at the end. |
|
inline |
Check whether an ant is shielded by Deflector for a player.
|
inline |
Check whether a tower is shielded by EmpBluster.
|
inline |
Check whether a point is shielded by EmpBluster for a player.
|
inline |
Get next moving direction for an ant based on the probability, randomly.
a | The ant. |
|
inline |
Find the tower at a specific point.
x | The x-coordinate of the point. |
y | The y-coordinate of the point. |
|
inline |
Count the number of towers of a player.
player_id | The player. |
|
inline |
Find the tower of a specific ID.
id | The ID of the target tower. |
|
inline |
Update pheromone based on the state of an ant.
ant | The given ant for updating. |
|
inlinestatic |
Calculate the cost of upgrading a base's generation speed or level of generated ants.
level | Level of the base before upgrading. |
|
inline |
Find the tower of a specific ID, then upgrade it.
id | The ID of the tower about to be upgraded. |
type | The target type of upgrading. |
|
inlinestatic |
Calculate the cost of upgrading a tower.
type | The target type of upgrading. |
|
inlinestatic |
Calculate the cost of using a super weapon.
type | The type of super weapon. |