Class: Battle::AI::MoveHeuristicBase
- Defined in:
- scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00001 MoveHeuristic/00001 MoveHeuristicBase.rb,
scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00001 MoveHeuristic/00002 Rest.rb,
scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00001 MoveHeuristic/00004 CuringMoves.rb,
scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00001 MoveHeuristic/00003 HealingMoves.rb,
scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00001 MoveHeuristic/00005 ReflectMoves.rb
Overview
Class responsive of handling the heuristics of moves
Direct Known Subclasses
Defined Under Namespace
Classes: CuringMove, HealingMoves, ReflectMoves, Rest
Class Method Summary collapse
-
.new(db_symbol, level) ⇒ MoveHeuristicBase
Get a MoveHeuristic by db_symbol and level.
-
.register(db_symbol, klass, min_level = 0)
Register a new move heuristic.
Instance Method Summary collapse
-
#compute(move, user, target, ai) ⇒ Float
Compute the heuristic.
-
#ignore_effectiveness? ⇒ Boolean
Is this heuristic ignoring effectiveness.
-
#ignore_power? ⇒ Boolean
Is this heuristic ignoring power.
-
#initialize(ignore_effectiveness = false, ignore_power = false, overwrite_move_kind_flag = false) ⇒ MoveHeuristicBase
constructor
Create a new MoveHeusristicBase.
-
#overwrite_move_kind_flag? ⇒ Boolean
Is this heuristic ignoring power.
Constructor Details
#initialize(ignore_effectiveness = false, ignore_power = false, overwrite_move_kind_flag = false) ⇒ MoveHeuristicBase
Create a new MoveHeusristicBase
12 13 14 15 16 |
# File 'scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00001 MoveHeuristic/00001 MoveHeuristicBase.rb', line 12 def initialize(ignore_effectiveness = false, ignore_power = false, overwrite_move_kind_flag = false) @ignore_effectiveness = ignore_effectiveness @ignore_power = ignore_power @overwrite_move_kind_flag = overwrite_move_kind_flag end |
Class Method Details
.new(db_symbol, level) ⇒ MoveHeuristicBase
Get a MoveHeuristic by db_symbol and level
65 66 67 68 69 70 71 |
# File 'scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00001 MoveHeuristic/00001 MoveHeuristicBase.rb', line 65 def new(db_symbol, level) klass = @move_heuristics[db_symbol]&.find { |entry| entry[:min_level] <= level } klass = klass ? klass[:klass] : self heuristic = klass.allocate heuristic.send(:initialize) return heuristic end |
.register(db_symbol, klass, min_level = 0)
Note:
If there's several min_level, the highest condition matching with current AI level is choosen.
Register a new move heuristic
54 55 56 57 58 59 |
# File 'scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00001 MoveHeuristic/00001 MoveHeuristicBase.rb', line 54 def register(db_symbol, klass, min_level = 0) @move_heuristics[db_symbol] ||= [] @move_heuristics[db_symbol].delete_if { |entry| entry[:min_level] == min_level } @move_heuristics[db_symbol] << { min_level: min_level, klass: klass } if klass @move_heuristics[db_symbol].sort_by! { |entry| -entry[:min_level] } # This will help to fetch the first min level matching with .find end |
Instance Method Details
#compute(move, user, target, ai) ⇒ Float
Compute the heuristic
42 43 44 45 46 |
# File 'scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00001 MoveHeuristic/00001 MoveHeuristicBase.rb', line 42 def compute(move, user, target, ai) return 1.0 if move.status? return Math.sqrt(move.special? ? user.ats_basis / target.dfs_basis.to_f : user.atk_basis / target.dfe_basis.to_f) end |
#ignore_effectiveness? ⇒ Boolean
Is this heuristic ignoring effectiveness
20 21 22 |
# File 'scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00001 MoveHeuristic/00001 MoveHeuristicBase.rb', line 20 def ignore_effectiveness? return @ignore_effectiveness end |
#ignore_power? ⇒ Boolean
Is this heuristic ignoring power
26 27 28 |
# File 'scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00001 MoveHeuristic/00001 MoveHeuristicBase.rb', line 26 def ignore_power? return @ignore_power end |
#overwrite_move_kind_flag? ⇒ Boolean
Is this heuristic ignoring power
32 33 34 |
# File 'scripts/01600 Alpha 25 Battle Engine/08000 Battle_AI/00001 MoveHeuristic/00001 MoveHeuristicBase.rb', line 32 def overwrite_move_kind_flag? return @overwrite_move_kind_flag end |