Updates PkmnLib
This commit is contained in:
parent
a5d49d7aa4
commit
f5b438f38a
|
@ -68,7 +68,10 @@ namespace PkmnLibAI {
|
|||
auto side = user->GetBattleSide().GetValue();
|
||||
for (u8 moveIndex = 0; moveIndex < (u8)user->GetMoves().Count(); ++moveIndex) {
|
||||
auto move = user->GetMoves()[moveIndex];
|
||||
if (move->GetRemainingUses() == 0) {
|
||||
if (!move.HasValue()) {
|
||||
continue;
|
||||
}
|
||||
if (move.GetValue()->GetRemainingUses() == 0) {
|
||||
continue;
|
||||
}
|
||||
threadPool.push_back(std::async([=] {
|
||||
|
@ -105,7 +108,11 @@ namespace PkmnLibAI {
|
|||
auto side = user->GetBattleSide().GetValue();
|
||||
for (u8 moveIndex = 0; moveIndex < (u8)user->GetMoves().Count(); ++moveIndex) {
|
||||
auto move = user->GetMoves()[moveIndex];
|
||||
if (move->GetRemainingUses() == 0) {
|
||||
if (!move.HasValue()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (move.GetValue()->GetRemainingUses() == 0) {
|
||||
continue;
|
||||
}
|
||||
auto scored = SimulateTurn(battle, side->GetSideIndex(), 0, moveIndex, depth);
|
||||
|
@ -134,7 +141,7 @@ namespace PkmnLibAI {
|
|||
auto target = GetOppositeIndex(user);
|
||||
if (index < 4) {
|
||||
auto move = user->GetMoves()[index];
|
||||
auto choice = new CreatureLib::Battling::AttackTurnChoice(user, move, target);
|
||||
auto choice = new CreatureLib::Battling::AttackTurnChoice(user, move.GetValue(), target);
|
||||
if (!battle->TrySetChoice(choice)) {
|
||||
delete choice;
|
||||
return std::numeric_limits<float>::min();
|
||||
|
@ -197,7 +204,7 @@ namespace PkmnLibAI {
|
|||
}
|
||||
|
||||
if (highest < 4) {
|
||||
return new CreatureLib::Battling::AttackTurnChoice(user, user->GetMoves()[highest], target);
|
||||
return new CreatureLib::Battling::AttackTurnChoice(user, user->GetMoves()[highest].GetValue(), target);
|
||||
} else {
|
||||
return new CreatureLib::Battling::SwitchTurnChoice(user, party.At(highest - 4));
|
||||
}
|
||||
|
|
|
@ -15,11 +15,14 @@ namespace PkmnLibAI {
|
|||
auto highestScore = -1;
|
||||
PkmnLib::Battling::LearnedMove* bestMove;
|
||||
for (auto move : user->GetMoves()) {
|
||||
if (move->GetRemainingUses() <= 0)
|
||||
if (!move.HasValue()) {
|
||||
continue;
|
||||
auto naiveDamage =
|
||||
move->GetMoveData()->GetBasePower() * battle->GetLibrary()->GetTypeLibrary()->GetEffectiveness(
|
||||
move->GetMoveData()->GetType(), c->GetTypes());
|
||||
}
|
||||
if (move.GetValue()->GetRemainingUses() <= 0)
|
||||
continue;
|
||||
auto naiveDamage = move.GetValue()->GetMoveData()->GetBasePower() *
|
||||
battle->GetLibrary()->GetTypeLibrary()->GetEffectiveness(
|
||||
move.GetValue()->GetMoveData()->GetType(), c->GetTypes());
|
||||
if (naiveDamage > highestScore) {
|
||||
highestScore = naiveDamage;
|
||||
bestMove = move;
|
||||
|
|
|
@ -17,8 +17,11 @@ namespace PkmnLibAI {
|
|||
auto moves = user->GetMoves();
|
||||
ArbUt::List<PkmnLib::Battling::LearnedMove*> validMoves;
|
||||
for (auto move : moves) {
|
||||
if (move->GetRemainingUses() > 0) {
|
||||
validMoves.Append(move);
|
||||
if (!move.HasValue()) {
|
||||
continue;
|
||||
}
|
||||
if (move.GetValue()->GetRemainingUses() > 0) {
|
||||
validMoves.Append(move.GetValue());
|
||||
}
|
||||
}
|
||||
auto target = GetOppositeIndex(user);
|
||||
|
|
Loading…
Reference in New Issue