資源簡介
robocup 2D中較強的yushan底層代碼,雖說已經開源了,但是一些人可能找不到,分享分享
代碼片段和文件信息
//?-*-c++-*-
/*!
??\file?basic_actions.cpp
??\brief?basic?player?actions?Source?File
*/
/*
?*Copyright:
?Copyright?(C)?Hidehisa?AKIYAMA
?This?code?is?free?software;?you?can?redistribute?it?and/or
?modify?it?under?the?terms?of?the?GNU?Lesser?General?Public
?License?as?published?by?the?Free?Software?Foundation;?either
?version?3?of?the?License?or?(at?your?option)?any?later?version.
?This?library?is?distributed?in?the?hope?that?it?will?be?useful
?but?WITHOUT?ANY?WARRANTY;?without?even?the?implied?warranty?of
?MERCHANTABILITY?or?FITNESS?FOR?A?PARTICULAR?PURPOSE.??See?the?GNU
?Lesser?General?Public?License?for?more?details.
?You?should?have?received?a?copy?of?the?GNU?Lesser?General?Public
?License?along?with?this?library;?if?not?write?to?the?Free?Software
?Foundation?Inc.?59?Temple?Place?Suite?330?Boston?MA??02111-1307??USA
?*EndCopyright:
?*/
/////////////////////////////////////////////////////////////////////
#ifdef?HAVE_CONFIG_H
#include?
#endif
#include?“basic_actions.h“
#include?“bhv_scan_field.h“
#include?“neck_scan_field.h“
#include?“neck_scan_players.h“
#include?yer/player_agent.h>
#include?
#include?
#include?
//#define?DEBUG
//#define?DEBUG_NECK_TURN_TO_BALL
namespace?rcsc?{
/////////////////////////////////////////////////////////////////////
/*-------------------------------------------------------------------*/
/*!
?*/
bool
Body_TurnToAngle::execute(?PlayerAgent?*?agent?)
{
????dlog.addText(?Logger::ACTION
??????????????????__FILE__“:?Body_TurnToAngle“?);
????const?Selfobject?&?self?=?agent->world().self();
????if?(?!?self.faceValid()?)
????{
????????agent->doTurn(?0.0?);
????????return?false;
????}
????agent->doTurn(?M_angle?-?self.body()?);
????return?true;
}
/////////////////////////////////////////////////////////////////////
/*-------------------------------------------------------------------*/
/*!
?*/
bool
Body_TurnToPoint::execute(?PlayerAgent?*?agent?)
{
????dlog.addText(?Logger::ACTION
??????????????????__FILE__“:?Body_TurnToPoint“?);
????const?Selfobject?&?self?=?agent->world().self();
????if?(?!?self.posValid()?)
????{
????????return?agent->doTurn(?60.0?);
????}
????//?relative?angle?from?my?predicted?pos?&?body?angle?to?point
????Vector2D?my_point?=?self.inertiaPoint(?M_cycle?);
????AngleDeg?target_rel_angle
????????=?(?M_point?-?my_point?).th()?-?self.body();
????//?not?consider?about?max?effective?turn?(inertia?moment)
????//?try?to?face?to?point?greedy
????agent->doTurn(?target_rel_angle?);
????if?(?target_rel_angle.abs()?1.0?)
????{
????????return?false;
????}
????return?true;
}
/////////////////////////////////////////////////////////////////////
/*-------------------------------------------------------------------*/
/*!
?*/
bool
Body_TurnToBall::execute(?PlayerAgent?*?agent?)
{
????dlog.addText(?Logger::ACTION
??????????????????__FILE__“:?Body_TurnToBall“?);
????if?(?!?agent->world().ba
評論
共有 條評論