Exemplo n.º 1
0
bool AI::runHuman()
{
  cout<<"Human Turn: "<<turnNum()<<endl;
  if(turnNum() == 1)
  {
    for(unsigned int w=0;w<weapons.size();w++)
    {
      cout<<"WeaponID: "<<w<<endl;
      displayWeapon(weapons[w]);          
    }
    vector<location> nearby = validMoves(0,0);
    while(nearby.size()<5)
    {
      //should keep trying to find 6 valid spots at random on the map
      nearby = validMoves(rand()%(getMapSize()*2)-getMapSize(),rand()%(getMapSize()*2)-getMapSize());
    }
    for(int i=0;i<getHumansReady();i++)
    {
      Human::spawn(weapons[i], nearby[i].x, nearby[i].y);
    }
  }
  if(turnNum() == 3)
  {
    for(unsigned int i=0;i<humans.size();i++)    
    {
      cout<<"Human["<<humans[i].id()<<"] is carrying weapon "<<humans[i].weaponID()<<endl;
      displayWeapon(weapons[humans[i].weaponID()]);
    }
  }
  
  for(unsigned int i=0;i<humans.size();i++)
  {
    for(unsigned int m=0;m<humans[i].moves();m++)
    {
      vector<location> nearby = validMoves(humans[i].x(),humans[i].y());
      if(nearby.size()>0)
      {
        int pick = rand()%nearby.size();
        humans[i].move(nearby[pick].x,nearby[pick].y);
      }
      else
      {
        cout<<"Human["<<humans[i].id()<<"] is completely surrounded"<<endl;
      }
    }
  }
  cout<<"End Turn"<<endl;
  return true;
}
Exemplo n.º 2
0
string Room::longDescription() {
    return "room = " + description + ".\n" + displayWeapon()+ " " + displayFruit() + exitString();
}