游戏人工智能实验报告一

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

实验一追逐与拦截

实验报告

一、实验目的

掌握游戏中追逐与拦截的人工智能算法

二、实验仪器

Windows7系统

Microsoft Visual Studio2015

三、实验原理及过程

B ourg & Glenn Seemann

Example: Chasing and evading in continuous environments, Chapter 2

*/

= lg/2; vList[0].x = wd/2;

vList[1].y = -lg/2; vList[1].x = wd/2;

vList[2].y = -lg/2; vList[2].x = -wd/2;

vList[3].y = lg/2; vList[3].x = -wd/2;

vList[4].y = lg/2*; vList[4].x = 0;

for(i=0; i<5; i++)

{

v1 = VRotate2D, vList[i]);

vList[i] = v1 + ;

}

DrawLine(vList[0].x, vList[0].y, vList[1].x, vList[1].y, 2, clr);

DrawLine(vList[1].x, vList[1].y, vList[2].x, vList[2].y, 2, clr);

DrawLine(vList[2].x, vList[2].y, vList[3].x, vList[3].y, 2, clr);

DrawLine(vList[3].x, vList[3].y, vList[4].x, vList[4].y, 2, clr);

DrawLine(vList[4].x, vList[4].y, vList[0].x, vList[0].y, 2, clr);

if(ShowVectors)

{

Vector v, u;

double f = 5;

.

s12 = - ;

u = VRotate2D, s12);

if < -_TOL)

{

vtmp = vAngularVelocity^CD; double f;

if((Thrust * vLocalVelocity)/() * ()) > 0)

f = 2;

else

f = 1;

tmp = * rho * fLocalSpeed*fLocalSpeed * ProjectedArea * f;

vResultant = vDragVector *_LINEARDRAGCOEFFICIENT* tmp; calculations: fSpeed = ();

vVelocityBody = VRotate2D(-fOrientation, vVelocity);

}

void RigidBody2D::SetThrusters(bool p, bool s)

{

= 0;

= 0;

= 0;

= 0;

if(p)

= -_STEERINGFORCE;

if(s)

= _STEERINGFORCE;

}

Vector VRotate2D( float angle, Vector u)

{

float x,y;

x = * cos(DegreesToRadians(-angle)) + * sin(DegreesToRadians(-angle));

y = * sin(DegreesToRadians(-angle)) + * cos(DegreesToRadians(-angle));

return Vector( x, y, 0);

}

void RigidBody2D::ModulateThrust(bool up)

{

double dT = up_DTHRUST:-_DTHRUST;

ThrustForce += dT;

if(ThrustForce > _MAXTHRUST) ThrustForce = _MAXTHRUST;

if(ThrustForce < _MINTHRUST) ThrustForce = _MINTHRUST; }

相关文档
最新文档