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
f076b7d9
Commit
f076b7d9
authored
Aug 23, 2015
by
Matthew Hausknecht
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a force pass behavior.
parent
5bc12581
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1733 additions
and
1 deletion
+1733
-1
src/agent.cpp
src/agent.cpp
+6
-1
src/bhv_force_pass.cpp
src/bhv_force_pass.cpp
+1556
-0
src/bhv_force_pass.h
src/bhv_force_pass.h
+171
-0
No files found.
src/agent.cpp
View file @
f076b7d9
...
...
@@ -47,6 +47,7 @@
#include "bhv_set_play_kick_in.h"
#include "bhv_set_play_indirect_free_kick.h"
#include "shoot_generator.h"
#include "bhv_force_pass.h"
#include "bhv_custom_before_kick_off.h"
#include "bhv_strict_check_shoot.h"
...
...
@@ -411,6 +412,11 @@ void Agent::actionImpl() {
=
std
::
min_element
(
cont
.
begin
(),
cont
.
end
(),
ShootGenerator
::
ScoreCmp
());
Body_SmartKick
(
best_shoot
->
target_point_
,
best_shoot
->
first_ball_speed_
,
best_shoot
->
first_ball_speed_
*
0.99
,
3
).
execute
(
this
);
}
else
if
(
action
.
action
==
PASS
)
{
Force_Pass
pass
;
int
receiver
=
int
(
action
.
arg1
);
pass
.
get_pass_to_player
(
this
->
world
(),
receiver
);
pass
.
execute
(
this
);
}
switch
(
action
.
action
)
{
case
DASH
:
...
...
@@ -431,7 +437,6 @@ void Agent::actionImpl() {
case
SHOOT
:
break
;
case
PASS
:
this
->
doPass
();
break
;
case
DRIBBLE
:
this
->
doDribble
();
...
...
src/bhv_force_pass.cpp
0 → 100644
View file @
f076b7d9
This diff is collapsed.
Click to expand it.
src/bhv_force_pass.h
0 → 100644
View file @
f076b7d9
#ifndef BHV_FORCE_PASS_H
#define BHV_FORCE_PASS_H
#include <rcsc/player/player_object.h>
#include <rcsc/player/soccer_action.h>
#include <rcsc/player/world_model.h>
#include <rcsc/geom/vector_2d.h>
#include <rcsc/geom/angle_deg.h>
#include <functional>
#include <vector>
/* class WorldModel; */
/* class PlayerObject; */
/*!
\class Force_Pass
\brief advanced pass planning & behavior.
*/
class
Force_Pass
:
public
rcsc
::
BodyAction
{
public:
/*!
\enum PassType
\brief pass type id
*/
enum
PassType
{
DIRECT
=
1
,
LEAD
=
2
,
THROUGH
=
3
};
/*!
\struct PassRoute
\brief pass route information object, that contains type,
receiver info, receive point and ball first speed.
*/
struct
PassRoute
{
PassType
type_
;
//!< pass type id
const
rcsc
::
PlayerObject
*
receiver_
;
//!< pointer to the receiver player
rcsc
::
Vector2D
receive_point_
;
//!< estimated receive point
double
first_speed_
;
//!< ball first speed
bool
one_step_kick_
;
//!< true if ball reaches first speed only by one kick.
double
score_
;
//!< evaluated value of this pass
/*!
\brief construct with all member variables
\param type pass type id
\param receiver pointer to the receiver player
\param point pass receive point
\param speed ball first speed
\param one_step_kick true if ball reaches first speed only by one kick.
*/
PassRoute
(
PassType
type
,
const
rcsc
::
PlayerObject
*
receiver
,
const
rcsc
::
Vector2D
&
point
,
const
double
&
speed
,
const
bool
one_step_kick
)
:
type_
(
type
)
,
receiver_
(
receiver
)
,
receive_point_
(
point
)
,
first_speed_
(
speed
)
,
one_step_kick_
(
one_step_kick
)
,
score_
(
0.0
)
{
}
};
/*!
\class PassRouteScoreComp
\brief function object to evaluate the pass
*/
class
PassRouteScoreComp
:
public
std
::
binary_function
<
PassRoute
,
PassRoute
,
bool
>
{
public:
/*!
\brief compare operator
\param lhs left hand side argument
\param rhs right hand side argument
\return compared result
*/
result_type
operator
()(
const
first_argument_type
&
lhs
,
const
second_argument_type
&
rhs
)
const
{
return
lhs
.
score_
<
rhs
.
score_
;
}
};
private:
//! cached calculated pass data
static
std
::
vector
<
PassRoute
>
S_cached_pass_route
;
public:
/*!
\brief accessible from global.
*/
Force_Pass
()
{
}
/*!
\brief execute action
\param agent pointer to the agent itself
\return true if action is performed
*/
bool
execute
(
rcsc
::
PlayerAgent
*
agent
);
/*!
\brief calculate best pass route
\param world consr rerefence to the WorldModel
\param target_point receive target point is stored to this
\param first_speed ball first speed is stored to this
\param receiver receiver number
\return true if pass route is found.
*/
static
bool
get_best_pass
(
const
rcsc
::
WorldModel
&
world
,
rcsc
::
Vector2D
*
target_point
,
double
*
first_speed
,
int
*
receiver
);
static
bool
get_pass_to_player
(
const
rcsc
::
WorldModel
&
world
,
int
receiver
);
private:
static
void
create_routes
(
const
rcsc
::
WorldModel
&
world
);
static
void
create_routes_to_player
(
const
rcsc
::
WorldModel
&
world
,
const
rcsc
::
PlayerObject
*
teammate
);
static
void
create_direct_pass
(
const
rcsc
::
WorldModel
&
world
,
const
rcsc
::
PlayerObject
*
teammates
);
static
void
create_lead_pass
(
const
rcsc
::
WorldModel
&
world
,
const
rcsc
::
PlayerObject
*
teammates
);
static
void
create_through_pass
(
const
rcsc
::
WorldModel
&
world
,
const
rcsc
::
PlayerObject
*
teammates
);
static
void
create_forced_pass
(
const
rcsc
::
WorldModel
&
world
,
const
rcsc
::
PlayerObject
*
teammates
);
static
bool
verify_direct_pass
(
const
rcsc
::
WorldModel
&
world
,
const
rcsc
::
PlayerObject
*
receiver
,
const
rcsc
::
Vector2D
&
target_point
,
const
double
&
target_dist
,
const
rcsc
::
AngleDeg
&
target_angle
,
const
double
&
first_speed
);
static
bool
verify_through_pass
(
const
rcsc
::
WorldModel
&
world
,
const
rcsc
::
PlayerObject
*
receiver
,
const
rcsc
::
Vector2D
&
receiver_pos
,
const
rcsc
::
Vector2D
&
target_point
,
const
double
&
target_dist
,
const
rcsc
::
AngleDeg
&
target_angle
,
const
double
&
first_speed
,
const
double
&
reach_step
);
static
void
evaluate_routes
(
const
rcsc
::
WorldModel
&
world
);
static
bool
can_kick_by_one_step
(
const
rcsc
::
WorldModel
&
world
,
const
double
&
first_speed
,
const
rcsc
::
AngleDeg
&
target_angle
);
};
#endif
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