http://blog.sina.com.cn/crane1may[订阅]
个人资料
评论
读取中...
访客
读取中...
好友
读取中...
博文
火星归来(2007-11-25 21:24)
不说了,贴图吧
来个ws的先
 
 
这位同学在法国,缅怀一下
 
再来我桌子
 
费尽千辛万苦来之不易的20'显示器
我的第一幅PS手绘(2007-06-07 22:57)
很简单的
不过感觉还挺帅
还有个红色版和鹤鹤当QQ头像了
小show一下(2007-06-04 16:40)
应家人需求,先贴俩奖状
下来是微软的入围证书
这张照片是在人大答辩时照的
是跟高中同学一起参加创业计划的比赛
 
可惜只得了第二名,不过中间那个是风险投资商,说要给我们投资呢
记得我刚进大学就说,我要拿冯如杯一等奖然后保研
居然成功了
有点晕了,大学好像快结束了,赶紧再定个目标
对了
大家有空看看我的作品
 
这个是简化版
 
发个完全版截图
 北航微软俱乐部举办的机器人PK大赛,我小参加了一把,没想到一晚上做出来的还挺牛逼,不过高估了对手,被肉搏的弱智干掉了
罢了,发出来玩玩
那个模式匹配的攻击不是我写的,感谢那个作者,我是从高版本平台改写的,然后写了躲避策略
当然还用朋友帮忙,特地感谢覃仁智,一起干活还替我上场,主要是吹嘘了我一把
 
下边是源码:
 

#include 'Robot.h'
#include 'Utils.h'
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>

double velocity; //运动速度
double moveTime; //朝一个方向运动的时间

//函数声明
void changeDirection(void);
void doRadar(void);


double velocity;
void moveTo(double x, double y)
{
 double h = heading(getBodyX(),getBodyY(),x,y);
 double angle = turnAngle(getBodyHeading(),h);
 turnBody(angle);
 moveBody(velocity);
}


static double POWER;
#define LongW  20
#define HisLong  20000
double vMem[HisLong];
double hMem[HisLong];
static int nowI;


void record(struct ScannedRobotEvent* bot);
int getSml();
void reachfire(int matchIndex, double power, double* fireX, double* fireY);

 
void record(struct ScannedRobotEvent* bot)
{
 vMem[nowI] = bot->velocity;
 hMem[nowI] = bot->heading;
 nowI++;
}
int getSml()
{
 double bS=1000000;
 int mI=0, i, j;
 for(i=LongW; i<nowI-LongW; i++)
 {
  double similarity=0;
  for(j=1; j<=LongW; j++)
  {
   similarity+=abs(vMem[i-j]-vMem[nowI-j]);
   similarity+=abs(hMem[i-j]-hMem[nowI-j]);
   
  }
     if(similarity<bS)
     {
      mI=i;
      bS=similarity;
  }
 }
 return mI;
}

double next(double x,double y,double  heading1, double dis1, double* nextX, double* nextY)
{


 *nextX=dis1*cos(heading1)+x;
 *nextY=dis1*sin(heading1)+y;
 return 0.0;
}

void reachfire(int matchIndex, double power, double* fireX, double* fireY)
{
    double x =scannedRobotEvent.x;
    double y = scannedRobotEvent.y;
    double dis;
    int time = 0;
    while(matchIndex+time<nowI)
    {
     dis = distance(getBodyX(), getBodyY(), x, y);
     if(dis/(20.0-3.0*power)<=time) break;
     next(x, y, hMem[matchIndex+time],
      vMem[matchIndex+time], &x, &y);
     time++;
    }
 *fireX = x;
 *fireY = y;
}

void valuearea(double x,double y,double head,double* nx,double *ny)
{
 double h=heading(x,y,*nx,*ny);
 double s=distance(x,y,*nx,*ny);
 double tmp;

 double x1=s*cos(h-head);
 double y1=s*sin(h-head);

 if (abs(x1)>abs(y1))
 {
  tmp=x1;
  x1=y1;
  y1=tmp;

  *nx=s*cos(h+head)+x;
  *ny=s*sin(h+head)+y;
 }
}

//执行函数
void work()
{
 int matchIndex;
 double fireX, fireY;
 double h;
 double angle; 
 double nx;
 double ny;
 int pointX;
 int pointY;
 char buf[10];
 struct ScannedRobotEvent oppo;
 struct ScannedRobotEvent* opponent = &oppo;
 oppo=scannedRobotEvent;
 doRadar();
 if(opponent==NULL) return;
 record(opponent);
 matchIndex = getSml();
 reachfire(matchIndex, POWER, &fireX, &fireY);
 h = heading(getBodyX(), getBodyY(), fireX, fireY);
 angle = turnAngle(getGunHeading(),h);
 turnGun(angle);
 //println(buf);
 fire(POWER);

 pointX = rand() % 8;
 srand( (unsigned)time( NULL ) );
 pointY = rand() % 8;

 nx=pointX + getBodyX()-4;
 ny=pointY + getBodyY()-4;

 h=heading(getBodyX(),getBodyY(),scannedRobotEvent.x,scannedRobotEvent.y);
 valuearea(getBodyX(),getBodyY(),h,&nx,&ny);
 moveTo(nx,ny);

}

void onBegin()
{
    scannedRobotEvent.time = -5;
 velocity = 20;
 moveTime = 25;
}

void onHitRobot()
{
 changeDirection();
}

void onHitWall()
{
 changeDirection();
}


void onHitByBullet()
{
}


void doRadar()
{
 if( getTime()- scannedRobotEvent.time > 3 )turnRadar(PI);
 else{
  double h = heading( getBodyX(),getBodyY(),
    scannedRobotEvent.x, scannedRobotEvent.y
     );
  double angle = turnAngle(getRadarHeading(),h);
  
  double s=distance(getBodyX(),getBodyY(),scannedRobotEvent.x, scannedRobotEvent.y);
  turnRadar(angle);

  POWER=(1-s/700.0)*1.0+0.3;
  if (s<200) POWER+=0.5;
  if (s<100) POWER+=0.9;
  if (s<50) POWER+=1.2;
 }
}

void changeDirection()
{
 velocity = -velocity;
}

void onRobotDeath(){}
void onFinish(){}
void onOvertime(){}
void onBulletHit(){}
void onScannedRobot(){}

最近的照片(2007-04-26 21:20)
 我们参加ImageineCup的队伍 -Still Fun
 
中间那个就是盖茨了
 
刚分到实验室的桌子了
 
给这群壮观的书来个特写,里面没有课本,图书馆的只有两本,都是买的,利害吧
 
这招叫做螺旋丸(拉行嘎)
 
小班春游,我居然是大厨,烤出的肉知道3.0版才能吃
 
那天上山没冻死我
 
V505大变身!!!(2007-03-09 22:21)
先刮掉原来的皮
 
刮光啦
 
找到图,先画出轮廓
 
完成啦,给几张特写!!
hehe2(2006-09-24 00:34)
 
中国政法
hehe(2006-09-24 00:26)
我的mm同学
我爸的杰作
狂吃
我们学校的新大楼
同上
小强 活的
我的局域床
学校里发现的