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
85a0d4aa
You need to sign in or sign up before continuing.
Commit
85a0d4aa
authored
Aug 06, 2017
by
drallensmith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revise feedback with enum, use of ACTION_STATUS_UNKNOWN when appropriate
parent
2be132c1
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
300 additions
and
112 deletions
+300
-112
doc/manual.pdf
doc/manual.pdf
+0
-0
doc/manual.tex
doc/manual.tex
+3
-3
example/explore_offense_actions_fullstate.py
example/explore_offense_actions_fullstate.py
+116
-25
hfo/hfo.py
hfo/hfo.py
+3
-3
src/HFO.cpp
src/HFO.cpp
+1
-1
src/HFO.hpp
src/HFO.hpp
+1
-1
src/agent.cpp
src/agent.cpp
+97
-54
src/agent.h
src/agent.h
+15
-12
src/bhv_basic_move.cpp
src/bhv_basic_move.cpp
+22
-8
src/bhv_basic_move.h
src/bhv_basic_move.h
+3
-1
src/common.hpp
src/common.hpp
+39
-4
No files found.
doc/manual.pdf
View file @
85a0d4aa
No preview for this file type
doc/manual.tex
View file @
85a0d4aa
...
@@ -622,13 +622,13 @@ Team. unum invalid & Y & Y & Y & Y & Y & Y & Y & Y & Y & Y & N &
...
@@ -622,13 +622,13 @@ Team. unum invalid & Y & Y & Y & Y & Y & Y & Y & Y & Y & Y & N &
Opponent loc invalid
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y?
&
Y
&
N
&
Y?
&
Y
&
Y?
&
Y
&
Y
&
Y
&
Y
&
N
\\
Opponent loc invalid
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y?
&
Y
&
N
&
Y?
&
Y
&
Y?
&
Y
&
Y
&
Y
&
Y
&
N
\\
Opp. unum invalid
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
N
\\
Opp. unum invalid
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
N
\\
\hline
\hline
Ball kickable
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
?
&
*
&
Y
&
Y
&
Y
&
Y
&
?
&
?
&
?
&
Y
\\
Ball kickable
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
N
&
*
&
Y
&
Y
&
Y
&
Y
&
?
&
?
&
N
&
Y
\\
Ball not kickable
&
Y
&
Y
&
Y
&
N
&
N
&
Y
&
Y
&
Y
&
Y
&
N
&
N
&
N
&
Y
&
Y
&
Y
&
Y
&
Y
\\
Ball not kickable
&
Y
&
Y
&
Y
&
N
&
N
&
Y
&
Y
&
Y
&
Y
&
N
&
N
&
N
&
Y
&
Y
&
Y
&
Y
&
Y
\\
\hline
\hline
Frozen
&
N
&
N
&
N
&
N
&
N
&
N
&
N?
&
N
&
N?
&
N
&
N
&
Y
&
N?
&
N
&
N
&
N
&
N
\\
Frozen
&
N
&
N
&
N
&
N
&
N
&
N
&
N?
&
N
&
N?
&
N
&
N
&
Y
&
N?
&
N
&
N
&
N
&
N
\\
Colliding w/ball
&
Y
&
Y
&
?
&
?
&
?
&
Y?
&
?
&
?
&
?
&
?
&
?
&
?
&
?
&
?
&
?
&
?
&
?
\\
Colliding w/ball
&
Y
&
Y
&
?
&
N
&
Y
&
Y
&
Y
&
Y
&
?
&
?
&
?
&
?
&
?
&
?
&
?
&
N
&
?
\\
Colliding w/player
&
Y
&
Y?
&
?
&
N?
&
N?
&
Y?
&
?
&
Y?
&
?
&
?
&
?
&
Y?
&
?
&
?
&
?
&
Y?
&
?
\\
Colliding w/player
&
Y
&
Y?
&
?
&
N?
&
N?
&
Y?
&
?
&
Y?
&
?
&
?
&
?
&
Y?
&
?
&
?
&
?
&
Y?
&
?
\\
Colliding w/post
&
Y
&
Y
&
N?
&
N?
&
N?
&
Y
&
?
&
Y
&
?
&
?
&
?
&
?
&
?
&
?
&
?
&
Y
&
?
\\
Colliding w/post
&
Y
&
Y
&
N?
&
N?
&
N?
&
Y
&
Y
&
Y
&
Y
&
?
&
?
&
Y
&
?
&
Y
&
Y
&
Y
&
Y
\\
\hline
\hline
Offense
&
Y
&
Y
&
N
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
N
&
N
&
N
&
Y
&
N
\\
Offense
&
Y
&
Y
&
N
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
Y
&
N
&
N
&
N
&
Y
&
N
\\
Defense, not goalie
&
Y
&
Y
&
Y
&
N?
&
N?
&
Y
&
N
&
Y
&
Y
&
N
&
N
&
N
&
N
&
Y
&
?
&
Y
&
Y
\\
Defense, not goalie
&
Y
&
Y
&
Y
&
N?
&
N?
&
Y
&
N
&
Y
&
Y
&
N
&
N
&
N
&
N
&
Y
&
?
&
Y
&
Y
\\
...
...
example/explore_offense_actions_fullstate.py
View file @
85a0d4aa
...
@@ -284,7 +284,7 @@ def get_abs_x_y_pos(abs_angle, dist, self_x_pos, self_y_pos, warn=True, of_what=
...
@@ -284,7 +284,7 @@ def get_abs_x_y_pos(abs_angle, dist, self_x_pos, self_y_pos, warn=True, of_what=
if
dist
<
10
:
if
dist
<
10
:
raise
RuntimeError
(
"
\n
"
.
join
(
error_strings
))
raise
RuntimeError
(
"
\n
"
.
join
(
error_strings
))
else
:
else
:
if
warn
or
(
dist
<
6
0
):
if
warn
or
(
dist
<
5
0
):
print
(
"
\n
"
.
join
(
error_strings
),
file
=
sys
.
stderr
)
print
(
"
\n
"
.
join
(
error_strings
),
file
=
sys
.
stderr
)
sys
.
stderr
.
flush
()
sys
.
stderr
.
flush
()
return
(
None
,
None
)
return
(
None
,
None
)
...
@@ -641,9 +641,36 @@ def evaluate_previous_action(hfo_env,
...
@@ -641,9 +641,36 @@ def evaluate_previous_action(hfo_env,
action_status_observed
=
hfo
.
ACTION_STATUS_UNKNOWN
# NOTE: Check intent + other bitflags!
action_status_observed
=
hfo
.
ACTION_STATUS_UNKNOWN
# NOTE: Check intent + other bitflags!
if
namespace
.
action
==
hfo
.
DASH
:
if
namespace
.
action
==
hfo
.
DASH
:
pass
# TODO
if
(
namespace
.
intent
!=
INTENT_GOAL_COLLISION
)
and
namespace
.
prestate_bit_list
[
3
]
and
(
not
bit_list
[
3
]):
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
elif
(
namespace
.
intent
!=
INTENT_BALL_COLLISION
)
and
namespace
.
prestate_bit_list
[
2
]
and
(
not
bit_list
[
2
]):
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
elif
(
namespace
.
intent
==
INTENT_BALL_KICKABLE
)
and
(
not
namespace
.
prestate_bit_list
[
4
])
and
bit_list
[
4
]:
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
elif
(
namespace
.
intent
==
INTENT_GOAL_COLLISION
)
and
(
not
namespace
.
prestate_bit_list
[
3
])
and
bit_list
[
3
]:
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
elif
(
namespace
.
intent
==
INTENT_BALL_COLLISION
)
and
(((
not
namespace
.
prestate_bit_list
[
2
])
and
bit_list
[
2
])
or
((
not
namespace
.
prestate_bit_list
[
4
])
and
bit_list
[
4
])):
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
else
:
pass
# TODO
elif
namespace
.
action
==
hfo
.
TURN
:
elif
namespace
.
action
==
hfo
.
TURN
:
if
(
namespace
.
prestate_self_dict
[
'body_angle'
]
is
not
None
)
and
(
self_dict
[
'body_angle'
]
is
not
None
):
if
(
namespace
.
intent
!=
INTENT_GOAL_COLLISION
)
and
namespace
.
prestate_bit_list
[
3
]
and
(
not
bit_list
[
3
]):
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
elif
(
namespace
.
intent
!=
INTENT_BALL_COLLISION
)
and
namespace
.
prestate_bit_list
[
2
]
and
(
not
bit_list
[
2
]):
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
elif
(
namespace
.
intent
==
INTENT_BALL_KICKABLE
)
and
(
not
namespace
.
prestate_bit_list
[
4
])
and
bit_list
[
4
]:
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
elif
(
namespace
.
intent
==
INTENT_GOAL_COLLISION
)
and
(
not
namespace
.
prestate_bit_list
[
3
])
and
bit_list
[
3
]:
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
elif
(
namespace
.
intent
==
INTENT_BALL_COLLISION
)
and
(((
not
namespace
.
prestate_bit_list
[
2
])
and
bit_list
[
2
])
or
((
not
namespace
.
prestate_bit_list
[
4
])
and
bit_list
[
4
])):
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
elif
(
namespace
.
prestate_self_dict
[
'body_angle'
]
is
not
None
)
and
(
self_dict
[
'body_angle'
]
is
not
None
):
intended_body_angle
=
namespace
.
prestate_self_dict
[
'body_angle'
]
+
namespace
.
action_params
[
0
]
intended_body_angle
=
namespace
.
prestate_self_dict
[
'body_angle'
]
+
namespace
.
action_params
[
0
]
if
get_angle_diff
(
namespace
.
prestate_self_dict
[
'body_angle'
],
if
get_angle_diff
(
namespace
.
prestate_self_dict
[
'body_angle'
],
intended_body_angle
)
>
get_angle_diff
(
self_dict
[
'body_angle'
],
intended_body_angle
)
>
get_angle_diff
(
self_dict
[
'body_angle'
],
...
@@ -652,7 +679,15 @@ def evaluate_previous_action(hfo_env,
...
@@ -652,7 +679,15 @@ def evaluate_previous_action(hfo_env,
else
:
else
:
action_status_observed
=
hfo
.
ACTION_STATUS_BAD
action_status_observed
=
hfo
.
ACTION_STATUS_BAD
elif
namespace
.
action
==
hfo
.
KICK
:
elif
namespace
.
action
==
hfo
.
KICK
:
pass
# TODO
if
bit_list
[
4
]:
if
namespace
.
prestate_bit_list
[
2
]
and
(
not
bit_list
[
2
]):
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
elif
namespace
.
prestate_bit_list
[
3
]
and
(
not
bit_list
[
3
]):
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
else
:
action_status_observed
=
hfo
.
ACTION_STATUS_BAD
else
:
pass
# TODO
elif
namespace
.
action
==
hfo
.
KICK_TO
:
elif
namespace
.
action
==
hfo
.
KICK_TO
:
if
(
namespace
.
prestate_ball_dict
[
'x_pos'
]
is
not
None
)
and
(
ball_dict
[
'x_pos'
]
is
not
None
):
if
(
namespace
.
prestate_ball_dict
[
'x_pos'
]
is
not
None
)
and
(
ball_dict
[
'x_pos'
]
is
not
None
):
dist_before
=
get_dist_real
(
namespace
.
prestate_ball_dict
[
'x_pos'
],
dist_before
=
get_dist_real
(
namespace
.
prestate_ball_dict
[
'x_pos'
],
...
@@ -665,10 +700,30 @@ def evaluate_previous_action(hfo_env,
...
@@ -665,10 +700,30 @@ def evaluate_previous_action(hfo_env,
namespace
.
action_params
[
1
])
namespace
.
action_params
[
1
])
if
dist_before
>
dist_after
:
if
dist_before
>
dist_after
:
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
elif
bit_list
[
4
]:
if
namespace
.
prestate_bit_list
[
2
]
and
(
not
bit_list
[
2
]):
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
elif
namespace
.
prestate_bit_list
[
3
]
and
(
not
bit_list
[
3
]):
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
else
:
action_status_observed
=
hfo
.
ACTION_STATUS_BAD
else
:
else
:
action_status_observed
=
hfo
.
ACTION_STATUS_BAD
action_status_observed
=
hfo
.
ACTION_STATUS_BAD
elif
namespace
.
action
==
hfo
.
MOVE_TO
:
elif
namespace
.
action
==
hfo
.
MOVE_TO
:
if
(
namespace
.
prestate_self_dict
[
'x_pos'
]
is
not
None
)
and
(
self_dict
[
'x_pos'
]
is
not
None
):
if
(
namespace
.
intent
!=
INTENT_GOAL_COLLISION
)
and
namespace
.
prestate_bit_list
[
3
]
and
(
not
bit_list
[
3
]):
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
elif
(
namespace
.
intent
!=
INTENT_BALL_COLLISION
)
and
namespace
.
prestate_bit_list
[
2
]
and
(
not
bit_list
[
2
]):
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
elif
(
namespace
.
intent
==
INTENT_BALL_KICKABLE
)
and
(
not
namespace
.
prestate_bit_list
[
4
])
and
bit_list
[
4
]:
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
elif
(
namespace
.
intent
==
INTENT_GOAL_COLLISION
)
and
(
not
namespace
.
prestate_bit_list
[
3
])
and
bit_list
[
3
]:
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
elif
(
namespace
.
intent
==
INTENT_BALL_COLLISION
)
and
(((
not
namespace
.
prestate_bit_list
[
2
])
and
bit_list
[
2
])
or
((
not
namespace
.
prestate_bit_list
[
4
])
and
bit_list
[
4
])):
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
elif
(
namespace
.
prestate_self_dict
[
'x_pos'
]
is
not
None
)
and
(
self_dict
[
'x_pos'
]
is
not
None
):
dist_before
=
get_dist_real
(
namespace
.
prestate_self_dict
[
'x_pos'
],
dist_before
=
get_dist_real
(
namespace
.
prestate_self_dict
[
'x_pos'
],
namespace
.
prestate_self_dict
[
'y_pos'
],
namespace
.
prestate_self_dict
[
'y_pos'
],
namespace
.
action_params
[
0
],
namespace
.
action_params
[
0
],
...
@@ -685,6 +740,10 @@ def evaluate_previous_action(hfo_env,
...
@@ -685,6 +740,10 @@ def evaluate_previous_action(hfo_env,
if
namespace
.
prestate_bit_list
[
4
]:
if
namespace
.
prestate_bit_list
[
4
]:
if
not
bit_list
[
4
]:
if
not
bit_list
[
4
]:
action_status_observed
=
hfo
.
ACTION_STATUS_BAD
action_status_observed
=
hfo
.
ACTION_STATUS_BAD
elif
namespace
.
prestate_bit_list
[
3
]
and
(
not
bit_list
[
3
]):
# goal collision
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
elif
namespace
.
prestate_bit_list
[
2
]
and
(
not
bit_list
[
2
]):
# ball collision
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
elif
(
namespace
.
prestate_self_dict
[
'x_pos'
]
is
not
None
)
and
(
self_dict
[
'x_pos'
]
is
not
None
):
elif
(
namespace
.
prestate_self_dict
[
'x_pos'
]
is
not
None
)
and
(
self_dict
[
'x_pos'
]
is
not
None
):
dist_before
=
get_dist_real
(
namespace
.
prestate_self_dict
[
'x_pos'
],
dist_before
=
get_dist_real
(
namespace
.
prestate_self_dict
[
'x_pos'
],
namespace
.
prestate_self_dict
[
'y_pos'
],
namespace
.
prestate_self_dict
[
'y_pos'
],
...
@@ -700,6 +759,10 @@ def evaluate_previous_action(hfo_env,
...
@@ -700,6 +759,10 @@ def evaluate_previous_action(hfo_env,
action_status_observed
=
hfo
.
ACTION_STATUS_BAD
action_status_observed
=
hfo
.
ACTION_STATUS_BAD
elif
bit_list
[
4
]:
elif
bit_list
[
4
]:
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
elif
namespace
.
prestate_bit_list
[
3
]
and
(
not
bit_list
[
3
]):
# goal collision
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
elif
namespace
.
prestate_bit_list
[
2
]
and
(
not
bit_list
[
2
]):
# ball collision
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
elif
namespace
.
prestate_ball_dict
[
'dist'
]
>
ball_dict
[
'dist'
]:
elif
namespace
.
prestate_ball_dict
[
'dist'
]
>
ball_dict
[
'dist'
]:
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
elif
namespace
.
prestate_ball_dict
[
'dist'
]
<
ball_dict
[
'dist'
]:
elif
namespace
.
prestate_ball_dict
[
'dist'
]
<
ball_dict
[
'dist'
]:
...
@@ -709,11 +772,20 @@ def evaluate_previous_action(hfo_env,
...
@@ -709,11 +772,20 @@ def evaluate_previous_action(hfo_env,
elif
(
namespace
.
action
==
hfo
.
INTERCEPT
)
or
(
namespace
.
action
==
hfo
.
GO_TO_BALL
):
elif
(
namespace
.
action
==
hfo
.
INTERCEPT
)
or
(
namespace
.
action
==
hfo
.
GO_TO_BALL
):
if
namespace
.
prestate_bit_list
[
4
]:
if
namespace
.
prestate_bit_list
[
4
]:
if
bit_list
[
4
]:
if
bit_list
[
4
]:
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
if
(
namespace
.
intent
!=
INTENT_BALL_COLLISION
)
and
bit_list
[
2
]:
action_status_observed
=
hfo
.
ACTION_STATUS_BAD
elif
(
namespace
.
intent
!=
INTENT_GOAL_COLLISION
)
and
bit_list
[
3
]:
action_status_observed
=
hfo
.
ACTION_STATUS_BAD
else
:
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
else
:
else
:
action_status_observed
=
hfo
.
ACTION_STATUS_BAD
action_status_observed
=
hfo
.
ACTION_STATUS_BAD
elif
bit_list
[
4
]:
elif
bit_list
[
4
]:
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
elif
namespace
.
prestate_bit_list
[
3
]
and
(
not
bit_list
[
3
]):
# goal collision
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
elif
(
namespace
.
intent
==
INTENT_BALL_COLLISION
)
and
(
not
namespace
.
prestate_bit_list
[
2
])
and
bit_list
[
2
]:
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
elif
namespace
.
prestate_ball_dict
[
'dist'
]
>
ball_dict
[
'dist'
]:
elif
namespace
.
prestate_ball_dict
[
'dist'
]
>
ball_dict
[
'dist'
]:
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
action_status_observed
=
hfo
.
ACTION_STATUS_MAYBE
elif
namespace
.
prestate_ball_dict
[
'dist'
]
<
ball_dict
[
'dist'
]:
elif
namespace
.
prestate_ball_dict
[
'dist'
]
<
ball_dict
[
'dist'
]:
...
@@ -759,16 +831,18 @@ def evaluate_previous_action(hfo_env,
...
@@ -759,16 +831,18 @@ def evaluate_previous_action(hfo_env,
namespace
.
struct_tried
[
pack_action_bit_list
(
namespace
.
action
,
namespace
.
prestate_bit_list
)]
+=
1
namespace
.
struct_tried
[
pack_action_bit_list
(
namespace
.
action
,
namespace
.
prestate_bit_list
)]
+=
1
# further analysis...
# further analysis...
# further analysis...
if
action_status_guessed
==
hfo
.
ACTION_STATUS_MAYBE
:
if
namespace
.
prestate_bit_list
[
3
]
and
(
namespace
.
action
in
(
hfo
.
DASH
,
hfo
.
MOVE_TO
))
and
(
action_status_guessed
==
hfo
.
ACTION_STATUS_MAYBE
):
# further analysis...
print
(
"OK status from {0!s} despite goal collision in prestate (poststate: {1!s})"
.
format
(
if
namespace
.
prestate_bit_list
[
3
]
and
(
namespace
.
action
in
(
hfo
.
KICK
,
hfo
.
KICK_TO
)):
action_string
,
bit_list
[
3
]))
print
(
"OK status from {0!s} despite goal collision in prestate (poststate: {1!s})"
.
format
(
sys
.
stdout
.
flush
()
action_string
,
bit_list
[
3
]))
sys
.
stdout
.
flush
()
if
namespace
.
prestate_bit_list
[
2
]
and
(
namespace
.
action
in
(
hfo
.
DASH
,
hfo
.
TURN
,
hfo
.
MOVE_TO
))
and
(
action_status_guessed
==
hfo
.
ACTION_STATUS_MAYBE
):
print
(
"OK status from {0!s} despite ball collision in prestate (poststate: {1!s})"
.
format
(
if
namespace
.
prestate_bit_list
[
2
]
and
(
namespace
.
action
in
(
hfo
.
KICK
,
hfo
.
MOVE_TO
,
action_string
,
bit_list
[
2
]))
hfo
.
GO_TO_BALL
)):
sys
.
stdout
.
flush
()
print
(
"OK status from {0!s} despite ball collision in prestate (poststate: {1!s})"
.
format
(
action_string
,
bit_list
[
2
]))
sys
.
stdout
.
flush
()
def
save_action_prestate
(
action
,
def
save_action_prestate
(
action
,
prestate_bit_list
,
prestate_bit_list
,
...
@@ -886,6 +960,8 @@ def do_intent(hfo_env,
...
@@ -886,6 +960,8 @@ def do_intent(hfo_env,
poss_actions_list
.
append
(
hfo
.
TURN
)
poss_actions_list
.
append
(
hfo
.
TURN
)
if
abs
(
ball_rel_angle
)
<
1.0
:
if
abs
(
ball_rel_angle
)
<
1.0
:
poss_actions_list
.
append
(
hfo
.
DASH
)
poss_actions_list
.
append
(
hfo
.
DASH
)
if
bit_list
[
0
]
and
(
ball_dict
[
'x_pos'
]
is
not
None
):
poss_actions_list
.
append
(
hfo
.
MOVE_TO
)
action
=
determine_which_action
(
poss_actions_list
,
namespace
,
bit_list
)
action
=
determine_which_action
(
poss_actions_list
,
namespace
,
bit_list
)
...
@@ -899,6 +975,11 @@ def do_intent(hfo_env,
...
@@ -899,6 +975,11 @@ def do_intent(hfo_env,
hfo_env
.
act
(
*
save_action_prestate
(
action
=
hfo
.
DASH
,
hfo_env
.
act
(
*
save_action_prestate
(
action
=
hfo
.
DASH
,
action_params
=
[
80
,
ball_rel_angle
],
action_params
=
[
80
,
ball_rel_angle
],
**
prestate_dict
))
**
prestate_dict
))
elif
action
==
hfo
.
MOVE_TO
:
hfo_env
.
act
(
*
save_action_prestate
(
action
=
hfo
.
MOVE_TO
,
action_params
=
[
ball_dict
[
'x_pos'
],
ball_dict
[
'y_pos'
]],
**
prestate_dict
))
else
:
else
:
raise
RuntimeError
(
"Unknown action {0!r}"
.
format
(
action
))
raise
RuntimeError
(
"Unknown action {0!r}"
.
format
(
action
))
...
@@ -1023,13 +1104,15 @@ def do_next_action(hfo_env,
...
@@ -1023,13 +1104,15 @@ def do_next_action(hfo_env,
# figure out what to do next
# figure out what to do next
if
not
(
bit_list
[
2
]
or
bit_list
[
3
]
or
bit_list
[
4
]
):
if
not
(
bit_list
[
2
]
or
bit_list
[
3
]):
poss_intent_set
=
set
([
INTENT_BALL_KICKABLE
,
INTENT_BALL_COLLISION
,
INTENT_GOAL_COLLISION
])
poss_intent_set
=
set
([
INTENT_BALL_KICKABLE
,
INTENT_BALL_COLLISION
,
INTENT_GOAL_COLLISION
])
if
not
bit_list
[
5
]:
if
not
bit_list
[
5
]:
poss_intent_set
.
remove
(
INTENT_BALL_KICKABLE
)
poss_intent_set
.
remove
(
INTENT_BALL_KICKABLE
)
poss_intent_set
.
remove
(
INTENT_BALL_COLLISION
)
poss_intent_set
.
remove
(
INTENT_BALL_COLLISION
)
if
not
bit_list
[
0
]:
if
not
bit_list
[
0
]:
poss_intent_set
.
remove
(
INTENT_GOAL_COLLISION
)
poss_intent_set
.
remove
(
INTENT_GOAL_COLLISION
)
if
bit_list
[
4
]:
poss_intent_set
.
remove
(
INTENT_BALL_KICKABLE
)
if
not
poss_intent_set
:
if
not
poss_intent_set
:
raise
NotImplementedError
(
"Not yet set up for self+ball location invalid"
)
raise
NotImplementedError
(
"Not yet set up for self+ball location invalid"
)
...
@@ -1044,14 +1127,22 @@ def do_next_action(hfo_env,
...
@@ -1044,14 +1127,22 @@ def do_next_action(hfo_env,
return
do_intent
(
hfo_env
,
state
,
namespace
)
return
do_intent
(
hfo_env
,
state
,
namespace
)
elif
bit_list
[
4
]:
# kickable
## elif bit_list[4]: # kickable
actions_want_check
=
set
([
hfo
.
INTERCEPT
,
hfo
.
GO_TO_BALL
])
## actions_want_check = set([hfo.INTERCEPT, hfo.GO_TO_BALL])
if
bit_list
[
2
]
or
bit_list
[
3
]:
## if bit_list[2] or bit_list[3]:
actions_want_check
|=
set
([
hfo
.
KICK
,
hfo
.
KICK_TO
])
## actions_want_check |= set([hfo.KICK, hfo.KICK_TO])
else
:
# colliding
elif
bit_list
[
2
]:
# colliding with ball
actions_want_check
=
set
([
hfo
.
DASH
,
hfo
.
TURN
,
hfo
.
KICK
,
hfo
.
KICK_TO
,
actions_want_check
=
set
([
hfo
.
GO_TO_BALL
])
hfo
.
MOVE_TO
,
hfo
.
DRIBBLE_TO
,
hfo
.
INTERCEPT
,
if
bit_list
[
3
]:
# colliding with goal
hfo
.
GO_TO_BALL
])
actions_want_check
|=
set
([
hfo
.
KICK
,
hfo
.
KICK_TO
,
hfo
.
DRIBBLE_TO
])
else
:
# colliding with goal
actions_want_check
=
set
([
hfo
.
KICK
,
hfo
.
KICK_TO
,
hfo
.
DRIBBLE_TO
])
if
prior_intent
is
not
None
:
print
(
"INTENT: WAS {}"
.
format
(
INTENT_DICT
[
prior_intent
]))
else
:
print
(
"INTENT: NONE"
)
sys
.
stdout
.
flush
()
if
bit_list
[
4
]
and
(
prior_intent
not
in
(
None
,
INTENT_BALL_KICKABLE
)):
if
bit_list
[
4
]
and
(
prior_intent
not
in
(
None
,
INTENT_BALL_KICKABLE
)):
namespace
.
intent_done
[
INTENT_BALL_KICKABLE
]
+=
1
namespace
.
intent_done
[
INTENT_BALL_KICKABLE
]
+=
1
...
...
hfo/hfo.py
View file @
85a0d4aa
...
@@ -68,9 +68,6 @@ STATUS_STRINGS = {IN_GAME: "InGame",
...
@@ -68,9 +68,6 @@ STATUS_STRINGS = {IN_GAME: "InGame",
OUT_OF_TIME
:
"OutOfTime"
,
OUT_OF_TIME
:
"OutOfTime"
,
SERVER_DOWN
:
"ServerDown"
}
SERVER_DOWN
:
"ServerDown"
}
"""Possible sides."""
RIGHT
,
NEUTRAL
,
LEFT
=
list
(
range
(
-
1
,
2
))
"""Possible action result statuses."""
"""Possible action result statuses."""
ACTION_STATUS_UNKNOWN
,
ACTION_STATUS_BAD
,
ACTION_STATUS_MAYBE
=
list
(
range
(
-
1
,
2
))
ACTION_STATUS_UNKNOWN
,
ACTION_STATUS_BAD
,
ACTION_STATUS_MAYBE
=
list
(
range
(
-
1
,
2
))
ACTION_STATUS_MAYBE_OK
=
ACTION_STATUS_MAYBE
# typos
ACTION_STATUS_MAYBE_OK
=
ACTION_STATUS_MAYBE
# typos
...
@@ -78,6 +75,9 @@ ACTION_STATUS_STRINGS = {ACTION_STATUS_UNKNOWN: "Unknown",
...
@@ -78,6 +75,9 @@ ACTION_STATUS_STRINGS = {ACTION_STATUS_UNKNOWN: "Unknown",
ACTION_STATUS_BAD
:
"Bad"
,
ACTION_STATUS_BAD
:
"Bad"
,
ACTION_STATUS_MAYBE
:
"MaybeOK"
}
ACTION_STATUS_MAYBE
:
"MaybeOK"
}
"""Possible sides."""
RIGHT
,
NEUTRAL
,
LEFT
=
list
(
range
(
-
1
,
2
))
class
Player
(
Structure
):
pass
class
Player
(
Structure
):
pass
Player
.
_fields_
=
[
Player
.
_fields_
=
[
(
'side'
,
c_int
),
(
'side'
,
c_int
),
...
...
src/HFO.cpp
View file @
85a0d4aa
...
@@ -123,7 +123,7 @@ int HFOEnvironment::getNumOpponents() {
...
@@ -123,7 +123,7 @@ int HFOEnvironment::getNumOpponents() {
return
agent
->
getNumOpponents
();
return
agent
->
getNumOpponents
();
}
}
in
t
HFOEnvironment
::
getLastActionStatus
(
action_t
last_action
)
{
action_status_
t
HFOEnvironment
::
getLastActionStatus
(
action_t
last_action
)
{
return
agent
->
getLastActionStatus
(
last_action
);
return
agent
->
getLastActionStatus
(
last_action
);
}
}
...
...
src/HFO.hpp
View file @
85a0d4aa
...
@@ -55,7 +55,7 @@ class HFOEnvironment {
...
@@ -55,7 +55,7 @@ class HFOEnvironment {
// Returns the number of opponents
// Returns the number of opponents
virtual
int
getNumOpponents
();
virtual
int
getNumOpponents
();
virtual
in
t
getLastActionStatus
(
action_t
last_action
);
virtual
action_status_
t
getLastActionStatus
(
action_t
last_action
);
// Get the current player holding the ball
// Get the current player holding the ball
virtual
Player
playerOnBall
();
virtual
Player
playerOnBall
();
...
...
src/agent.cpp
View file @
85a0d4aa
...
@@ -153,7 +153,7 @@ Agent::Agent()
...
@@ -153,7 +153,7 @@ Agent::Agent()
// setup last_action variables
// setup last_action variables
last_action_with_status
=
NOOP
;
last_action_with_status
=
NOOP
;
last_action_status
=
-
1
;
last_action_status
=
ACTION_STATUS_UNKNOWN
;
}
}
Agent
::~
Agent
()
{
Agent
::~
Agent
()
{
...
@@ -166,20 +166,27 @@ int Agent::getUnum() {
...
@@ -166,20 +166,27 @@ int Agent::getUnum() {
return
world
().
self
().
unum
();
return
world
().
self
().
unum
();
}
}
in
t
Agent
::
getLastActionStatus
(
action_t
last_action
)
{
action_status_
t
Agent
::
getLastActionStatus
(
action_t
last_action
)
{
if
(
last_action
==
last_action_with_status
)
{
if
(
last_action
==
last_action_with_status
)
{
return
last_action_status
;
return
last_action_status
;
}
else
{
}
else
{
return
-
1
;
return
ACTION_STATUS_UNKNOWN
;
}
}
}
}
void
Agent
::
addLastActionStatus
(
action_t
last_action
,
bool
action_status
)
{
void
Agent
::
addLastActionStatus
(
action_t
last_action
,
action_status_t
action_status
)
{
last_action_with_status
=
last_action
;
last_action_with_status
=
last_action
;
if
(
action_status
)
{
last_action_status
=
action_status
;
last_action_status
=
1
;
}
void
Agent
::
addLastActionStatusCollision
(
action_t
last_action
,
bool
may_fix
,
bool
likely_success
)
{
last_action_with_status
=
last_action
;
if
(
likely_success
)
{
last_action_status
=
ACTION_STATUS_MAYBE
;
}
else
if
(
may_fix
)
{
last_action_status
=
ACTION_STATUS_UNKNOWN
;
}
else
{
}
else
{
last_action_status
=
0
;
last_action_status
=
ACTION_STATUS_BAD
;
}
}
}
}
...
@@ -268,42 +275,55 @@ void Agent::actionImpl() {
...
@@ -268,42 +275,55 @@ void Agent::actionImpl() {
<<
" parameters, given "
<<
params
.
size
()
<<
std
::
endl
;
<<
" parameters, given "
<<
params
.
size
()
<<
std
::
endl
;
exit
(
1
);
exit
(
1
);
}
}
// For now let's not worry about turning the neck or setting the vision.
// But do the settings now, so that doesn't override any set by the actions below.
// TODO: Add setViewActionDefault, setNeckActionDefault to librcsc that only set if not already set.
this
->
setViewAction
(
new
View_Tactical
());
this
->
setNeckAction
(
new
Neck_TurnToBallOrScan
());
const
WorldModel
&
wm
=
this
->
world
();
bool
may_fix
=
wm
.
self
().
collidesWithPost
();
switch
(
requested_action
)
{
switch
(
requested_action
)
{
case
DASH
:
case
DASH
:
addLastActionStatus
(
DASH
,
this
->
doDash
(
params
[
0
],
params
[
1
]));
addLastActionStatus
Collision
(
DASH
,
may_fix
,
this
->
doDash
(
params
[
0
],
params
[
1
]));
break
;
break
;
case
TURN
:
case
TURN
:
addLastActionStatus
(
TURN
,
this
->
doTurn
(
params
[
0
]));
addLastActionStatus
Collision
(
TURN
,
may_fix
,
this
->
doTurn
(
params
[
0
]));
break
;
break
;
case
TACKLE
:
case
TACKLE
:
addLastActionStatus
(
TACKLE
,
this
->
doTackle
(
params
[
0
],
false
));
addLastActionStatus
(
TACKLE
,
BooleanToActionStatus
(
this
->
doTackle
(
params
[
0
],
false
)
));
break
;
break
;
case
KICK
:
case
KICK
:
addLastActionStatus
(
KICK
,
this
->
doKick
(
params
[
0
],
params
[
1
]
));
addLastActionStatus
(
KICK
,
BooleanToActionStatus
(
this
->
doKick
(
params
[
0
],
params
[
1
])
));
break
;
break
;
case
KICK_TO
:
case
KICK_TO
:
if
(
feature_extractor
!=
NULL
)
{
if
(
feature_extractor
!=
NULL
)
{
addLastActionStatus
(
KICK_TO
,
Body_SmartKick
(
Vector2D
(
feature_extractor
->
absoluteXPos
(
params
[
0
]),
addLastActionStatus
(
KICK_TO
,
feature_extractor
->
absoluteYPos
(
params
[
1
])),
BooleanToActionStatus
(
Body_SmartKick
(
Vector2D
(
feature_extractor
->
absoluteXPos
(
params
[
0
]),
params
[
2
],
params
[
2
]
*
0.99
,
3
).
execute
(
this
));
feature_extractor
->
absoluteYPos
(
params
[
1
])),
params
[
2
],
params
[
2
]
*
0.99
,
3
).
execute
(
this
)));
}
}
break
;
break
;
case
MOVE_TO
:
case
MOVE_TO
:
if
(
feature_extractor
!=
NULL
)
{
if
(
feature_extractor
!=
NULL
)
{
addLastActionStatus
(
MOVE_TO
,
Body_GoToPoint
(
Vector2D
(
feature_extractor
->
absoluteXPos
(
params
[
0
]),
addLastActionStatusCollision
(
MOVE_TO
,
may_fix
,
feature_extractor
->
absoluteYPos
(
params
[
1
])),
0.25
,
Body_GoToPoint
(
Vector2D
(
feature_extractor
->
absoluteXPos
(
params
[
0
]),
ServerParam
::
i
().
maxDashPower
()).
execute
(
this
));
feature_extractor
->
absoluteYPos
(
params
[
1
])),
0.25
,
ServerParam
::
i
().
maxDashPower
()).
execute
(
this
));
}
}
break
;
break
;
case
DRIBBLE_TO
:
case
DRIBBLE_TO
:
if
(
feature_extractor
!=
NULL
)
{
if
(
feature_extractor
!=
NULL
)
{
addLastActionStatus
(
DRIBBLE_TO
,
Body_Dribble
(
Vector2D
(
feature_extractor
->
absoluteXPos
(
params
[
0
]),
addLastActionStatusCollision
(
DRIBBLE_TO
,
may_fix
,
feature_extractor
->
absoluteYPos
(
params
[
1
])),
1.0
,
Body_Dribble
(
Vector2D
(
feature_extractor
->
absoluteXPos
(
params
[
0
]),
ServerParam
::
i
().
maxDashPower
(),
2
).
execute
(
this
));
feature_extractor
->
absoluteYPos
(
params
[
1
])),
1.0
,
ServerParam
::
i
().
maxDashPower
(),
2
).
execute
(
this
));
}
}
break
;
break
;
case
INTERCEPT
:
case
INTERCEPT
:
addLastActionStatus
(
INTERCEPT
,
Body_Intercept
().
execute
(
this
));
addLastActionStatus
Collision
(
INTERCEPT
,
may_fix
,
Body_Intercept
().
execute
(
this
));
break
;
break
;
case
MOVE
:
case
MOVE
:
addLastActionStatus
(
MOVE
,
this
->
doMove
());
addLastActionStatus
(
MOVE
,
this
->
doMove
());
...
@@ -318,7 +338,7 @@ void Agent::actionImpl() {
...
@@ -318,7 +338,7 @@ void Agent::actionImpl() {
addLastActionStatus
(
DRIBBLE
,
this
->
doDribble
());
addLastActionStatus
(
DRIBBLE
,
this
->
doDribble
());
break
;
break
;
case
CATCH
:
case
CATCH
:
addLastActionStatus
(
CATCH
,
this
->
doCatch
(
));
addLastActionStatus
(
CATCH
,
BooleanToActionStatus
(
this
->
doCatch
()
));
break
;
break
;
case
NOOP
:
case
NOOP
:
break
;
break
;
...
@@ -343,9 +363,7 @@ void Agent::actionImpl() {
...
@@ -343,9 +363,7 @@ void Agent::actionImpl() {
<<
requested_action
<<
std
::
endl
;
<<
requested_action
<<
std
::
endl
;
exit
(
1
);
exit
(
1
);
}
}
// For now let's not worry about turning the neck or setting the vision.
this
->
setViewAction
(
new
View_Tactical
());
this
->
setNeckAction
(
new
Neck_TurnToBallOrScan
());
}
}
void
void
...
@@ -723,7 +741,7 @@ Agent::doPreprocess()
...
@@ -723,7 +741,7 @@ Agent::doPreprocess()
/*!
/*!
*/
*/
bool
action_status_t
Agent
::
doShoot
()
Agent
::
doShoot
()
{
{
const
WorldModel
&
wm
=
this
->
world
();
const
WorldModel
&
wm
=
this
->
world
();
...
@@ -738,21 +756,23 @@ Agent::doShoot()
...
@@ -738,21 +756,23 @@ Agent::doShoot()
// reset intention
// reset intention
this
->
setIntention
(
static_cast
<
SoccerIntention
*
>
(
0
)
);
this
->
setIntention
(
static_cast
<
SoccerIntention
*
>
(
0
)
);
return
true
;
return
ACTION_STATUS_MAYBE
;
}
}
return
false
;
return
ACTION_STATUS_BAD
;
}
}
bool
action_status_t
Agent
::
doSmartKick
()
Agent
::
doSmartKick
()
{
{
const
ShootGenerator
::
Container
&
cont
=
const
ShootGenerator
::
Container
&
cont
=
ShootGenerator
::
instance
().
courses
(
this
->
world
(),
false
);
ShootGenerator
::
instance
().
courses
(
this
->
world
(),
false
);
ShootGenerator
::
Container
::
const_iterator
best_shoot
ShootGenerator
::
Container
::
const_iterator
best_shoot
=
std
::
min_element
(
cont
.
begin
(),
cont
.
end
(),
ShootGenerator
::
ScoreCmp
());
=
std
::
min_element
(
cont
.
begin
(),
cont
.
end
(),
ShootGenerator
::
ScoreCmp
());
return
Body_SmartKick
(
best_shoot
->
target_point_
,
best_shoot
->
first_ball_speed_
,
return
BooleanToActionStatus
(
Body_SmartKick
(
best_shoot
->
target_point_
,
best_shoot
->
first_ball_speed_
*
0.99
,
3
).
execute
(
this
);
best_shoot
->
first_ball_speed_
,
best_shoot
->
first_ball_speed_
*
0.99
,
3
).
execute
(
this
));
}
}
...
@@ -769,19 +789,19 @@ Agent::doPass()
...
@@ -769,19 +789,19 @@ Agent::doPass()
return
true
;
return
true
;
}
}
bool
action_status_t
Agent
::
doPassTo
(
int
receiver
)
Agent
::
doPassTo
(
int
receiver
)
{
{
Force_Pass
pass
;
Force_Pass
pass
;
pass
.
get_pass_to_player
(
this
->
world
(),
receiver
);
pass
.
get_pass_to_player
(
this
->
world
(),
receiver
);
return
pass
.
execute
(
this
);
return
BooleanToActionStatus
(
pass
.
execute
(
this
)
);
}
}
/*-------------------------------------------------------------------*/
/*-------------------------------------------------------------------*/
/*!
/*!
*/
*/
bool
action_status_t
Agent
::
doDribble
()
Agent
::
doDribble
()
{
{
bool
success
=
false
;
bool
success
=
false
;
...
@@ -795,9 +815,9 @@ Agent::doDribble()
...
@@ -795,9 +815,9 @@ Agent::doDribble()
success
=
doPreprocess
();
success
=
doPreprocess
();
ActionChainHolder
::
instance
().
update
(
world
()
);
ActionChainHolder
::
instance
().
update
(
world
()
);
if
(
Bhv_ChainAction
(
ActionChainHolder
::
instance
().
graph
()).
execute
(
this
))
{
if
(
Bhv_ChainAction
(
ActionChainHolder
::
instance
().
graph
()).
execute
(
this
))
{
return
true
;
return
ACTION_STATUS_MAYBE
;
}
else
{
}
else
{
return
success
;
return
BooleanToActionStatus
(
success
)
;
}
}
}
}
...
@@ -805,19 +825,19 @@ Agent::doDribble()
...
@@ -805,19 +825,19 @@ Agent::doDribble()
/*!
/*!
*/
*/
bool
action_status_t
Agent
::
doMove
()
Agent
::
doMove
()
{
{
Strategy
::
instance
().
update
(
world
()
);
Strategy
::
instance
().
update
(
world
()
);
int
role_num
=
Strategy
::
i
().
roleNumber
(
world
().
self
().
unum
());
int
role_num
=
Strategy
::
i
().
roleNumber
(
world
().
self
().
unum
());
// Unused?
return
Bhv_BasicMove
().
execute
(
this
);
return
Bhv_BasicMove
().
action_
execute
(
this
);
}
}
/*-------------------------------------------------------------------*/
/*-------------------------------------------------------------------*/
/*!
/*!
* This Action marks the player with the specified uniform number.
* This Action marks the player with the specified uniform number.
*/
*/
bool
Agent
::
doMarkPlayer
(
int
unum
)
{
action_status_t
Agent
::
doMarkPlayer
(
int
unum
)
{
const
WorldModel
&
wm
=
this
->
world
();
const
WorldModel
&
wm
=
this
->
world
();
Vector2D
kicker_pos
=
Vector2D
::
INVALIDATED
;
Vector2D
kicker_pos
=
Vector2D
::
INVALIDATED
;
Vector2D
player_pos
=
Vector2D
::
INVALIDATED
;
Vector2D
player_pos
=
Vector2D
::
INVALIDATED
;
...
@@ -841,19 +861,27 @@ bool Agent::doMarkPlayer(int unum) {
...
@@ -841,19 +861,27 @@ bool Agent::doMarkPlayer(int unum) {
if
(
!
player_pos
.
isValid
())
{
if
(
!
player_pos
.
isValid
())
{
//Player to be marked not found
//Player to be marked not found
return
false
;
return
ACTION_STATUS_BAD
;
}
}
if
(
!
kicker_pos
.
isValid
())
{
if
(
!
kicker_pos
.
isValid
())
{
//Kicker not found
//Kicker not found
return
false
;
return
ACTION_STATUS_BAD
;
}
}
if
(
unum
==
kicker_unum
||
kicker_pos
.
equals
(
player_pos
))
{
if
(
unum
==
kicker_unum
||
kicker_pos
.
equals
(
player_pos
))
{
//Player to be marked is kicker
//Player to be marked is kicker
return
false
;
return
ACTION_STATUS_BAD
;
}
}
double
x
=
player_pos
.
x
+
(
kicker_pos
.
x
-
player_pos
.
x
)
*
0.1
;
double
x
=
player_pos
.
x
+
(
kicker_pos
.
x
-
player_pos
.
x
)
*
0.1
;
double
y
=
player_pos
.
y
+
(
kicker_pos
.
y
-
player_pos
.
y
)
*
0.1
;
double
y
=
player_pos
.
y
+
(
kicker_pos
.
y
-
player_pos
.
y
)
*
0.1
;
return
Body_GoToPoint
(
Vector2D
(
x
,
y
),
0.25
,
ServerParam
::
i
().
maxDashPower
()).
execute
(
this
);
bool
may_fix
=
wm
.
self
().
collidesWithPost
();
if
(
Body_GoToPoint
(
Vector2D
(
x
,
y
),
0.25
,
ServerParam
::
i
().
maxDashPower
()).
execute
(
this
))
{
return
ACTION_STATUS_MAYBE
;
}
else
if
(
may_fix
)
{
return
ACTION_STATUS_UNKNOWN
;
}
else
{
return
ACTION_STATUS_BAD
;
}
}
}
/*-------------------------------------------------------------------*/
/*-------------------------------------------------------------------*/
...
@@ -867,7 +895,7 @@ bool compare_y_pos (PlayerObject* i, PlayerObject* j) {
...
@@ -867,7 +895,7 @@ bool compare_y_pos (PlayerObject* i, PlayerObject* j) {
return
i
->
pos
().
y
<
j
->
pos
().
y
;
return
i
->
pos
().
y
<
j
->
pos
().
y
;
}
}
bool
Agent
::
doReduceAngleToGoal
()
{
action_status_t
Agent
::
doReduceAngleToGoal
()
{
const
WorldModel
&
wm
=
this
->
world
();
const
WorldModel
&
wm
=
this
->
world
();
Vector2D
goal_pos1
(
-
ServerParam
::
i
().
pitchHalfLength
(),
ServerParam
::
i
().
goalHalfWidth
()
);
Vector2D
goal_pos1
(
-
ServerParam
::
i
().
pitchHalfLength
(),
ServerParam
::
i
().
goalHalfWidth
()
);
Vector2D
goal_pos2
(
-
ServerParam
::
i
().
pitchHalfLength
(),
-
ServerParam
::
i
().
goalHalfWidth
()
);
Vector2D
goal_pos2
(
-
ServerParam
::
i
().
pitchHalfLength
(),
-
ServerParam
::
i
().
goalHalfWidth
()
);
...
@@ -876,7 +904,7 @@ bool Agent::doReduceAngleToGoal() {
...
@@ -876,7 +904,7 @@ bool Agent::doReduceAngleToGoal() {
const
BallObject
&
ball
=
wm
.
ball
();
const
BallObject
&
ball
=
wm
.
ball
();
if
(
!
ball
.
rposValid
())
{
if
(
!
ball
.
rposValid
())
{
return
false
;
return
ACTION_STATUS_BAD
;
}
}
Vector2D
ball_pos
=
ball
.
pos
();
Vector2D
ball_pos
=
ball
.
pos
();
...
@@ -945,23 +973,30 @@ bool Agent::doReduceAngleToGoal() {
...
@@ -945,23 +973,30 @@ bool Agent::doReduceAngleToGoal() {
double
dist_to_end2
=
targetLineEnd2
.
dist2
(
ball_pos
);
double
dist_to_end2
=
targetLineEnd2
.
dist2
(
ball_pos
);
double
ratio
=
dist_to_end2
/
(
dist_to_end1
+
dist_to_end2
);
double
ratio
=
dist_to_end2
/
(
dist_to_end1
+
dist_to_end2
);
Vector2D
target
=
targetLineEnd1
*
ratio
+
targetLineEnd2
*
(
1
-
ratio
);
Vector2D
target
=
targetLineEnd1
*
ratio
+
targetLineEnd2
*
(
1
-
ratio
);
return
Body_GoToPoint
(
target
,
0.25
,
ServerParam
::
i
().
maxDashPower
()).
execute
(
this
);
bool
may_fix
=
wm
.
self
().
collidesWithPost
();
if
(
Body_GoToPoint
(
target
,
0.25
,
ServerParam
::
i
().
maxDashPower
()).
execute
(
this
))
{
return
ACTION_STATUS_MAYBE
;
}
else
if
(
may_fix
)
{
return
ACTION_STATUS_UNKNOWN
;
}
else
{
return
ACTION_STATUS_BAD
;
}
}
}
/*-------------------------------------------------------------------*/
/*-------------------------------------------------------------------*/
/*!
/*!
*
*
* This action cuts off the angle between the shooter and the goal
the players
always moves on a fixed line.
* This action cuts off the angle between the shooter and the goal
; the player
always moves on a fixed line.
*/
*/
bool
Agent
::
doDefendGoal
()
{
action_status_t
Agent
::
doDefendGoal
()
{
const
WorldModel
&
wm
=
this
->
world
();
const
WorldModel
&
wm
=
this
->
world
();
Vector2D
goal_pos1
(
-
ServerParam
::
i
().
pitchHalfLength
()
+
ServerParam
::
i
().
goalAreaLength
(),
ServerParam
::
i
().
goalHalfWidth
()
);
Vector2D
goal_pos1
(
-
ServerParam
::
i
().
pitchHalfLength
()
+
ServerParam
::
i
().
goalAreaLength
(),
ServerParam
::
i
().
goalHalfWidth
()
);
Vector2D
goal_pos2
(
-
ServerParam
::
i
().
pitchHalfLength
()
+
ServerParam
::
i
().
goalAreaLength
(),
-
ServerParam
::
i
().
goalHalfWidth
()
);
Vector2D
goal_pos2
(
-
ServerParam
::
i
().
pitchHalfLength
()
+
ServerParam
::
i
().
goalAreaLength
(),
-
ServerParam
::
i
().
goalHalfWidth
()
);
const
BallObject
&
ball
=
wm
.
ball
();
const
BallObject
&
ball
=
wm
.
ball
();
if
(
!
ball
.
rposValid
())
{
if
(
!
ball
.
rposValid
())
{
return
false
;
return
ACTION_STATUS_BAD
;
}
}
Vector2D
ball_pos
=
ball
.
pos
();
Vector2D
ball_pos
=
ball
.
pos
();
...
@@ -969,7 +1004,15 @@ bool Agent::doDefendGoal() {
...
@@ -969,7 +1004,15 @@ bool Agent::doDefendGoal() {
double
dist_to_post2
=
goal_pos2
.
dist2
(
ball_pos
);
double
dist_to_post2
=
goal_pos2
.
dist2
(
ball_pos
);
double
ratio
=
dist_to_post2
/
(
dist_to_post1
+
dist_to_post2
);
double
ratio
=
dist_to_post2
/
(
dist_to_post1
+
dist_to_post2
);
Vector2D
target
=
goal_pos1
*
ratio
+
goal_pos2
*
(
1
-
ratio
);
Vector2D
target
=
goal_pos1
*
ratio
+
goal_pos2
*
(
1
-
ratio
);
return
Body_GoToPoint
(
target
,
0.25
,
ServerParam
::
i
().
maxDashPower
()).
execute
(
this
);
bool
may_fix
=
wm
.
self
().
collidesWithPost
();
if
(
Body_GoToPoint
(
target
,
0.25
,
ServerParam
::
i
().
maxDashPower
()).
execute
(
this
))
{
return
ACTION_STATUS_MAYBE
;
}
else
if
(
may_fix
)
{
return
ACTION_STATUS_UNKNOWN
;
}
else
{
return
ACTION_STATUS_BAD
;
}
}
}
/*-------------------------------------------------------------------*/
/*-------------------------------------------------------------------*/
...
@@ -980,13 +1023,13 @@ bool Agent::doDefendGoal() {
...
@@ -980,13 +1023,13 @@ bool Agent::doDefendGoal() {
*/
*/
bool
Agent
::
doGoToBall
()
{
action_status_t
Agent
::
doGoToBall
()
{
const
WorldModel
&
wm
=
this
->
world
();
const
WorldModel
&
wm
=
this
->
world
();
const
BallObject
&
ball
=
wm
.
ball
();
const
BallObject
&
ball
=
wm
.
ball
();
if
(
!
ball
.
rposValid
())
{
if
(
!
ball
.
rposValid
())
{
return
false
;
return
ACTION_STATUS_BAD
;
}
}
return
Bo
dy_GoToPoint
(
ball
.
pos
(),
0.25
,
ServerParam
::
i
().
maxDashPower
()).
execute
(
this
);
return
Bo
oleanToActionStatus
(
Body_GoToPoint
(
ball
.
pos
(),
0.25
,
ServerParam
::
i
().
maxDashPower
()).
execute
(
this
)
);
}
}
/*-------------------------------------------------------------------*/
/*-------------------------------------------------------------------*/
...
...
src/agent.h
View file @
85a0d4aa
// -*-c++-*-
#ifndef AGENT_H
#ifndef AGENT_H
#define AGENT_H
#define AGENT_H
...
@@ -64,7 +66,7 @@ protected:
...
@@ -64,7 +66,7 @@ protected:
int
num_teammates
;
// Number of teammates
int
num_teammates
;
// Number of teammates
int
num_opponents
;
// Number of opponents
int
num_opponents
;
// Number of opponents
hfo
::
action_t
last_action_with_status
;
// Last action with a recorded return status
hfo
::
action_t
last_action_with_status
;
// Last action with a recorded return status
int
last_action_status
;
// Recorded return status of last action (1 = true, 0 = false, -1 = not available)
hfo
::
action_status_t
last_action_status
;
// Recorded return status of last action
public:
public:
inline
const
std
::
vector
<
float
>&
getState
()
{
return
state
;
}
inline
const
std
::
vector
<
float
>&
getState
()
{
return
state
;
}
...
@@ -74,7 +76,7 @@ protected:
...
@@ -74,7 +76,7 @@ protected:
int
getUnum
();
// Returns the uniform number of the player
int
getUnum
();
// Returns the uniform number of the player
inline
int
getNumTeammates
()
{
return
num_teammates
;
}
inline
int
getNumTeammates
()
{
return
num_teammates
;
}
inline
int
getNumOpponents
()
{
return
num_opponents
;
}
inline
int
getNumOpponents
()
{
return
num_opponents
;
}
in
t
getLastActionStatus
(
hfo
::
action_t
last_action
);
// if last_action is correct, returns status if available
hfo
::
action_status_
t
getLastActionStatus
(
hfo
::
action_t
last_action
);
// if last_action is correct, returns status if available
inline
void
setFeatureSet
(
hfo
::
feature_set_t
fset
)
{
feature_set
=
fset
;
}
inline
void
setFeatureSet
(
hfo
::
feature_set_t
fset
)
{
feature_set
=
fset
;
}
inline
std
::
vector
<
float
>*
mutable_params
()
{
return
&
params
;
}
inline
std
::
vector
<
float
>*
mutable_params
()
{
return
&
params
;
}
...
@@ -83,21 +85,22 @@ protected:
...
@@ -83,21 +85,22 @@ protected:
private:
private:
bool
doPreprocess
();
bool
doPreprocess
();
bool
doSmartKick
();
hfo
::
action_status_t
doSmartKick
();
bool
doShoot
();
hfo
::
action_status_t
doShoot
();
bool
doPass
();
bool
doPass
();
bool
doPassTo
(
int
receiver
);
hfo
::
action_status_t
doPassTo
(
int
receiver
);
bool
doDribble
();
hfo
::
action_status_t
doDribble
();
bool
doMove
();
hfo
::
action_status_t
doMove
();
bool
doForceKick
();
bool
doForceKick
();
bool
doHeardPassReceive
();
bool
doHeardPassReceive
();
bool
doMarkPlayer
(
int
unum
);
hfo
::
action_status_t
doMarkPlayer
(
int
unum
);
bool
doMarkPlayerNearIndex
(
int
near_index
);
bool
doMarkPlayerNearIndex
(
int
near_index
);
bool
doReduceAngleToGoal
();
hfo
::
action_status_t
doReduceAngleToGoal
();
bool
doDefendGoal
();
hfo
::
action_status_t
doDefendGoal
();
bool
doGoToBall
();
hfo
::
action_status_t
doGoToBall
();
bool
doNewAction1
();
bool
doNewAction1
();
void
addLastActionStatus
(
hfo
::
action_t
last_action
,
bool
action_status
);
void
addLastActionStatus
(
hfo
::
action_t
last_action
,
hfo
::
action_status_t
action_status
);
void
addLastActionStatusCollision
(
hfo
::
action_t
last_action
,
bool
may_fix
,
bool
likely_success
);
Communication
::
Ptr
M_communication
;
Communication
::
Ptr
M_communication
;
...
...
src/bhv_basic_move.cpp
View file @
85a0d4aa
...
@@ -48,25 +48,36 @@
...
@@ -48,25 +48,36 @@
#include <rcsc/common/server_param.h>
#include <rcsc/common/server_param.h>
#include "neck_offensive_intercept_neck.h"
#include "neck_offensive_intercept_neck.h"
#include "common.hpp"
using
namespace
rcsc
;
using
namespace
rcsc
;
bool
Bhv_BasicMove
::
execute
(
PlayerAgent
*
agent
)
{
if
(
Bhv_BasicMove
::
action_execute
(
agent
)
==
hfo
::
ACTION_STATUS_MAYBE
)
{
return
true
;
}
else
{
return
false
;
}
}
/*-------------------------------------------------------------------*/
/*-------------------------------------------------------------------*/
/*!
/*!
*/
*/
bool
hfo
::
action_status_t
Bhv_BasicMove
::
execute
(
PlayerAgent
*
agent
)
Bhv_BasicMove
::
action_
execute
(
PlayerAgent
*
agent
)
{
{
dlog
.
addText
(
Logger
::
TEAM
,
dlog
.
addText
(
Logger
::
TEAM
,
__FILE__
": Bhv_BasicMove"
);
__FILE__
": Bhv_BasicMove"
);
bool
success
=
true
;
hfo
::
action_status_t
success
=
hfo
::
ACTION_STATUS_UNKNOWN
;
//-----------------------------------------------
//-----------------------------------------------
// tackle
// tackle
if
(
Bhv_BasicTackle
(
0.8
,
80.0
).
execute
(
agent
)
)
if
(
Bhv_BasicTackle
(
0.8
,
80.0
).
execute
(
agent
)
)
{
{
return
true
;
return
hfo
::
ACTION_STATUS_MAYBE
;
}
}
const
WorldModel
&
wm
=
agent
->
world
();
const
WorldModel
&
wm
=
agent
->
world
();
...
@@ -85,9 +96,8 @@ Bhv_BasicMove::execute( PlayerAgent * agent )
...
@@ -85,9 +96,8 @@ Bhv_BasicMove::execute( PlayerAgent * agent )
{
{
dlog
.
addText
(
Logger
::
TEAM
,
dlog
.
addText
(
Logger
::
TEAM
,
__FILE__
": intercept"
);
__FILE__
": intercept"
);
success
=
Body_Intercept
().
execute
(
agent
);
success
=
hfo
::
BooleanToActionStatus
(
Body_Intercept
().
execute
(
agent
)
);
agent
->
setNeckAction
(
new
Neck_OffensiveInterceptNeck
()
);
agent
->
setNeckAction
(
new
Neck_OffensiveInterceptNeck
()
);
return
success
;
return
success
;
}
}
...
@@ -96,7 +106,9 @@ Bhv_BasicMove::execute( PlayerAgent * agent )
...
@@ -96,7 +106,9 @@ Bhv_BasicMove::execute( PlayerAgent * agent )
const
BallObject
&
ball
=
wm
.
ball
();
const
BallObject
&
ball
=
wm
.
ball
();
if
(
!
ball
.
rposValid
())
{
if
(
!
ball
.
rposValid
())
{
success
=
false
;
if
(
!
wm
.
self
().
collidesWithPost
())
{
success
=
hfo
::
ACTION_STATUS_BAD
;
}
}
}
double
dist_thr
=
ball
.
distFromSelf
()
*
0.1
;
double
dist_thr
=
ball
.
distFromSelf
()
*
0.1
;
...
@@ -115,8 +127,10 @@ Bhv_BasicMove::execute( PlayerAgent * agent )
...
@@ -115,8 +127,10 @@ Bhv_BasicMove::execute( PlayerAgent * agent )
).
execute
(
agent
)
)
).
execute
(
agent
)
)
{
{
if
(
!
Body_TurnToBall
().
execute
(
agent
))
{
if
(
!
Body_TurnToBall
().
execute
(
agent
))
{
success
=
false
;
success
=
hfo
::
ACTION_STATUS_BAD
;
}
}
}
else
if
(
success
!=
hfo
::
ACTION_STATUS_BAD
)
{
success
=
hfo
::
ACTION_STATUS_MAYBE
;
}
}
if
(
wm
.
existKickableOpponent
()
&&
if
(
wm
.
existKickableOpponent
()
&&
...
...
src/bhv_basic_move.h
View file @
85a0d4aa
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
#include <rcsc/geom/vector_2d.h>
#include <rcsc/geom/vector_2d.h>
#include <rcsc/player/soccer_action.h>
#include <rcsc/player/soccer_action.h>
#include "common.hpp"
class
Bhv_BasicMove
class
Bhv_BasicMove
:
public
rcsc
::
SoccerBehavior
{
:
public
rcsc
::
SoccerBehavior
{
...
@@ -36,7 +37,8 @@ public:
...
@@ -36,7 +37,8 @@ public:
Bhv_BasicMove
()
Bhv_BasicMove
()
{
}
{
}
bool
execute
(
rcsc
::
PlayerAgent
*
agent
);
bool
execute
(
rcsc
::
PlayerAgent
*
agent
);
hfo
::
action_status_t
action_execute
(
rcsc
::
PlayerAgent
*
agent
);
private:
private:
double
getDashPower
(
const
rcsc
::
PlayerAgent
*
agent
);
double
getDashPower
(
const
rcsc
::
PlayerAgent
*
agent
);
...
...
src/common.hpp
View file @
85a0d4aa
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
#include <stdlib.h>
#include <stdlib.h>
#include <iostream>
#include <iostream>
#include <sstream>
#include <sstream>
#include <vector>
namespace
hfo
{
namespace
hfo
{
...
@@ -33,14 +34,14 @@ enum action_t
...
@@ -33,14 +34,14 @@ enum action_t
DRIBBLE
,
// [High-Level] Dribble(): Offensive dribble
DRIBBLE
,
// [High-Level] Dribble(): Offensive dribble
CATCH
,
// [High-Level] Catch(): Catch the ball (Goalie only!)
CATCH
,
// [High-Level] Catch(): Catch the ball (Goalie only!)
NOOP
,
// Do nothing
NOOP
,
// Do nothing
QUIT
,
// Special action to quit the game
QUIT
,
// Special action to quit the game
REDUCE_ANGLE_TO_GOAL
,
// [High-Level] Reduce_Angle_To_Goal : Reduces the shooting angle
REDUCE_ANGLE_TO_GOAL
,
// [High-Level] Reduce_Angle_To_Goal : Reduces the shooting angle
MARK_PLAYER
,
// [High-Level] Mark_Player(opponent_unum [0,11]) : Moves to the position in between the kicker and a given player
MARK_PLAYER
,
// [High-Level] Mark_Player(opponent_unum [0,11]) : Moves to the position in between the kicker and a given player
DEFEND_GOAL
,
DEFEND_GOAL
,
GO_TO_BALL
GO_TO_BALL
};
};
// Status of a HFO game
// Status of a
n
HFO game
enum
status_t
enum
status_t
{
{
IN_GAME
,
// Game is currently active
IN_GAME
,
// Game is currently active
...
@@ -51,6 +52,24 @@ enum status_t
...
@@ -51,6 +52,24 @@ enum status_t
SERVER_DOWN
// Server is not alive
SERVER_DOWN
// Server is not alive
};
};
// Action status
enum
action_status_t
{
ACTION_STATUS_UNKNOWN
=
-
1
,
// cannot tell or invalid action # in status request
ACTION_STATUS_BAD
=
0
,
// definitely not OK
ACTION_STATUS_MAYBE
=
1
,
// may be OK, may not
};
/**
* Translates from boolean false (bad) or true (maybe OK) to action status
*/
inline
action_status_t
BooleanToActionStatus
(
const
bool
status
)
{
if
(
status
)
{
return
ACTION_STATUS_MAYBE
;
}
else
{
return
ACTION_STATUS_BAD
;
}
}
// Configuration of the HFO domain including the team names and player
// Configuration of the HFO domain including the team names and player
// numbers for each team. This struct is populated by ParseConfig().
// numbers for each team. This struct is populated by ParseConfig().
struct
Config
{
struct
Config
{
...
@@ -171,7 +190,7 @@ inline std::string ActionToString(action_t action) {
...
@@ -171,7 +190,7 @@ inline std::string ActionToString(action_t action) {
};
};
/**
/**
* Returns a string representation of a game
_
status.
* Returns a string representation of a game
status.
*/
*/
inline
std
::
string
StatusToString
(
status_t
status
)
{
inline
std
::
string
StatusToString
(
status_t
status
)
{
switch
(
status
)
{
switch
(
status
)
{
...
@@ -192,6 +211,22 @@ inline std::string StatusToString(status_t status) {
...
@@ -192,6 +211,22 @@ inline std::string StatusToString(status_t status) {
}
}
};
};
/**
* Returns a string representation of an action status.
*/
inline
std
::
string
ActionStatusToString
(
action_status_t
status
)
{
switch
(
status
)
{
case
ACTION_STATUS_BAD
:
return
"Bad"
;
case
ACTION_STATUS_MAYBE
:
return
"MaybeOK"
;
case
ACTION_STATUS_UNKNOWN
:
return
"Unknown"
;
default:
return
"Invalid"
;
}
}
/**
/**
* Parse a Trainer message to populate config. Returns a bool
* Parse a Trainer message to populate config. Returns a bool
* indicating if the struct was correctly parsed.
* indicating if the struct was correctly parsed.
...
...
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