人工势场法
// Strategy.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include "Strategy.h"
#include <math.h>
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call, 街舞中国
LPVOID lpRerved
)
{
switch (ul_reason_for_call)
{
ca DLL_PROCESS_ATTACH:
ca DLL_THREAD_ATTACH:
ca DLL_THREAD_DETACH:
ca DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
typedef struct
{
double x,y;
}speed;
const double PI = 3.1415926;
FILE *trace;
void Path(Robot *robot,Environment *env,int num);
speed Computc(Robot *robot1,OpponentRobot *robot2);
特殊教育概论speed Computx(Robot *robot,Environment *env);
speed Computbc(Robot *robot1,Robot *robot2);
void Angle ( Robot *robot, int desired_angle, int v,Environment *env);
void Velocity ( Robot *robot, int vl, int vr );
void Position( Robot *robot, double x, double y );
void defend(Robot *robot);
void Position1_cz( Robot *robot, double x, double y ) ;
extern "C" STRATEGY_API void Create ( Environment *env )
{
// allocate ur data and assign to env->urData
// eg. env->urData = ( void * ) new MyVariables ();
}
extern "C" STRATEGY_API void Destroy ( Environment *env )
{
// free any ur data created in Create ( Environment * )
// eg. if ( env->urData != NULL ) delete ( MyVariables * ) env->urData;
}
extern "C" STRATEGY_API void Strategy ( Environment *env )
{
Path(&env->home[1],env,1);
/*Path(&env->home[2],env,2);
Path(&env->home[3],env,3);
Path(&env->home[4],env,4);
defend(&env->home[0]);*/
徽菜
}
void defend(Robot *robot)
{
if(robot->pos.y < 49.6801)
{
Velocity(robot,-25,-25);
}
if(robot->pos.y > 33.9320)
{
Velocity(robot,25,25);
}
}
void Path(Robot *robot,Environment *env,int num)
{
int i;
speed sp;
double x = 0, y = 0;
double v,angle;
创业基础double posx = robot->pos.x;
double posy = robot->pos.y;
for(i = 0; i < 5; i++)
{
sp = Computc(robot,&env->opponent[i]);
x += sp.x;
y += sp.y;
/*trace = fopen("1.txt","a");
fprintf(trace,"1=%d\n",i);
fprintf(trace,"x=%d\n",int(sp.x));
fprintf(trace,"y=%d\n",int(sp.y));
fclo(trace);*/
if(i != num )
{
sp = Computbc(robot,&env->home[i]);
x += sp.x;
y += sp.y;
/*trace = fopen("2.txt","a");
fprintf(trace,"i=%d\n",i);
fprintf(trace,"x=%d\n",int(sp.x));
fprintf(trace,"y=%d\n",int(sp.y));
fclo(trace);*/
}
}
sp = Computx(robot,env);
x += sp.x;工作年限怎么填
y += sp.y;
if(robot->pos.x > 88.0 && abs((int)robot->rotation) <80 )
{
x = 0;
}
if(robot->pos.x < 11.0 && abs((int)robot->rotation) > 100)
{
x = 0;
}
if(robot->pos.y > 72.0 && (int)robot->rotation >10 && (int)robot->rotation <170)
{
y = 0;
}
if(robot->pos.y < 11.0 && (int)robot->rotation <-10 && (int)robot->rotation > -170)
{
y = 0;
}
posx+=x;
posy+=y;
Position1_cz(robot,posx,posy);
/*
v = sqrt(x*x +
y*y);//速度
if(v > 125)
v = 125;
if(v < -125)
v = -125;
v/=2;
/*trace = fopen("3.txt","a");
fprintf(trace,"x=%d\n",int(sp.y));cute中文翻译
fprintf(trace,"y=%d\n",int(sp.x));
fprintf(trace,"sx=%d\n",int(x));
fprintf(trace,"sy=%d\n",int(y));
fprintf(trace,"v=%d\n",int(v));
fclo(trace);*/
/*
if(abs(v) < 3)
{
v = 3;
}
angle = atan(abs(y/x))*180/PI;//反正切,转换为角度
if(x > 0 && y > 0)
{
angle = angle;
}
el if(x < 0 && y > 0)
{
angle = 180 - angle;
}
el if(x < 0 && y < 0)
{
angle = angle - 180;
}
el if(x > 0 && y < 0)
勤学的成语
{
angle = - angle;
一个人也能好好过
}
el if(x == 0 && y > 0)
{
angle = 90;
}
el if(x == 0 && y < 0)
{
angle = 270;
}
el if(y == 0 && x > 0)
{
angle = 0;
}
el if(y == 0 && x < 0)
{
angle = 180;
}
Angle(robot,int(angle),int(v),env);
//Velocity(robot,int(v),int(v));
/*trace = fopen("1.txt","a");
fprintf(trace,"a%d\n",int(angle));
fprintf(trace,"v%d\n",int(v));
fprintf(trace,"%d\n",int(y));
fclo(trace);*/
}
speed Computc(Robot *robot1,OpponentRobot *robot2)