58 if(sw.type != SuperWeaponType::LightningStorm)
63 && ant.player != sw.player)
66 ant.state = AntState::Fail;
86 for (
int idx: targets)
88 if (
info.
ants[idx].state == AntState::Fail)
96 ant.deflector =
false;
116 if (ant.state == AntState::Fail)
119 if (ant.age > Ant::AGE_LIMIT)
120 ant.state = AntState::TooOld;
122 if (ant.state == AntState::Alive)
127 ant.state = AntState::Success;
132 return (ant.player == 0) ? GameState::Player0Win : GameState::Player1Win;
135 if (ant.state == AntState::Frozen)
136 ant.state = AntState::Alive;
138 return GameState::Running;
177 return GameState::Player1Win;
179 return GameState::Player0Win;
181 return GameState::Undecided;
254 if (state != GameState::Running)
274 return GameState::Running;
An integrated module for simulation with simple interfaces for your convenience. Built from the game ...
Definition: simulate.hpp:34
void generate_ants()
Bases try generating new ants.
Definition: simulate.hpp:145
GameState move_ants()
Make alive ants move according to pheromone, without modifying pheromone.
Definition: simulate.hpp:109
GameInfo info
Game state.
Definition: simulate.hpp:36
void apply_operations_of_player(int player_id)
Apply all operations in "operations[player_id]" to current state.
Definition: simulate.hpp:231
GameState next_round()
Update game state at the end of current round. This function is called after both players have applie...
Definition: simulate.hpp:245
const GameInfo & get_info()
Get information about current game state.
Definition: simulate.hpp:195
void attack_ants()
Lightning storms snd towers try attacking ants.
Definition: simulate.hpp:52
Simulator(const GameInfo &info)
Construct a new Simulator object from a GameInfo instance. Current game state will be copied.
Definition: simulate.hpp:189
bool add_operation_of_player(int player_id, Operation op)
Try adding an operation to "operations[player_id]". The operation has been constructed elsewhere....
Definition: simulate.hpp:217
const std::vector< Operation > & get_operations_of_player(int player_id) const
Get added operations of a player.
Definition: simulate.hpp:205
std::vector< Operation > operations[2]
Players' operations which are about to be applied to current game state.
Definition: simulate.hpp:37
void get_basic_income(int player_id)
Get the basic income for a player and add it to corresponding coins.
Definition: simulate.hpp:162
GameState judge_winner() const
Judge winner at MAX_ROUND.
Definition: simulate.hpp:174
constexpr TowerInfo TOWER_INFO[]
Static information of all types of tower.
Definition: common.hpp:352
static constexpr int MAX_ROUND
Max number of rounds.
Definition: common.hpp:22
An integrated module of IO and encapsulated game state management.
A bottom module used for game state management.
GameState
Enumerate values showing whether the game is running, and with detailed reasons if the game ends.
Definition: simulate.hpp:21
@ Player1Win
Game ends when player 1 wins the game.
Definition: simulate.hpp:23
@ Player0Win
Game ends when player 0 wins the game.
Definition: simulate.hpp:22
@ Running
Game is still running.
Definition: simulate.hpp:24
@ Undecided
Game ends due to round limit exceeded. Further checking for the winner is needed.
Definition: simulate.hpp:25
Basic attacking unit.
Definition: common.hpp:230
int reward() const
Reward for killing this ant.
Definition: common.hpp:272
void move(int direction)
Move the ant in a specified direction.
Definition: common.hpp:254
static constexpr int POSITION[2][2]
Positions for both players.
Definition: common.hpp:621
A module used for game state management, providing interfaces for accessing and modifying various typ...
Definition: game_info.hpp:28
int round
Current round number.
Definition: game_info.hpp:29
bool is_shielded_by_emp(int player_id, int x, int y) const
Check whether a point is shielded by EmpBluster for a player.
Definition: game_info.hpp:746
bool is_shielded_by_deflector(const Ant &a) const
Check whether an ant is shielded by Deflector for a player.
Definition: game_info.hpp:766
void update_base_hp(int player_id, int change)
Update the hp of base for a player.
Definition: game_info.hpp:256
void count_down_super_weapons_cd()
Count down cd of all types of super weapons.
Definition: game_info.hpp:798
std::vector< Ant > ants
All ants on the map.
Definition: game_info.hpp:31
int next_ant_id
ID of the next generated ant.
Definition: game_info.hpp:38
void update_pheromone_for_ants()
Update pheromone for each ant.
Definition: game_info.hpp:280
void clear_dead_and_succeeded_ants()
Clear ants of state "Success", "Fail" or "TooOld".
Definition: game_info.hpp:266
std::vector< SuperWeapon > super_weapons
Super weapons being used.
Definition: game_info.hpp:35
void global_pheromone_attenuation()
Global pheromone attenuation.
Definition: game_info.hpp:333
void update_coin(int player_id, int change)
Update the number of coins for a player.
Definition: game_info.hpp:240
bool is_operation_valid(int player_id, const Operation &op) const
Check operation validness.
Definition: game_info.hpp:369
std::vector< Tower > towers
All towers on the map.
Definition: game_info.hpp:30
void apply_operation(int player_id, const Operation &op)
Change buildings, targets and coin values based on the given operation.
Definition: game_info.hpp:545
int next_move(const Ant &ant) const
Get next moving direction for an ant based on the probability, randomly.
Definition: game_info.hpp:581
void count_down_super_weapons_left_time(int player_id)
Count down left_time of super weapons for a player. Clear it if timeout.
Definition: game_info.hpp:776
Base bases[2]
Bases of both sides: "bases[player_id]".
Definition: game_info.hpp:32
Player's operations. It is able to be applied to the map.
Definition: common.hpp:742
Great choice to knockout your opponent.
Definition: common.hpp:694
bool is_in_range(int x, int y) const
Check whether given position is in the range of effect.
Definition: common.hpp:710
Defense unit. Only choice to get yourself armed to the teeth.
Definition: common.hpp:375
std::vector< int > attack(std::vector< Ant > &ants)
Try to attack ants around, and update CD time.
Definition: common.hpp:402