Commit 1e1b36fe authored by sanmit's avatar sanmit

Cleanup and integration with makefile

parent 06d6e35c
...@@ -62,10 +62,10 @@ cmake_install.cmake ...@@ -62,10 +62,10 @@ cmake_install.cmake
CMakeFiles/ CMakeFiles/
# Executeables # Executeables
bin/agent bin/teams/base/agent
bin/sample_coach bin/teams/base/sample_coach
bin/sample_player bin/teams/base/sample_player
bin/sample_trainer bin/teams/base/sample_trainer
bin/rcssserver bin/rcssserver
bin/soccerwindow2 bin/soccerwindow2
example/hfo_example_agent example/hfo_example_agent
...@@ -74,6 +74,7 @@ example/low_level_random_agent ...@@ -74,6 +74,7 @@ example/low_level_random_agent
example/mid_level_move_agent example/mid_level_move_agent
example/mid_level_kick_agent example/mid_level_kick_agent
example/mid_level_dribble_agent example/mid_level_dribble_agent
example/communication_agent
# Dependency directories # Dependency directories
librcsc-prefix/ librcsc-prefix/
......
...@@ -41,7 +41,7 @@ if(BUILD_SOCCERWINDOW) ...@@ -41,7 +41,7 @@ if(BUILD_SOCCERWINDOW)
INSTALL_COMMAND "") INSTALL_COMMAND "")
ExternalProject_Get_Property(soccerwindow2 BINARY_DIR) ExternalProject_Get_Property(soccerwindow2 BINARY_DIR)
set(SOCCERWINDOW2_BINARY_DIR ${BINARY_DIR}/bin) set(SOCCERWINDOW2_BINARY_DIR ${BINARY_DIR}/bin)
install(DIRECTORY ${SOCCERWINDOW2_BINARY_DIR} DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/ USE_SOURCE_PERMISSIONS) install(DIRECTORY ${SOCCERWINDOW2_BINARY_DIR} DESTINATION ${CMAKE_CURRENT_SOURCE_DIR} USE_SOURCE_PERMISSIONS)
endif() endif()
set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src) set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
...@@ -79,9 +79,15 @@ list(APPEND LINK_LIBS rcsc_agent rcsc_geom rcsc_param rcsc_ann ...@@ -79,9 +79,15 @@ list(APPEND LINK_LIBS rcsc_agent rcsc_geom rcsc_param rcsc_ann
add_library(player_chain_action STATIC ${PLAYER_SOURCES} ${CHAIN_ACTION_SOURCES}) add_library(player_chain_action STATIC ${PLAYER_SOURCES} ${CHAIN_ACTION_SOURCES})
add_executable(sample_coach ${SOURCE_DIR}/main_coach.cpp ${SOURCE_DIR}/sample_coach.cpp) add_executable(sample_coach ${SOURCE_DIR}/main_coach.cpp ${SOURCE_DIR}/sample_coach.cpp)
add_executable(sample_player ${SOURCE_DIR}/HFO.cpp ${SOURCE_DIR}/main_player.cpp ${SOURCE_DIR}/sample_player.cpp ${SOURCE_DIR}/agent.cpp) add_executable(sample_player ${SOURCE_DIR}/HFO.cpp ${SOURCE_DIR}/main_player.cpp ${SOURCE_DIR}/sample_player.cpp ${SOURCE_DIR}/agent.cpp)
add_executable(sample_trainer ${SOURCE_DIR}/main_trainer.cpp ${SOURCE_DIR}/sample_trainer.cpp) add_executable(sample_trainer ${SOURCE_DIR}/main_trainer.cpp ${SOURCE_DIR}/sample_trainer.cpp)
add_executable(agent ${SOURCE_DIR}/HFO.cpp ${SOURCE_DIR}/main_agent.cpp ${SOURCE_DIR}/agent.cpp) add_executable(agent ${SOURCE_DIR}/HFO.cpp ${SOURCE_DIR}/main_agent.cpp ${SOURCE_DIR}/agent.cpp)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/teams/base)
set_target_properties(sample_coach PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/teams/base)
set_target_properties(sample_player PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/teams/base)
set_target_properties(sample_trainer PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/teams/base)
set_target_properties(agent PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/teams/base)
add_library(hfo-lib SHARED ${SOURCE_DIR}/HFO.hpp ${SOURCE_DIR}/HFO.cpp) add_library(hfo-lib SHARED ${SOURCE_DIR}/HFO.hpp ${SOURCE_DIR}/HFO.cpp)
set_target_properties(hfo-lib PROPERTIES OUTPUT_NAME hfo) set_target_properties(hfo-lib PROPERTIES OUTPUT_NAME hfo)
set_target_properties(hfo-lib PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib) set_target_properties(hfo-lib PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib)
...@@ -126,8 +132,6 @@ add_executable(communication_agent ${CMAKE_CURRENT_SOURCE_DIR}/example/communica ...@@ -126,8 +132,6 @@ add_executable(communication_agent ${CMAKE_CURRENT_SOURCE_DIR}/example/communica
set_target_properties(communication_agent PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/example) set_target_properties(communication_agent PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/example)
target_link_libraries(communication_agent hfo-lib) target_link_libraries(communication_agent hfo-lib)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/example DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/ USE_SOURCE_PERMISSIONS) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/example DESTINATION ${CMAKE_CURRENT_SOURCE_DIR} USE_SOURCE_PERMISSIONS)
install(DIRECTORY ${RCSSSERVER_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/bin DESTINATION ${CMAKE_CURRENT_SOURCE_DIR} USE_SOURCE_PERMISSIONS)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/teams DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/bin USE_SOURCE_PERMISSIONS)
install(DIRECTORY ${RCSSSERVER_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/bin DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/ USE_SOURCE_PERMISSIONS)
...@@ -52,7 +52,9 @@ class Trainer(object): ...@@ -52,7 +52,9 @@ class Trainer(object):
self.initMsgHandlers() self.initMsgHandlers()
def launch_npc(self, player_num, play_offense, wait_until_join=True): def launch_npc(self, player_num, play_offense, wait_until_join=True):
"""Launches a player using sample_player binary """
OBSOLETE -- Should we delete this method?
Launches a player using sample_player binary
Returns a Popen process object Returns a Popen process object
""" """
...@@ -105,9 +107,9 @@ class Trainer(object): ...@@ -105,9 +107,9 @@ class Trainer(object):
self._agentNumInt.append(internal_player_num) self._agentNumInt.append(internal_player_num)
numTeammates = self._numDefense - 1 numTeammates = self._numDefense - 1
numOpponents = self._numOffense numOpponents = self._numOffense
binary_dir = os.path.dirname(os.path.realpath(__file__)) binary_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'teams', 'base')
config_dir = os.path.join(binary_dir, '../config/formations-dt') config_dir = os.path.join(binary_dir, 'config/formations-dt')
player_conf = os.path.join(binary_dir, '../config/player.conf') player_conf = os.path.join(binary_dir, '/config/player.conf')
agent_cmd = os.path.join(binary_dir, 'agent') agent_cmd = os.path.join(binary_dir, 'agent')
agent_cmd += ' -t %s -p %i --numTeammates %i --numOpponents %i' \ agent_cmd += ' -t %s -p %i --numTeammates %i --numOpponents %i' \
' --playingOffense %i --serverPort %i --log_dir %s' \ ' --playingOffense %i --serverPort %i --log_dir %s' \
...@@ -128,7 +130,9 @@ class Trainer(object): ...@@ -128,7 +130,9 @@ class Trainer(object):
return p return p
def getDefensiveRoster(self, team_name): def getDefensiveRoster(self, team_name):
"""Returns a list of player numbers on a given team that are thought """
OBSOLETE -- Should we delete this method?
Returns a list of player numbers on a given team that are thought
to prefer defense. This map is not set in stone as the players on to prefer defense. This map is not set in stone as the players on
some teams can adapt and change their roles. some teams can adapt and change their roles.
...@@ -141,7 +145,9 @@ class Trainer(object): ...@@ -141,7 +145,9 @@ class Trainer(object):
return [2,3,4,5,6,7,8,11,9,10] return [2,3,4,5,6,7,8,11,9,10]
def getOffensiveRoster(self, team_name): def getOffensiveRoster(self, team_name):
"""Returns a list of player numbers on a given team that are thought """
OBSOLETE -- Should we delete this method?
Returns a list of player numbers on a given team that are thought
to prefer offense. This map is not set in stone as the players on to prefer offense. This map is not set in stone as the players on
some teams can adapt and change their roles. some teams can adapt and change their roles.
......
...@@ -8,8 +8,8 @@ echo " Copyright 2007-2012. Hidehisa Akiyama and Hiroki Shimora" ...@@ -8,8 +8,8 @@ echo " Copyright 2007-2012. Hidehisa Akiyama and Hiroki Shimora"
echo " All rights reserved." echo " All rights reserved."
echo "******************************************************************" echo "******************************************************************"
BINARY_DIR=`dirname $0` BINARY_DIR=`dirname $0`/teams/base
CONFIG_DIR=$BINARY_DIR/../config CONFIG_DIR=$BINARY_DIR/config
player="${BINARY_DIR}/sample_player" player="${BINARY_DIR}/sample_player"
coach="${BINARY_DIR}/sample_coach" coach="${BINARY_DIR}/sample_coach"
......
#!/bin/bash #!/bin/bash
BINARY_DIR=`dirname $0` #"$( cd "$( dirname "$0" )" && pwd )" BINARY_DIR=`dirname $0`/teams/base #"$( cd "$( dirname "$0" )" && pwd )"
CONFIG_DIR=$BINARY_DIR/../config CONFIG_DIR=$BINARY_DIR/config
player="${BINARY_DIR}/agent" player="${BINARY_DIR}/agent"
coach="${BINARY_DIR}/sample_coach" coach="${BINARY_DIR}/sample_coach"
......
...@@ -23,8 +23,14 @@ class Team(object): ...@@ -23,8 +23,14 @@ class Team(object):
self._offense_order = offenseOrder self._offense_order = offenseOrder
self._defense_order = defenseOrder self._defense_order = defenseOrder
def launch_npc(self, player_num):
"""
Abstract method that should be overrided by subclasses. Launches an npc with player number player_num.
The method that overrides this should call start_npc_process. See examples below.
"""
pass
def launch_npc(self, launchOpts=None): def start_npc_proc(self, launchOpts=None):
"""Launches a player using the team-specific binary """Launches a player using the team-specific binary
launchOpts should be used to append player specific options launchOpts should be used to append player specific options
(e.g., helios uses '-g' to signify launching a goalie ) (e.g., helios uses '-g' to signify launching a goalie )
...@@ -61,7 +67,7 @@ class Agent2d(Team): ...@@ -61,7 +67,7 @@ class Agent2d(Team):
if player_num == 1: if player_num == 1:
launchOpts = '-g' launchOpts = '-g'
print 'Launch npc %s-%d' % (self._name, player_num) print 'Launch npc %s-%d' % (self._name, player_num)
return super(Agent2d, self).launch_npc(launchOpts) return self.start_npc_proc(launchOpts)
class Helios(Team): class Helios(Team):
...@@ -78,7 +84,7 @@ class Helios(Team): ...@@ -78,7 +84,7 @@ class Helios(Team):
if player_num == 1: if player_num == 1:
launchOpts = '-g' launchOpts = '-g'
print 'Launch npc %s-%d' % (self._name, player_num) print 'Launch npc %s-%d' % (self._name, player_num)
return super(Helios, self).launch_npc(launchOpts) return self.start_npc_proc(launchOpts)
......
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