An integrated module of IO and game state management with simple interfaces for your convenience. Focus on the information of current game state (e.g. get the probability of an ant's movement) and make your decisions, without caring much about tedious details of IO.
More...
#include <control.hpp>
|
| Controller () |
| Construct a new Controller object. Read initializing information from judger and initialize.
|
|
const GameInfo & | get_info () const |
| Get information about current game state.
|
|
const std::vector< Operation > & | get_self_operations () const |
| Get added operations.
|
|
const std::vector< Operation > & | get_opponent_operations () const |
| Get saved opponent's operations.
|
|
void | read_round_info () |
| Read round information from judger and update current game state.
|
|
void | read_opponent_operations () |
| Read opponent's operations from judger and overwrites "opponent_operations".
|
|
void | apply_opponent_operations () |
| Apply all the operations in "opponent_operations" to current game state.
|
|
bool | append_self_operation (OperationType type, int arg0=-1, int arg1=-1) |
| Try adding an operation to "self_operations". The operation will be constructed with the given type and arguments. This function will check validness of the operation and add it to "self_operations" if valid.
|
|
bool | append_self_operation (Operation op) |
| Try adding an operation to "self_operations". The operation has been constructed elsewhere. This function will check validness of the operation and add it to "self_operations" if valid.
|
|
void | apply_self_operations () |
| Apply all the operations in "self_operations" to current game state.
|
|
void | send_self_operations () const |
| Send all the operations in "self_operations" (i.e. print to stdout)
|
|
|
const int | self_player_id |
| Your player ID.
|
|
|
void | update_towers (std::vector< Tower > &new_towers) |
| Update "info.towers" with vector "new_towers" and reset "info.next_tower_id".
|
|
void | update_ants (const std::vector< Ant > &new_ants) |
| Update "info.ants" with vector "new_ants" and reset "info.next_ant_id".
|
|
void | update_ant (const Ant &a) |
| Update "info.ants" with ant "a".
|
|
void | update_coins (int coin0, int coin1) |
| Update "info.coins".
|
|
void | update_bases_hp (int hp0, int hp1) |
| Update health points (HP) of "info.base[0]" and "info.base[1]".
|
|
| Controller (InitInfo init_info) |
| Construct a new Controller object with given init info.
|
|
An integrated module of IO and game state management with simple interfaces for your convenience. Focus on the information of current game state (e.g. get the probability of an ant's movement) and make your decisions, without caring much about tedious details of IO.
◆ append_self_operation() [1/2]
bool Controller::append_self_operation |
( |
Operation |
op | ) |
|
|
inline |
Try adding an operation to "self_operations". The operation has been constructed elsewhere. This function will check validness of the operation and add it to "self_operations" if valid.
- Parameters
-
op | The operation to be added. |
- Returns
- Whether the operation is added successfully.
◆ append_self_operation() [2/2]
bool Controller::append_self_operation |
( |
OperationType |
type, |
|
|
int |
arg0 = -1 , |
|
|
int |
arg1 = -1 |
|
) |
| |
|
inline |
Try adding an operation to "self_operations". The operation will be constructed with the given type and arguments. This function will check validness of the operation and add it to "self_operations" if valid.
- Parameters
-
type | The type of the operation (see OperationType). |
arg0 | The first argument of the operation. |
arg1 | (optional) The second argument of the operation. |
- Returns
- Whether the operation is added successfully.
◆ get_info()
const GameInfo & Controller::get_info |
( |
| ) |
const |
|
inline |
Get information about current game state.
- Returns
- A read-only (constant) reference to the current GameInfo object.
◆ get_opponent_operations()
Get saved opponent's operations.
- Returns
- A read-only (constant) reference to opponent operations.
◆ get_self_operations()
Get added operations.
- Returns
- A read-only (constant) reference to self operations.
◆ update_ant()
void Controller::update_ant |
( |
const Ant & |
a | ) |
|
|
inlineprivate |
Update "info.ants" with ant "a".
- Parameters
-
a | The given ant for updating. |
Given ant "a", find in vector "ants" if there is an ant "b" having the same ID as "a". If found "b" (which means "a" is not newly generated), then update "b" with "a". If not found "b" (which means "a" is newly generated), then emplace "a" at the back of vector "info.ants".
◆ update_ants()
Update "info.ants" with vector "new_ants" and reset "info.next_ant_id".
- Parameters
-
new_ants | The vector of ants (read from Judger) for updating. |
◆ update_bases_hp()
void Controller::update_bases_hp |
( |
int |
hp0, |
|
|
int |
hp1 |
|
) |
| |
|
inlineprivate |
Update health points (HP) of "info.base[0]" and "info.base[1]".
- Parameters
-
hp0 | The hp of player0's base (read from Judger). |
hp1 | The hp of player1's base (read from Judger). |
- See also
- GameInfo::set_base_hp for details.
◆ update_coins()
void Controller::update_coins |
( |
int |
coin0, |
|
|
int |
coin1 |
|
) |
| |
|
inlineprivate |
Update "info.coins".
- Parameters
-
coin0 | The number of coins of player0 (read from Judger). |
coin1 | The number of coins of player1 (read from Judger). |
- See also
- GameInfo::set_coin for details.
◆ update_towers()
Update "info.towers" with vector "new_towers" and reset "info.next_tower_id".
- Parameters
-
new_towers | The vector of towers (read from Judger) for updating. |
The documentation for this class was generated from the following file: