gotoball.java

来自「一个多机器人的仿真平台」· Java 代码 · 共 60 行

JAVA
60
字号
package Domains.SoccerBots.teams;/* * GoToBall.java */import	EDU.gatech.cc.is.util.Vec2;import	EDU.gatech.cc.is.abstractrobot.*;//Clay not used/** * This is about the simplest possible soccer strategy, just go to the ball. * <P> * <A HREF="../COPYRIGHT.html">Copyright</A> * (c)1997 Georgia Tech Research Corporation * * @author Tucker Balch * @version $Revision: 1.1 $ */public class GoToBall extends ControlSystemSS	{	/**	Configure the Avoid control system.  This method is	called once at initialization time.  You can use it	to do whatever you like.	*/	public void Configure()		{		}				/**	Called every timestep to allow the control system to	run.	*/	public int TakeStep()		{		Vec2	result,ball;		long	curr_time = abstract_robot.getTime();			// get vector to the ball		ball = abstract_robot.getBall(curr_time);		// set heading towards it		abstract_robot.setSteerHeading(curr_time, ball.t);		// set speed at maximum		abstract_robot.setSpeed(curr_time, 1.0);		// kick it if we can		if (abstract_robot.canKick(curr_time))			abstract_robot.kick(curr_time);		// tell the parent we're OK		return(CSSTAT_OK);		}	}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?