Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
Seminar-HFO
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
Seminar-HFO
Commits
36fb8fc4
Commit
36fb8fc4
authored
Jul 15, 2017
by
drallensmith
Browse files
Options
Browse Files
Download
Plain Diff
Recording capabilities; avoid rebase
parents
83b22387
63c448e2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
12 deletions
+22
-12
example/high_level_custom_agent.py
example/high_level_custom_agent.py
+20
-10
example/high_level_random_agent.py
example/high_level_random_agent.py
+2
-2
No files found.
example/high_level_custom_agent.py
View file @
36fb8fc4
...
@@ -62,26 +62,36 @@ def main():
...
@@ -62,26 +62,36 @@ def main():
help
=
"Python randomization seed; uses python default if 0 or not given"
)
help
=
"Python randomization seed; uses python default if 0 or not given"
)
parser
.
add_argument
(
'--rand-pass'
,
action
=
"store_true"
,
parser
.
add_argument
(
'--rand-pass'
,
action
=
"store_true"
,
help
=
"Randomize order of checking teammates for a possible pass"
)
help
=
"Randomize order of checking teammates for a possible pass"
)
parser
.
add_argument
(
'--eps'
,
type
=
float
,
default
=
0
,
parser
.
add_argument
(
'--eps
ilon
'
,
type
=
float
,
default
=
0
,
help
=
"Probability of a random action if has the ball, to adjust difficulty"
)
help
=
"Probability of a random action if has the ball, to adjust difficulty"
)
parser
.
add_argument
(
'--record'
,
action
=
'store_true'
,
help
=
"If doing HFO --record"
)
parser
.
add_argument
(
'--rdir'
,
type
=
str
,
default
=
'log/'
,
help
=
"Set directory to use if doing --record"
)
parser
.
add_argument
(
'--numTeammates'
,
type
=
int
,
default
=
0
)
parser
.
add_argument
(
'--numTeammates'
,
type
=
int
,
default
=
0
)
parser
.
add_argument
(
'--numOpponents'
,
type
=
int
,
default
=
1
)
parser
.
add_argument
(
'--numOpponents'
,
type
=
int
,
default
=
1
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
if
args
.
seed
:
if
args
.
seed
:
random
.
seed
(
args
.
seed
)
random
.
seed
(
args
.
seed
)
hfo_env
=
hfo
.
HFOEnvironment
()
hfo_env
=
hfo
.
HFOEnvironment
()
if
args
.
record
:
hfo_env
.
connectToServer
(
hfo
.
HIGH_LEVEL_FEATURE_SET
,
'bin/teams/base/config/formations-dt'
,
args
.
port
,
'localhost'
,
'base_left'
,
False
,
record_dir
=
args
.
rdir
)
else
:
hfo_env
.
connectToServer
(
hfo
.
HIGH_LEVEL_FEATURE_SET
,
hfo_env
.
connectToServer
(
hfo
.
HIGH_LEVEL_FEATURE_SET
,
'bin/teams/base/config/formations-dt'
,
args
.
port
,
'bin/teams/base/config/formations-dt'
,
args
.
port
,
'localhost'
,
'base_left'
,
False
)
'localhost'
,
'base_left'
,
False
)
if
args
.
seed
:
if
args
.
seed
:
if
args
.
rand_pass
or
(
args
.
eps
>
0
):
if
(
args
.
rand_pass
and
(
numTeammates
>
1
))
or
(
args
.
epsilon
>
0
):
print
(
"Python randomization seed: {0:d}"
.
format
(
args
.
seed
))
print
(
"Python randomization seed: {0:d}"
.
format
(
args
.
seed
))
else
:
else
:
print
(
"Python randomization seed
setting is useless without --rand-pass or --eps
>0"
)
print
(
"Python randomization seed
useless without --rand-pass w/teammates or --epsilon
>0"
)
if
args
.
rand_pass
and
(
args
.
numTeammates
>
1
):
if
args
.
rand_pass
and
(
args
.
numTeammates
>
1
):
print
(
"Randomizing order of checking for a pass"
)
print
(
"Randomizing order of checking for a pass"
)
if
args
.
eps
>
0
:
if
args
.
eps
ilon
>
0
:
print
(
"Using eps
(ilon) {0:n}"
.
format
(
args
.
eps
))
print
(
"Using eps
ilon {0:n}"
.
format
(
args
.
epsilon
))
for
episode
in
itertools
.
count
():
for
episode
in
itertools
.
count
():
num_eps
=
0
num_eps
=
0
num_had_ball
=
0
num_had_ball
=
0
...
@@ -91,7 +101,7 @@ def main():
...
@@ -91,7 +101,7 @@ def main():
state
=
hfo_env
.
getState
()
state
=
hfo_env
.
getState
()
#print(state)
#print(state)
if
int
(
state
[
5
])
==
1
:
# state[5] is 1 when player has the ball
if
int
(
state
[
5
])
==
1
:
# state[5] is 1 when player has the ball
if
(
args
.
eps
>
0
)
and
(
random
.
random
()
<
args
.
eps
):
if
(
args
.
eps
ilon
>
0
)
and
(
random
.
random
()
<
args
.
epsilon
):
if
random
.
random
()
<
0.5
:
if
random
.
random
()
<
0.5
:
hfo_env
.
act
(
hfo
.
SHOOT
)
hfo_env
.
act
(
hfo
.
SHOOT
)
else
:
else
:
...
@@ -114,7 +124,7 @@ def main():
...
@@ -114,7 +124,7 @@ def main():
# Check the outcome of the episode
# Check the outcome of the episode
print
(
"Episode {0:d} ended with {1:s}"
.
format
(
episode
,
print
(
"Episode {0:d} ended with {1:s}"
.
format
(
episode
,
hfo_env
.
statusToString
(
status
)))
hfo_env
.
statusToString
(
status
)))
if
args
.
eps
>
0
:
if
args
.
eps
ilon
>
0
:
print
(
"
\t
Num move: {0:d}; Random action: {1:d}; Nonrandom: {2:d}"
.
format
(
num_move
,
print
(
"
\t
Num move: {0:d}; Random action: {1:d}; Nonrandom: {2:d}"
.
format
(
num_move
,
num_eps
,
num_eps
,
(
num_had_ball
-
(
num_had_ball
-
...
...
example/high_level_random_agent.py
View file @
36fb8fc4
...
@@ -22,9 +22,9 @@ def main():
...
@@ -22,9 +22,9 @@ def main():
parser
.
add_argument
(
'--seed'
,
type
=
int
,
default
=
None
,
parser
.
add_argument
(
'--seed'
,
type
=
int
,
default
=
None
,
help
=
"Python randomization seed; uses python default if 0 or not given"
)
help
=
"Python randomization seed; uses python default if 0 or not given"
)
parser
.
add_argument
(
'--record'
,
action
=
'store_true'
,
parser
.
add_argument
(
'--record'
,
action
=
'store_true'
,
help
=
"
D
oing HFO --record"
)
help
=
"
If d
oing HFO --record"
)
parser
.
add_argument
(
'--rdir'
,
type
=
str
,
default
=
'log/'
,
parser
.
add_argument
(
'--rdir'
,
type
=
str
,
default
=
'log/'
,
help
=
"Set directory to use if doing
HFO
--record"
)
help
=
"Set directory to use if doing --record"
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
if
args
.
seed
:
if
args
.
seed
:
random
.
seed
(
args
.
seed
)
random
.
seed
(
args
.
seed
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment