HFO.hpp 1.92 KB
Newer Older
1 2 3
#ifndef __HFO_HPP__
#define __HFO_HPP__

4
#include <string>
5
#include <vector>
6
#include "common.hpp"
7

Matthew Hausknecht's avatar
Matthew Hausknecht committed
8 9 10
class Agent;
namespace rcsc { class BasicClient; }

11 12
namespace hfo {

13 14
class HFOEnvironment {
 public:
Matthew Hausknecht's avatar
Matthew Hausknecht committed
15 16
  HFOEnvironment();
  virtual ~HFOEnvironment();
17 18 19 20 21 22 23 24 25 26 27

  /**
   * Connect to the server on the specified port. The
   * following information is provided by the ./bin/HFO
   *
   * feature_set: High or low level state features
   * config_dir: Config directory. Typically HFO/bin/teams/base/config/
   * server_port: port to connect to server on
   * server_addr: address of server
   * team_name: Name of team to join.
   * play_goalie: is this player the goalie
28
   * record_dir: record agent's states/actions/rewards to this directory
29 30 31 32 33 34
   */
  void connectToServer(feature_set_t feature_set=HIGH_LEVEL_FEATURE_SET,
                       std::string config_dir="bin/teams/base/config/formations-dt",
                       int server_port=6000,
                       std::string server_addr="localhost",
                       std::string team_name="base_left",
35 36
                       bool play_goalie=false,
                       std::string record_dir="");
37 38 39 40

  // Get the current state of the domain. Returns a reference to feature_vec.
  const std::vector<float>& getState();

41 42
  // Specify action type to take followed by parameters for that action
  virtual void act(action_t action, ...);
43
  virtual void act(action_t action, const std::vector<float>& params);
44 45 46 47 48

  // Send/receive communication from other agents
  virtual void say(const std::string& message);
  virtual std::string hear();

49 50 51
  // Returns the uniform number of the player
  virtual int getUnum();

52
  // Get the current player holding the ball
53 54
  virtual Player playerOnBall();

55 56
  // Indicates the agent is done and the environment should
  // progress. Returns the game status after the step
57
  virtual status_t step();
58

Matthew Hausknecht's avatar
Matthew Hausknecht committed
59 60 61
 private:
  rcsc::BasicClient* client;
  Agent* agent;
62 63
};

64
} // namespace hfo
65
#endif