separated thinking and action handling in two different loop
This commit is contained in:
parent
f762f199ca
commit
025113a218
@ -49,7 +49,7 @@ void Dude::update(BehaviorFunction func)
|
||||
{
|
||||
func(&m_action, m_memory, (Info*)this);
|
||||
m_receivedComData = false;
|
||||
memcpy(m_com_data.data, 0, COM_SIZE);
|
||||
memset(m_com_data.data, 0, COM_SIZE);
|
||||
}
|
||||
|
||||
PixelType Dude::getNear(Dir d) const
|
||||
|
@ -34,10 +34,14 @@ void Simulation::update()
|
||||
std::random_shuffle(m_dudes.begin(), m_dudes.end());
|
||||
for (unsigned int i=0; i<m_dudes.size(); ++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
|
||||
}
|
||||
|
||||
for (unsigned int i=0; i<m_dudes.size(); ++i){
|
||||
Dude *dude = m_dudes[i];
|
||||
if (dude->isAlive())
|
||||
handleAction(dude);
|
||||
}
|
||||
}
|
||||
|
||||
resolveBattles();
|
||||
|
Loading…
x
Reference in New Issue
Block a user