diff --git a/src/DepthSearchAI.hpp b/src/DepthSearchAI.hpp index f051383..b1e5d60 100644 --- a/src/DepthSearchAI.hpp +++ b/src/DepthSearchAI.hpp @@ -74,7 +74,7 @@ namespace PkmnLibAI { if (move.GetValue()->GetRemainingUses() == 0) { continue; } - threadPool.push_back(std::async([=] { + threadPool.push_back(std::async([this, battle, side, moveIndex, depth] { auto v = std::tuple(moveIndex, SimulateTurn(battle, side->GetSideIndex(), 0, moveIndex, depth)); asThreadCleanup(); return v; @@ -89,7 +89,7 @@ namespace PkmnLibAI { if (mon.GetValue()->IsFainted()) { continue; } - threadPool.push_back(std::async([=] { + threadPool.push_back(std::async([this, battle, side, i, depth] { auto v = std::tuple((u8)(i + 4), SimulateTurn(battle, side->GetSideIndex(), 0, i + 4, depth)); asThreadCleanup(); return v; @@ -141,6 +141,9 @@ namespace PkmnLibAI { auto target = GetOppositeIndex(user); if (index < 4) { auto move = user->GetMoves()[index]; + if (!move.HasValue()) { + return std::numeric_limits::min(); + } auto choice = new CreatureLib::Battling::AttackTurnChoice(user, move.GetValue(), target); if (!battle->TrySetChoice(choice)) { delete choice;