small changes in simulation

This commit is contained in:
Lendemor 2016-06-04 13:35:19 +02:00
parent 8deedd9098
commit f762f199ca
3 changed files with 4 additions and 4 deletions

View File

@ -2,7 +2,7 @@
#include "map.h" #include "map.h"
#include <cstring> #include <cstring>
Dude::Dude(const Coord &_pos, Map *_map, int &_team) : Dude::Dude(const Coord &_pos, Map *_map, const int &_team) :
m_pos(_pos), m_pos(_pos),
p_map(_map), p_map(_map),
m_team(_team), m_team(_team),

View File

@ -20,7 +20,7 @@ private:
int m_underResCount; int m_underResCount;
public: public:
Dude(const Coord &_pos, Map *_map, int &_team); Dude(const Coord &_pos, Map *_map, const int &_team);
//general use functions //general use functions
void update(BehaviorFunction func); void update(BehaviorFunction func);
const Action& getAction() { return m_action; } const Action& getAction() { return m_action; }

View File

@ -32,7 +32,7 @@ Simulation::~Simulation()
void Simulation::update() void Simulation::update()
{ {
std::random_shuffle(m_dudes.begin(), m_dudes.end()); std::random_shuffle(m_dudes.begin(), m_dudes.end());
for (int i=0; i<m_dudes.size(); ++i){ for (unsigned int i=0; i<m_dudes.size(); ++i){
Dude *dude = m_dudes[i]; Dude *dude = m_dudes[i];
if (dude->isAlive()){ if (dude->isAlive()){
m_teams[dude->getTeam()].update(dude); //get action for this dude from behavior function in team m_teams[dude->getTeam()].update(dude); //get action for this dude from behavior function in team
@ -43,7 +43,7 @@ void Simulation::update()
resolveBattles(); resolveBattles();
// for each team, spawn dude if condition met // for each team, spawn dude if condition met
for(int i=0; i<m_teams.size(); ++i){ for(unsigned int i=0; i<m_teams.size(); ++i){
Team &t = m_teams[i]; Team &t = m_teams[i];
if(t.updateSpawn()) if(t.updateSpawn())
{ {