void Puzzle::BreedingThread() { while (true) { boost::unique_lock<boost::mutex> lock(m_pairsAccess); while(m_pairs.size() == 0) m_workerTrigger.wait(lock); std::pair<Creature*, Creature*> pair = m_pairs.front(); m_pairs.pop(); lock.unlock(); Creature* const baby = CreateBaby(pair.first, pair.second); #ifndef USE_BASELINE AddToNext(*baby); AddToNext(*pair.first); AddToNext(*pair.second); #else Creature* const baby2 = CreateBaby(pair.first, pair.second); std::array<Creature*, 4> creatures; creatures[0] = pair.first; creatures[1] = pair.second; creatures[2] = baby; creatures[3] = baby2; std::sort(creatures.begin(), creatures.end(), [](const Creature* const a, const Creature* const b) { return a->GetFitness() > b->GetFitness(); }); AddToNext(*creatures[0]); AddToNext(*creatures[1]); delete creatures[2]; delete creatures[3]; #endif { boost::unique_lock<boost::recursive_mutex> jobCountLock(m_jobCountAccess); m_jobCount--; } try { boost::this_thread::interruption_point(); } catch(boost::exception&) { return; } } }
CHumanInFarm::CHumanInFarm(void) { CreateBaby(); DeadImagePath[0] = L"wugargar/deadhuman/0.png"; DeadImagePath[1] = L"wugargar/deadhuman/1.png"; DeadImagePath[2] = L"wugargar/deadhuman/2.png"; DeadImagePath[3] = L"wugargar/deadhuman/3.png"; DeadImagePath[4] = L"wugargar/deadhuman/4.png"; DeadImagePath[5] = L"wugargar/deadhuman/5.png"; }