1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
#include <iostream>
#include <conio.h>
#include <windows.h>
#include "Robot.h"
#include <stdlib.h> /* srand, rand */
#include <time.h> /* time */
using namespace std;
const int MAXROB=5;
const int MaxX=10,maxY=10;
void orderOfPlay(int order[MAXROB],Robot roboti[MAXROB])
{
for(int i=0;i<MAXROB;i++)
{ int max=0,maxNum;
for(int j=0;j<MAXROB;j++)
{
if(roboti[j].getmovSpeed()>max)
{
int checkIn=0;
for(int k=0;k<i;k++)
if(order[k]==j)
checkIn=1;
if(checkIn==0)
{
maxNum=j;
max=roboti[j].getmovSpeed();
}
}
}
order[i]=maxNum;
}
}
void bitka(Robot A,Robot B)
{
}
void RobotMovement(Robot roboti[MAXROB],int order[MAXROB],int inGame,int br)
{ int NumOfRob=0;
for(int i=0;i<inGame;i++)
{
while(roboti[order[NumOfRob]].getInGamez()!=true)
{
NumOfRob++;
}
bool done=false;
while(done==false)
{
int movement=rand() % 4+1;
switch(movement)
{
case 1:
{
if(roboti[order[NumOfRob]].getY()!=0)
{
roboti[order[NumOfRob]].moveWest();
done=true;
break;
}
}
case 2:
{
if(roboti[order[NumOfRob]].getY()<maxY-1)
{
roboti[order[NumOfRob]].moveEast();
done=true;
break;
}
}
case 3:
{
if(roboti[order[NumOfRob]].getX()!=0)
{
roboti[order[NumOfRob]].moveNorth();
done=true;
break;
}
}
case 4:
{
if(roboti[order[NumOfRob]].getX()<MaxX-1)
{
roboti[order[NumOfRob]].moveSouth();
done=true;
}
break;
}
}
}
int y=roboti[order[NumOfRob]].getY(),x=roboti[order[NumOfRob]].getX();
for(int j=0;j<br;j++)
{
if(j!=order[NumOfRob]&&roboti[j].getInGamez()==true)
{
if(x==roboti[j].getX()&&roboti[j].getY()==y)
bitka(roboti[order[NumOfRob]],roboti[j]);
}
}
NumOfRob++;
}
}
void map(Robot roboti[MAXROB],int br)
{
int inGame=br;
int order[MAXROB];
orderOfPlay(order,roboti); //Da proverq dali baca tui!
srand (time(NULL));
while(inGame!=1)
{ RobotMovement(roboti,order,inGame,br);
}
}
int main()
{
cout<<"H";
Sleep(400);
cout<<"E";
Sleep(400);
cout<<"L";
Sleep(400);
cout<<"M"<<endl;
return 0;
}
|