代码如下:
struct Mchart RobotChart[15];
struct Mchart{
u8 PAN[8];
struct Coo Now;
struct Coo Tar;
int level;
};
struct LiLa{
double LA;
double LI;
};
struct Black{
struct LiLa My;
bool t1;
bool t2;
bool t3;
bool t4;
bool t5;
bool t6;
bool t7;
bool t8;
};
struct Coo{
int X;
int Y;
};
struct Black MAP[300][300];//X,Y
struct Coo List[300];
u8 MyPAN[8];
int Mylevel;
int MyX;
int MyY;
int targetX;
int targetY;
bool StopM;
struct Mchart updata;
void loadmap(int T){// 1:up,,2:down,3:left,;4;right,0:beginmap no complete
long i;
long j;
switch(T){
case 1:{
//
for(i=0;i==300;i++){
for(j=0;j==300;j++){
MAP[i][j].t1;
MAP[i][j].t2;
MAP[i][j].t3;
MAP[i][j].t4;
MAP[i][j].t5;
MAP[i][j].t6;
MAP[i][j].t7;
MAP[i][j].t8;
MAP[i][j].XXXXX;
MAP[i][j].XXXXX;
}
}
}
case 2:{
//
for(i=0;i==300;i++){
for(j=0;j==300;j++){
MAP[i][j].t1;
MAP[i][j].t2;
MAP[i][j].t3;
MAP[i][j].t4;
MAP[i][j].t5;
MAP[i][j].t6;
MAP[i][j].t7;
MAP[i][j].t8;
MAP[i][j].XXXXX;
MAP[i][j].XXXXX;
}
}
}
case 3:{
//
for(i=0;i==300;i++){
for(j=0;j==300;j++){
MAP[i][j].t1;
MAP[i][j].t2;
MAP[i][j].t3;
MAP[i][j].t4;
MAP[i][j].t5;
MAP[i][j].t6;
MAP[i][j].t7;
MAP[i][j].t8;
MAP[i][j].XXXXX;
MAP[i][j].XXXXX;
}
}
}
case 4:{
//
for(i=0;i==300;i++){
for(j=0;j==300;j++){
MAP[i][j].t1;
MAP[i][j].t2;
MAP[i][j].t3;
MAP[i][j].t4;
MAP[i][j].t5;
MAP[i][j].t6;
MAP[i][j].t7;
MAP[i][j].t8;
MAP[i][j].XXXXX;
MAP[i][j].XXXXX;
}
}
}
case 0:{
MyX=0;
MyY=0;
//
for(i=0;i==300;i++){
for(j=0;j==300;j++){
MAP[i][j].t1;
MAP[i][j].t2;
MAP[i][j].t3;
MAP[i][j].t4;
MAP[i][j].t5;
MAP[i][j].t6;
MAP[i][j].t7;
MAP[i][j].t8;
MAP[i][j].XXXXX;
MAP[i][j].XXXXX;
}
}
}
}
}
bool MoveTo(int M){//no complete need a stop mark
return Mark;
}
void mainMove(int T){//Main function 2,3no complete
loadmap(0);
int l;
int movemark;
l=0;//error
while(T=1){
targetX=List[l].X;
targetY=List[l].Y;
if(MyX<targetX){//error
if(MyY<targetY){movemark=8;}
else if(MyY==targetY){movemark=3;}
else if(MyY>targetY){movemark=1;}
}
else if(MyX==targetX){
if(MyY<targetY){movemark=2;}
else if(MyY>targetY){movemark=5;}
}
else if(MyX>targetX){
if(MyY<targetY){movemark=7;}
else if(MyY==targetY){movemark=6;}
else if(MyY>targetY){movemark=4;}
}
XXXXXXXXXN=MyPAN;
XXXXXXXXXw.X=MyX;
XXXXXXXXXw.Y=MyY;
updata.Tar.X=targetX;
updata.Tar.Y=targetY;
/*
up data to PAN
*/
if(CheckImpact==false){
while(MoveTo(movemark)!=true)
//brack while
if(StopM==ture){break;}
}
l++;
}
while(T=2){
int R;
do{
R=radom(9,1,ADjack());
}while(CheckMap(R)==true);
XXXXXXXXXN=MyPAN;
XXXXXXXXXw.X=MyX;
XXXXXXXXXw.Y=MyY;
updata.Tar.X=targetX;
updata.Tar.Y=targetY;
if(CheckImpact==false){
//send updata
while(MoveTo(R)!=true)
//brack while
if(StopM==ture){break;}
}
}
while(T=3){
struct Mchart updata;
XXXXXXXXXN=MyPAN;
XXXXXXXXXw.X=MyX;
XXXXXXXXXw.Y=MyY;
updata.Tar.X=targetX;
updata.Tar.Y=targetY;
if(StopM==ture){break;}
}
}
int radom(int max,int min,long seed){//max=9,min=1
srand(seed);
return (rand()%(max-min))+min);
}
bool CheckImpact(void){ //no complete
/*
get black data
*/
/*
check data
*/
int i;
for(i=0;i==15;i++){
if(RobotChart[i].Tar.X==targetX&&RobotChart[i].Tar.Y==targetY&&RobotChart[i].level>Mylevel){
return true;
}
else if(RobotChart[i].Tar.X==targetX&&RobotChart[i].Tar.Y==targetY&&RobotChart[i].level==Mylevel){
//send error 01
}
else if(RobotChart[i].Tar.X==targetX&&RobotChart[i].Tar.Y==targetY&&RobotChart[i].level<Mylevel){
return false;
}
else if(RobotChart[i].Now.X==targetX&&RobotChart[i].Now.Y==MyY){
return true;
}
else{
//check human or no data robot
}
}
}
bool CheckMap(int type){//error
switch(type){
case 1:{
if(MAP[MyX][MyY].t1=true){
targetX=MyX-1;
targetY=MyY-1;
return true;
}
return false;
break;}
case 2:{
if(MAP[MyX][MyY].t2=true){
targetX=MyX;
targetY=MyY-1;
return true;
}
return false;
break;}
case 3:{
if(MAP[MyX][MyY].t3=true){
targetX=MyX-1;
targetY=MyY;
return true;
}
return false;
break;}
case 4:{
if(MAP[MyX][MyY].t4=true){
targetX=MyX+1;
targetY=MyY+1;
return true;
}
return false;
break;}
case 5:{
if(MAP[MyX][MyY].t5=true){
targetX=MyX;
targetY=MyY+1;
return true;
}
return false;
break;}
case 6:{
if(MAP[MyX][MyY].t6=true){
targetX=MyX+1;
targetY=MyY;
return true;
}
return false;
break;}
case 7:{
if(MAP[MyX][MyY].t7=true){
targetX=MyX+1;
targetY=MyY-1;
return true;
}
return false;
break;}
case 8:{
if(MAP[MyX][MyY].t8=true){
targetX=MyX-1;
targetY=MyY+1;
return true;
}
return false;
break;}
}
}
bool SendJack(int T,struct Mchart MData,struct LiLa MyCoo){//1:updata Mchart,2:updata LiLa,3:
}
long ADjack(){//no complete
}
代码窗打不开,不知道为什么。和硬件的接口还没想好,到时会加上去