ANTWAR C++ SDK
Loading...
Searching...
No Matches
template.hpp
Go to the documentation of this file.
1
11#pragma once
12
13#include "control.hpp"
14#include "simulate.hpp"
15
16#include <vector>
17#include <functional>
18
23
24
29static void run_with_ai(AI ai)
30{
31 Controller c;
32 while (true)
33 {
34 if (c.self_player_id == 0) // Game process when you are player 0
35 {
36 // AI makes decisions
38
39 // Add operations to controller
40 for (auto &op : ops)
42
43 // Send operations to judger
45
46 // Apply operations to game state
48
49 // Read opponent operations from judger
51
52 // Apply opponent operations to game state
54
55 // Read round info from judger
57 }
58 else // Game process when you are player 1
59 {
60 // Read opponent operations from judger
62
63 // Apply opponent operations to game state
65
66 // AI makes decisions
68
69 // Add operations to controller
70 for (auto &op : ops)
72
73 // Send operations to judger
75
76 // Apply operations to game state
78
79 // Read round info from judger
81 }
82 }
83}
An integrated module of IO and game state management with simple interfaces for your convenience....
Definition: control.hpp:24
const GameInfo & get_info() const
Get information about current game state.
Definition: control.hpp:120
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 a...
Definition: control.hpp:199
void read_round_info()
Read round information from judger and update current game state.
Definition: control.hpp:146
void apply_opponent_operations()
Apply all the operations in "opponent_operations" to current game state.
Definition: control.hpp:182
const int self_player_id
Your player ID.
Definition: control.hpp:108
void read_opponent_operations()
Read opponent's operations from judger and overwrites "opponent_operations".
Definition: control.hpp:174
void apply_self_operations()
Apply all the operations in "self_operations" to current game state.
Definition: control.hpp:223
void send_self_operations() const
Send all the operations in "self_operations" (i.e. print to stdout)
Definition: control.hpp:235
An integrated module of IO and encapsulated game state management.
An integrated module for game simulation.
A module used for game state management, providing interfaces for accessing and modifying various typ...
Definition: game_info.hpp:28
static void run_with_ai(AI ai)
Run the game with an AI that depends only on player id and game state.
Definition: template.hpp:29