Commit 07016ae3 authored by drallensmith's avatar drallensmith

Make hand_coded_defense_agent.cpp more flexible re number of teammates

parent bde41788
#!/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
./bin/HFO --offense-npcs=2 --defense-npcs=2 --trials 5000 --headless --seed=1500348586 --no-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
...@@ -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);
......
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