An integrated module for simulation with simple interfaces for your convenience. Built from the game state of a Controller instance, a Simulator object allows you to simulate the whole game and "predict" the future for decision making.
More...
#include <simulate.hpp>
An integrated module for simulation with simple interfaces for your convenience. Built from the game state of a Controller instance, a Simulator object allows you to simulate the whole game and "predict" the future for decision making.
◆ Simulator()
Simulator::Simulator |
( |
const GameInfo & |
info | ) |
|
|
inline |
Construct a new Simulator object from a GameInfo instance. Current game state will be copied.
- Parameters
-
info | The GaemInfo instance as data source. |
◆ add_operation_of_player()
bool Simulator::add_operation_of_player |
( |
int |
player_id, |
|
|
Operation |
op |
|
) |
| |
|
inline |
Try adding an operation to "operations[player_id]". The operation has been constructed elsewhere. This function will check validness of the operation and add it to "operations[player_id]" if valid.
- Parameters
-
player_id | The player. |
op | The operation to be added. |
- Returns
- Whether the operation is added successfully.
◆ apply_operations_of_player()
void Simulator::apply_operations_of_player |
( |
int |
player_id | ) |
|
|
inline |
Apply all operations in "operations[player_id]" to current state.
- Parameters
-
◆ attack_ants()
void Simulator::attack_ants |
( |
| ) |
|
|
inlineprivate |
Lightning storms snd towers try attacking ants.
- Note
- A tower may not attack if it has not cooled down (i.e. CD > 0) or if no target is available. Even if it is able to attack, a tower may not cause any damage due to item effects.
-
The state of an ant may be changed. Set AntState::Fail if an ant has negative health points(hp). Set AntState::Frozen if an ant is attacked by a tower of type TowerType::Ice.
- See also
- AntState for more information on the life cycle of an ant.
◆ generate_ants()
void Simulator::generate_ants |
( |
| ) |
|
|
inlineprivate |
Bases try generating new ants.
- Note
- Generation may not happen if it is not the right time (i.e. round % cycle == 0).
◆ get_basic_income()
void Simulator::get_basic_income |
( |
int |
player_id | ) |
|
|
inlineprivate |
Get the basic income for a player and add it to corresponding coins.
- Parameters
-
player_id | The player's ID. |
◆ get_info()
const GameInfo & Simulator::get_info |
( |
| ) |
|
|
inline |
Get information about current game state.
- Returns
- A read-only (constant) reference to the current GameInfo object.
◆ get_operations_of_player()
Get added operations of a player.
- Parameters
-
- Returns
- A read-only (constant) reference to "operations[player_id]".
◆ judge_winner()
Judge winner at MAX_ROUND.
- Returns
- Game result.
- Note
- The function returns GameState::Undecided when both players have the same hp.
◆ move_ants()
Make alive ants move according to pheromone, without modifying pheromone.
- Note
- The state of an ant may be changed. Set AntState::TooOld if an ant reaches age limit. Set AntState::Success if an ant has reached opponent's base, then update the base's health points (hp).
- Returns
- Current game state (running / ended for one side's hp <= 0).
- See also
- AntState for more information on the life cycle of an ant.
◆ next_round()
Update game state at the end of current round. This function is called after both players have applied their operations.
- Returns
- Current game state (running / ended with some reasons).
The documentation for this class was generated from the following file: