Group of classes to determine the players roles and what they need to do according to their roles and the game strategy.
Each player has a role and this depends on each player position. In the Agend2D code, using the basic formation 4-3-3, the roles are:
What do you need to implement is only the behavior of each role in a specific situation.
In the Agent2D, each role has only two methods: doKick() and doMove().
bool
RoleCenterBack::execute( PlayerAgent * agent )
{
bool kickable = agent->world().self().isKickable();
if ( agent->world().existKickableTeammate()
&& agent->world().teammatesFromBall().front()->distFromBall()
< agent->world().ball().distFromSelf() )
{
kickable = false;
}
if ( kickable )
{
doKick( agent );
}
else
{
doMove( agent );
}
return true;
}
The method above checks if the player with the ball possession can kick it to the goal and if the teammate distance to the ball is smaller than the player distance. If these two conditions are met, this means that the player can move with the ball. Otherwise, the player needs to pass the ball to the teammate.
Suppose that you want to perform a through pass. To do that, there is the Bhv_ThroughPassKick class which has the through pass implementation. We also want to perform this pass only with midfielder players (role: OffensiveHalf). Then, we need to go to the doKick method in the RoleOffensiveHalf class and check in which BallArea the player can execute this action.
Remember that, before you implement the behavior, you need to understand how the Strategy class works.
For example:
//[...]
switch ( Strategy::get_ball_area( agent->world().ball().pos() ) ) {
case Strategy::BA_OffMidField:
if(Bhv_ThroughPassKick().execute(agent))
break;
// other actions
break;
//[...] case n:
}
The player will only execut the through pass if the ball is in the offensive midfield (BA_OffMidField) and if the Bhv_ThroughPassKick's execute method returns true. That is, if the player can really execute this action. If the ball is in the BA_OffMidField area but the player has no condition of executing the pass through, then another action will be executed.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。