Commit 3191ab74 authored by drallensmith's avatar drallensmith

Merge branch 'randomization' into add_preprocess_action - bring in improvements, avoid rebase

parents ca27922d 9df16499
...@@ -53,7 +53,11 @@ def launch(cmd, name = 'Unknown', necessary = True, suppressOutput = True): ...@@ -53,7 +53,11 @@ def launch(cmd, name = 'Unknown', necessary = True, suppressOutput = True):
def main(args): def main(args):
"""Sets up the teams, launches the server and monitor, starts the trainer. """Sets up the teams, launches the server and monitor, starts the trainer.
""" """
if args.logging and not os.path.exists(args.logDir): if args.logging:
args.hfo_logging = True
if not os.path.exists(args.logDir):
os.makedirs(args.logDir)
elif args.hfo_logging and not os.path.exists(args.logDir):
os.makedirs(args.logDir) os.makedirs(args.logDir)
num_agents = args.offenseAgents + args.defenseAgents num_agents = args.offenseAgents + args.defenseAgents
binary_dir = os.path.dirname(os.path.realpath(__file__)) binary_dir = os.path.dirname(os.path.realpath(__file__))
...@@ -77,7 +81,7 @@ def main(args): ...@@ -77,7 +81,7 @@ def main(args):
'server::say_msg_size=%i ' \ 'server::say_msg_size=%i ' \
'server::record_messages=%i' \ 'server::record_messages=%i' \
%(server_port, coach_port, olcoach_port, %(server_port, coach_port, olcoach_port,
args.logging, args.logging, args.logging, args.logging, args.logging, args.hfo_logging,
args.logDir, args.logDir, args.logDir, args.logDir, args.logDir, args.logDir,
args.sync, args.fullstate, args.fullstate, args.sync, args.fullstate, args.fullstate,
args.maxFramesPerTrial, args.numTrials, args.numFrames, args.maxFramesPerTrial, args.numTrials, args.numFrames,
...@@ -166,6 +170,8 @@ def parseArgs(): ...@@ -166,6 +170,8 @@ def parseArgs():
'incrementally allocated the following ports.') 'incrementally allocated the following ports.')
p.add_argument('--no-logging', dest='logging', action='store_false', p.add_argument('--no-logging', dest='logging', action='store_false',
default=True, help='Disable rcssserver logging.') default=True, help='Disable rcssserver logging.')
p.add_argument('--hfo-logging', dest='hfo_logging', action='store_true', default=False,
help="Do .hfo logging even if no other logging")
p.add_argument('--log-dir', dest='logDir', default='log/', p.add_argument('--log-dir', dest='logDir', default='log/',
help='Directory to store logs. Default: log/') help='Directory to store logs. Default: log/')
p.add_argument('--record', dest='record', action='store_true', p.add_argument('--record', dest='record', action='store_true',
......
#!/bin/bash
./bin/HFO --offense-npcs=2 --defense-npcs=2 --trials 20 --headless &
# The magic line
# $$ holds the PID for this script
# Negation means kill by process group id instead of PID
trap "kill -TERM -$$" SIGINT
wait
#!/bin/bash
# Be sure to change/remove the seed for different experiments!
./bin/HFO --offense-npcs=2 --defense-npcs=2 --trials 5000 --headless --seed=1500348586 --no-logging --hfo-logging &
# The magic line
# $$ holds the PID for this script
# Negation means kill by process group id instead of PID
trap "kill -TERM -$$" SIGINT
wait
#!/bin/bash
# HAS TO BE RUN FROM EXAMPLE DIR DUE TO hand_coded_defense_agent CONFIG!
../bin/HFO --offense-npcs=2 --defense-agents=1 --defense-npcs=2 --trials 20 --headless --port=7000 &
# The below sleep period is needed to avoid the agent connecting in before the
# Trainer.py script gets the base/Helios goalie connected in; if that happens,
# the agent gets assigned unum 1 and there is a mixup in which agent is
# supposed to be the goalie (some portions of the various programs go by unum,
# others go by a goalie flag).
sleep 15
./hand_coded_defense_agent &> agent1.txt &
sleep 5
# The magic line
# $$ holds the PID for this script
# Negation means kill by process group id instead of PID
trap "kill -TERM -$$" SIGINT
wait
\ No newline at end of file
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
# HAS TO BE RUN FROM EXAMPLE DIR DUE TO hand_coded_defense_agent CONFIG! # HAS TO BE RUN FROM EXAMPLE DIR DUE TO hand_coded_defense_agent CONFIG!
../bin/HFO --offense-npcs=2 --defense-agents=1 --defense-npcs=1 --trials 5000 --headless --port=7000 --seed 1500310928 --no-logging & # Change to a new seed for different experiments!
../bin/HFO --offense-npcs=2 --defense-agents=1 --defense-npcs=1 --trials 5000 --headless --port=7000 --seed 1500348586 --no-logging &
sleep 15 sleep 15
./hand_coded_defense_agent &> agent1.txt & ./hand_coded_defense_agent &> agent1.txt &
sleep 5 sleep 5
......
#!/bin/bash #!/bin/bash
./bin/HFO --offense-npcs=2 --defense-agents=1 --defense-npcs=1 --trials 5000 --headless --seed 1500310928 --no-logging & # Change to a different seed for different experiments!
./bin/HFO --offense-npcs=2 --defense-agents=1 --defense-npcs=1 --trials 5000 --headless --seed 1500348586 --no-logging &
sleep 15 sleep 15
./example/hand_coded_defense_agent.py &> agent1.txt & ./example/hand_coded_defense_agent.py &> agent1.txt &
sleep 5 sleep 5
......
...@@ -66,7 +66,7 @@ bool is_in_open_area(double pos_x, double pos_y) { ...@@ -66,7 +66,7 @@ bool is_in_open_area(double pos_x, double pos_y) {
} }
} }
action_with_params get_defense_action(const std::vector<float>& state_vec, double no_of_opponents, double numTMates) { action_with_params get_defense_action(const std::vector<float>& state_vec, double no_of_opponents, int numTMates) {
int size_of_vec = 10 + 6*numTMates + 3*no_of_opponents; int size_of_vec = 10 + 6*numTMates + 3*no_of_opponents;
if (size_of_vec != state_vec.size()) { if (size_of_vec != state_vec.size()) {
std :: cout <<"Invalid Feature Vector / Check the number of teammates/opponents provided"; std :: cout <<"Invalid Feature Vector / Check the number of teammates/opponents provided";
...@@ -221,7 +221,7 @@ int main(int argc, char** argv) { ...@@ -221,7 +221,7 @@ int main(int argc, char** argv) {
// Get the vector of state features for the current state // Get the vector of state features for the current state
const vector<float>& feature_vec = hfo.getState(); const vector<float>& feature_vec = hfo.getState();
if (random == 0) { if (random == 0) {
action_with_params a = get_defense_action(feature_vec, 2,1); action_with_params a = get_defense_action(feature_vec, 2, hfo.getNumTeammates());
// std::cout << a.action << a.param; // std::cout << a.action << a.param;
if (a.action == hfo :: MARK_PLAYER || a.action == hfo::TACKLE) { if (a.action == hfo :: MARK_PLAYER || a.action == hfo::TACKLE) {
hfo.act(a.action, a.param); hfo.act(a.action, a.param);
......
This diff is collapsed.
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