Remove tie breaking by randomness. This caused issues with sorting.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-04-22 23:03:16 +02:00
parent 97fa37ea7d
commit 1709617e10
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
1 changed files with 3 additions and 6 deletions

View File

@ -7,10 +7,8 @@ using namespace CreatureLib;
using namespace Battling; using namespace Battling;
class ChoiceCompare { class ChoiceCompare {
Arbutils::Random& _rand;
public: public:
explicit ChoiceCompare(Arbutils::Random& rand) : _rand(rand) {} explicit ChoiceCompare() {}
bool operator()(const BaseTurnChoice* a, const BaseTurnChoice* b) { bool operator()(const BaseTurnChoice* a, const BaseTurnChoice* b) {
auto aKind = a->GetKind(); auto aKind = a->GetKind();
auto bKind = b->GetKind(); auto bKind = b->GetKind();
@ -27,11 +25,10 @@ public:
if (aSpeed != bSpeed) if (aSpeed != bSpeed)
return aSpeed > bSpeed; return aSpeed > bSpeed;
auto randomValue = _rand.Get(2); return true;
return randomValue == 0;
} }
}; };
void TurnOrdering::OrderChoices(std::vector<BaseTurnChoice*>& vec, Arbutils::Random& rand) { void TurnOrdering::OrderChoices(std::vector<BaseTurnChoice*>& vec, Arbutils::Random& rand) {
std::sort(vec.begin(), vec.end(), ChoiceCompare(rand)); std::sort(vec.begin(), vec.end(), ChoiceCompare());
} }