MCPcopy Create free account
hub / github.com/LARG/HFO / main

Function main

example/hfo_example_agent.cpp:10–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8// First Start the server: $> bin/start.py
9
10int main() {
11 // Create the HFO environment
12 HFOEnvironment hfo;
13 // Connect the agent's server on the given port with the given
14 // feature set. See possible feature sets in src/HFO.hpp.
15 hfo.connectToAgentServer(6000, LOW_LEVEL_FEATURE_SET);
16 // Play 5 episodes
17 for (int episode=0; episode<5; episode++) {
18 hfo_status_t status = IN_GAME;
19 while (status == IN_GAME) {
20 // Grab the vector of state features for the current state
21 const std::vector<float>& feature_vec = hfo.getState();
22 // Create a dash action
23 Action a = {DASH, 0., 0.};
24 // Perform the dash and recieve the current game status
25 status = hfo.act(a);
26 }
27 // Check what the outcome of the episode was
28 cout << "Episode " << episode << " ended with status: ";
29 switch (status) {
30 case GOAL:
31 cout << "goal" << endl;
32 break;
33 case CAPTURED_BY_DEFENSE:
34 cout << "captured by defense" << endl;
35 break;
36 case OUT_OF_BOUNDS:
37 cout << "out of bounds" << endl;
38 break;
39 case OUT_OF_TIME:
40 cout << "out of time" << endl;
41 break;
42 default:
43 cout << "Unknown status " << status << endl;
44 exit(1);
45 }
46 }
47};

Callers

nothing calls this directly

Calls 3

getStateMethod · 0.80
connectToAgentServerMethod · 0.45
actMethod · 0.45

Tested by

no test coverage detected