From 1da46794f74ebd8f445fcd70cbe0420eadb648e4 Mon Sep 17 00:00:00 2001 From: tom Date: Sun, 12 Feb 2017 07:57:21 -0600 Subject: -removed grouping --- src/creature.cpp | 9 ++++++--- src/list.cpp | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/creature.cpp b/src/creature.cpp index 7a86af9..0b7a438 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -14,8 +14,11 @@ Creature::Creature(Window M, SDL_Rect R, Dna D) type = CREATURE_TYPE; health = mine.maxHealth/2; gender = rand() % 2; + age = 0; + pregnancyTime = 0; able = true; pregnancyReady = false; + pregnate = false; } void Creature::Behavior() @@ -56,7 +59,8 @@ void Creature::Priority() void Creature::setTarget() { - for(std::list ::iterator it = N.begin(); it!=N.end(); it++){ + std::random_shuffle(N.begin(),N.end()); + for(std::vector ::iterator it = N.begin(); it!=N.end(); it++){ if( (*it)->getType() == RESOURCE_TYPE && hungry){ target = *it; hasTarget = true; @@ -80,12 +84,11 @@ void Creature::setTarget() void Creature::checkTarget() { - for(std::list ::iterator it = N.begin(); it!=N.end(); it++) + for(std::vector ::iterator it = N.begin(); it!=N.end(); it++) if( target == *it ) return; hasTarget = false; - return; } diff --git a/src/list.cpp b/src/list.cpp index edf3063..0439278 100644 --- a/src/list.cpp +++ b/src/list.cpp @@ -38,7 +38,7 @@ void List::Remove() void List::Behavior() { for(std::list::iterator it = C.begin(); it!=C.end(); it++){ - std::list N = getNear(*it); + std::vector N = getNear(*it); it->giveN(N); it->Behavior(); @@ -71,9 +71,9 @@ void List::Place() it->Place(); } -std::list List::getNear(Creature nC) +std::vector List::getNear(Creature nC) { - std::list N; + std::vector N; for(std::list::iterator it = R.begin(); it!=R.end(); it++) if( nC.getBestSense() > Distance(nC.getRect(),it->getRect()) ) -- cgit v1.2.3