Commit b336a23f authored by Matthew Hausknecht's avatar Matthew Hausknecht

Updates for OSX compatibility.

parent b146090a
...@@ -62,6 +62,10 @@ if(INSTALL_ADDITIONAL_TEAMS) ...@@ -62,6 +62,10 @@ if(INSTALL_ADDITIONAL_TEAMS)
endif() endif()
endif() endif()
if(APPLE)
set(CMAKE_SHARED_LIBRARY_SUFFIX ".so")
endif()
set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src) set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin)
include_directories(${SOURCE_DIR} ${SOURCE_DIR}/chain_action) include_directories(${SOURCE_DIR} ${SOURCE_DIR}/chain_action)
......
...@@ -15,7 +15,7 @@ using namespace hfo; ...@@ -15,7 +15,7 @@ using namespace hfo;
feature_set_t features = HIGH_LEVEL_FEATURE_SET; feature_set_t features = HIGH_LEVEL_FEATURE_SET;
string config_dir = "bin/teams/base/config/formations-dt"; string config_dir = "bin/teams/base/config/formations-dt";
int unum = 11; int unum = 11;
int port = 6001; int port = 6000;
string server_addr = "localhost"; string server_addr = "localhost";
string team_name = "base_left"; string team_name = "base_left";
bool goalie = false; bool goalie = false;
...@@ -50,7 +50,7 @@ int main(int argc, char** argv) { ...@@ -50,7 +50,7 @@ int main(int argc, char** argv) {
float y_pos = feature_vec[1]; float y_pos = feature_vec[1];
float target_x = 0; float target_x = 0;
float target_y = unum == 11 ? .3 : -.3; float target_y = unum == 11 ? .3 : -.3;
bool in_position = (pow(x_pos-target_x, 2) + pow(y_pos-target_y,2)) < .0005; bool in_position = (pow(x_pos-target_x, 2) + pow(y_pos-target_y,2)) < .001;
bool able_to_kick = feature_vec[5] > 0; bool able_to_kick = feature_vec[5] > 0;
if (agent_on_ball == unum && in_position && able_to_kick) { if (agent_on_ball == unum && in_position && able_to_kick) {
int teammate_unum = unum == 11 ? 7 : 11; int teammate_unum = unum == 11 ? 7 : 11;
......
...@@ -24,7 +24,8 @@ def main(): ...@@ -24,7 +24,8 @@ def main():
else: else:
hfo.act(MOVE) hfo.act(MOVE)
status = hfo.step() status = hfo.step()
print 'Episode', episode, 'ended with', hfo.statusToString(status) # print 'Episode', episode, 'ended with', hfo.statusToString(status)
print('Episode %d ended with %s'%(episode, hfo.statusToString(status)))
if __name__ == '__main__': if __name__ == '__main__':
main() main()
...@@ -13,7 +13,7 @@ using namespace hfo; ...@@ -13,7 +13,7 @@ using namespace hfo;
feature_set_t features = LOW_LEVEL_FEATURE_SET; feature_set_t features = LOW_LEVEL_FEATURE_SET;
string config_dir = "bin/teams/base/config/formations-dt"; string config_dir = "bin/teams/base/config/formations-dt";
int unum = 11; int unum = 11;
int port = 6001; int port = 6000;
string server_addr = "localhost"; string server_addr = "localhost";
string team_name = "base_left"; string team_name = "base_left";
bool goalie = false; bool goalie = false;
......
...@@ -13,7 +13,7 @@ using namespace hfo; ...@@ -13,7 +13,7 @@ using namespace hfo;
feature_set_t features = HIGH_LEVEL_FEATURE_SET; feature_set_t features = HIGH_LEVEL_FEATURE_SET;
string config_dir = "bin/teams/base/config/formations-dt"; string config_dir = "bin/teams/base/config/formations-dt";
int unum = 11; int unum = 11;
int port = 6001; int port = 6000;
string server_addr = "localhost"; string server_addr = "localhost";
string team_name = "base_left"; string team_name = "base_left";
bool goalie = false; bool goalie = false;
......
...@@ -13,7 +13,7 @@ using namespace hfo; ...@@ -13,7 +13,7 @@ using namespace hfo;
feature_set_t features = LOW_LEVEL_FEATURE_SET; feature_set_t features = LOW_LEVEL_FEATURE_SET;
string config_dir = "bin/teams/base/config/formations-dt"; string config_dir = "bin/teams/base/config/formations-dt";
int unum = 11; int unum = 11;
int port = 6001; int port = 6000;
string server_addr = "localhost"; string server_addr = "localhost";
string team_name = "base_left"; string team_name = "base_left";
bool goalie = false; bool goalie = false;
...@@ -23,7 +23,6 @@ float arg1, arg2; ...@@ -23,7 +23,6 @@ float arg1, arg2;
// Returns a random low-level action // Returns a random low-level action
action_t get_random_low_lv_action() { action_t get_random_low_lv_action() {
action_t action_indx = (action_t) ((rand() % 4) + DASH); action_t action_indx = (action_t) ((rand() % 4) + DASH);
std::cout << action_indx << std::endl;
switch (action_indx) { switch (action_indx) {
case DASH: case DASH:
arg1 = (rand() / float(RAND_MAX)) * 200 - 100; // power: [-100, 100] arg1 = (rand() / float(RAND_MAX)) * 200 - 100; // power: [-100, 100]
...@@ -55,7 +54,7 @@ int main(int argc, char** argv) { ...@@ -55,7 +54,7 @@ int main(int argc, char** argv) {
// manual for more information on feature sets. // manual for more information on feature sets.
hfo.connectToServer(features, config_dir, unum, port, server_addr, hfo.connectToServer(features, config_dir, unum, port, server_addr,
team_name, goalie); team_name, goalie);
for (int episode=0; ; episode++) { for (int episode=0; episode<10; episode++) {
status_t status = IN_GAME; status_t status = IN_GAME;
while (status == IN_GAME) { while (status == IN_GAME) {
// Get the vector of state features for the current state // Get the vector of state features for the current state
...@@ -65,6 +64,8 @@ int main(int argc, char** argv) { ...@@ -65,6 +64,8 @@ int main(int argc, char** argv) {
// Advance the environment and recieve current game status // Advance the environment and recieve current game status
status = hfo.step(); status = hfo.step();
} }
cout << "Episode " << episode << " ended with status: "
<< StatusToString(status) << std::endl;;
} }
hfo.act(QUIT); hfo.act(QUIT);
}; };
...@@ -17,7 +17,7 @@ using namespace hfo; ...@@ -17,7 +17,7 @@ using namespace hfo;
feature_set_t features = HIGH_LEVEL_FEATURE_SET; feature_set_t features = HIGH_LEVEL_FEATURE_SET;
string config_dir = "bin/teams/base/config/formations-dt"; string config_dir = "bin/teams/base/config/formations-dt";
int unum = 11; int unum = 11;
int port = 6001; int port = 6000;
string server_addr = "localhost"; string server_addr = "localhost";
string team_name = "base_left"; string team_name = "base_left";
bool goalie = false; bool goalie = false;
......
...@@ -15,7 +15,7 @@ using namespace hfo; ...@@ -15,7 +15,7 @@ using namespace hfo;
feature_set_t features = HIGH_LEVEL_FEATURE_SET; feature_set_t features = HIGH_LEVEL_FEATURE_SET;
string config_dir = "bin/teams/base/config/formations-dt"; string config_dir = "bin/teams/base/config/formations-dt";
int unum = 11; int unum = 11;
int port = 6001; int port = 6000;
string server_addr = "localhost"; string server_addr = "localhost";
string team_name = "base_left"; string team_name = "base_left";
bool goalie = false; bool goalie = false;
......
...@@ -14,7 +14,7 @@ using namespace hfo; ...@@ -14,7 +14,7 @@ using namespace hfo;
feature_set_t features = HIGH_LEVEL_FEATURE_SET; feature_set_t features = HIGH_LEVEL_FEATURE_SET;
string config_dir = "bin/teams/base/config/formations-dt"; string config_dir = "bin/teams/base/config/formations-dt";
int unum = 11; int unum = 11;
int port = 6001; int port = 6000;
string server_addr = "localhost"; string server_addr = "localhost";
string team_name = "base_left"; string team_name = "base_left";
bool goalie = false; bool goalie = false;
......
#!/bin/bash #!/bin/bash
./bin/HFO --offense-agents=2 --no-sync & ./bin/HFO --offense-agents=2 --no-sync &
sleep 1 sleep 5
./example/communication_agent 7 6000 & ./example/communication_agent 7 6000 &
sleep 1 sleep 5
./example/communication_agent 11 6000 & ./example/communication_agent 11 6000 &
# The magic line # The magic line
......
...@@ -112,8 +112,8 @@ class HFOEnvironment(object): ...@@ -112,8 +112,8 @@ class HFOEnvironment(object):
n_params = hfo_lib.numParams(action_type) n_params = hfo_lib.numParams(action_type)
assert n_params == len(args) - 1, 'Incorrect number of params to act: '\ assert n_params == len(args) - 1, 'Incorrect number of params to act: '\
'Required %d, provided %d'%(n_params, len(args)-1) 'Required %d, provided %d'%(n_params, len(args)-1)
hfo_lib.act(self.obj, action_type, params = np.asarray(args[1:], dtype=np.float32)
as_ctypes(np.asarray(args[1:], dtype=np.float32))) hfo_lib.act(self.obj, action_type, params.ctypes.data_as(POINTER(c_float)))
def say(self, message): def say(self, message):
""" Transmit a message """ """ Transmit a message """
......
...@@ -44,6 +44,7 @@ extern "C" { ...@@ -44,6 +44,7 @@ extern "C" {
return ActionToString(action).c_str(); return ActionToString(action).c_str();
} }
const char* statusToString(const hfo::status_t status) { const char* statusToString(const hfo::status_t status) {
StatusToString(status); // TODO: OSX requires two calls...?!
return StatusToString(status).c_str(); return StatusToString(status).c_str();
} }
} }
......
...@@ -326,7 +326,6 @@ void Agent::actionImpl() { ...@@ -326,7 +326,6 @@ void Agent::actionImpl() {
this->doSmartKick(); this->doSmartKick();
break; break;
case PASS: case PASS:
std::cout << "Inagent pass: 0: " << params[0] << std::endl;
this->doPassTo(int(params[0])); this->doPassTo(int(params[0]));
break; break;
case DRIBBLE: case DRIBBLE:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment