Class: Battle::AI::MoveHeuristicBase::HealingMoves

Inherits:
Battle::AI::MoveHeuristicBase show all
Defined in:
scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00001 MoveHeuristic/00003 HealingMoves.rb

Instance Method Summary collapse

Methods inherited from Battle::AI::MoveHeuristicBase

#ignore_effectiveness?, #ignore_power?, new, #overwrite_move_kind_flag?, register

Constructor Details

#initializeHealingMoves

Create a new Rest Heuristic



6
7
8
# File 'scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00001 MoveHeuristic/00003 HealingMoves.rb', line 6

def initialize
  super(true, true, true)
end

Instance Method Details

#compute(move, user, target, ai) ⇒ Float

Compute the heuristic

Parameters:

Returns:

  • (Float)


16
17
18
19
20
21
22
23
# File 'scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00001 MoveHeuristic/00003 HealingMoves.rb', line 16

def compute(move, user, target, ai)
  return 0 if target.effects.has?(:heal_block)
  return 0 if target.bank != user.bank
  return 0 if move.db_symbol == :heal_pulse && target.effects.has?(:substitute)
  return 0 if healing_sacrifice_clause(move, user, target, ai)

  return (1 - target.hp_rate) * 2
end

#healing_sacrifice_clause(move, user, target, ai) ⇒ Float

Test if sacrifice move should not be used

Parameters:

Returns:

  • (Float)


31
32
33
34
35
# File 'scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00001 MoveHeuristic/00003 HealingMoves.rb', line 31

def healing_sacrifice_clause(move, user, target, ai)
  return move.is_a?(Move::HealingSacrifice) &&
         ai.scene.logic.can_battler_be_replaced?(target) &&
         ai.scene.logic.allies_of(target).none? { |pokemon| pokemon.hp_rate <= 0.75 && pokemon.party_id == target.party_id }
end