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
bc7a979a
Commit
bc7a979a
authored
Aug 13, 2015
by
UNiQ10
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed cleanup in high level random agent
parent
38b50145
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
8 deletions
+15
-8
example/example_high_level_random_agent.py
example/example_high_level_random_agent.py
+15
-8
No files found.
example/example_high_level_random_agent.py
View file @
bc7a979a
...
...
@@ -12,20 +12,27 @@ except:
def
get_random_action
():
""" Returns a random high-level action """
high_lv_actions
=
[
HFO_Actions
.
MOVE
,
HFO_Actions
.
SHOOT
,
HFO_Actions
.
PASS
,
HFO_Actions
.
DRIBBLE
]
high_lv_actions
=
[
HFO_Actions
.
SHOOT
,
HFO_Actions
.
PASS
,
HFO_Actions
.
DRIBBLE
]
return
(
random
.
choice
(
high_lv_actions
),
0
,
0
)
def
play_hfo
(
num
):
""" Method called by a thread to play 5 games of HFO """
hfo_env
=
hfo
.
HFOEnvironment
()
hfo_env
.
connectToAgentServer
(
6000
+
num
,
HFO_Features
.
HIGH_LEVEL_FEATURE_SET
)
for
episode
in
xrange
(
5
):
status
=
HFO_Status
.
IN_GAME
while
status
==
HFO_Status
.
IN_GAME
:
state
=
hfo_env
.
getState
()
status
=
hfo_env
.
act
(
get_random_action
())
hfo_env
.
cleanup
()
try
:
for
episode
in
xrange
(
5
):
status
=
HFO_Status
.
IN_GAME
while
status
==
HFO_Status
.
IN_GAME
:
state
=
hfo_env
.
getState
()
if
state
[
5
]
==
1
:
#state[5] is 1 when player has the ball
status
=
hfo_env
.
act
(
get_random_action
())
else
:
status
=
hfo_env
.
act
((
HFO_Actions
.
MOVE
,
0
,
0
))
except
:
pass
finally
:
print
"Agent "
+
str
(
num
)
+
" exiting."
hfo_env
.
cleanup
()
def
main
():
parser
=
argparse
.
ArgumentParser
()
...
...
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