mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-21 16:32:23 +00:00
added level up attack candidate move
registered move in scenario-formula.cfg and added units to test functionality
This commit is contained in:
parent
fa3393c102
commit
dc825fb3b5
22
data/ai/formula/level_up_attack_eval.fai
Normal file
22
data/ai/formula/level_up_attack_eval.fai
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
faifile 'level_up_attack_move.fat'
|
||||||
|
|
||||||
|
# Score will be the probability * 100 of attacker unit (me) killing target unit #
|
||||||
|
# (target) if attacker can level up and if the highest probable outcome #
|
||||||
|
# is attacker killing target. #
|
||||||
|
|
||||||
|
# function calc_exp returns exp gain for a kill of unit with level#
|
||||||
|
def calc_exp(level)
|
||||||
|
if(level = 0, 4, level * 8);
|
||||||
|
|
||||||
|
if(calc_exp(target.level) > (me.max_experience - me.experience),
|
||||||
|
if(battle_outcome[1].hitpoints_left[0] = 0,
|
||||||
|
if(battle_outcome[0].hitpoints_left[0] > 0,
|
||||||
|
if(max(battle_outcome[1].probability) = battle_outcome[1].probability[0],
|
||||||
|
battle_outcome[1].probability[0] / 100,
|
||||||
|
-5),
|
||||||
|
-5),
|
||||||
|
-5),
|
||||||
|
-5)
|
||||||
|
where battle_outcome = calculate_outcome(me.loc, get_best_defense_loc(my_moves.moves, me, target), target.loc)
|
||||||
|
|
||||||
|
faiend
|
16
data/ai/formula/level_up_attack_move.fai
Normal file
16
data/ai/formula/level_up_attack_move.fai
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
faifile 'level_up_attack_move.fat'
|
||||||
|
|
||||||
|
# If move is chosen, attacker (me) will attack enemy unit (target) from the hex #
|
||||||
|
# with highest defensive value. This move will only be chosen if the attacker #
|
||||||
|
# can level up with a kill of target and has a high probability of killing in #
|
||||||
|
# a single round #
|
||||||
|
|
||||||
|
# function returns best defensive loc reachable by attacker to attack enemy #
|
||||||
|
def get_best_defense_loc(moves, attacker, enemy)
|
||||||
|
choose(filter(map(filter(moves, src=attacker.loc), dst),
|
||||||
|
distance_between(self, enemy.loc) = 1),
|
||||||
|
defense_on(attacker.loc, self));
|
||||||
|
|
||||||
|
attack(me.loc, get_best_defense_loc(my_moves.moves, me, target), target.loc)
|
||||||
|
|
||||||
|
faiend
|
@ -47,8 +47,15 @@ Gs^Fp , Gs^Fp , Wwf , Wwf , Mm , Rd
|
|||||||
recruit=Dwarvish Guardsman,Dwarvish Fighter,Dwarvish Thunderer,Thief,Poacher,Footpad
|
recruit=Dwarvish Guardsman,Dwarvish Fighter,Dwarvish Thunderer,Thief,Poacher,Footpad
|
||||||
gold=100
|
gold=100
|
||||||
controller=human
|
controller=human
|
||||||
|
[unit]
|
||||||
|
x,y=10,8
|
||||||
|
type="Elvish Archer"
|
||||||
|
hitpoints=1
|
||||||
|
generate_description=yes
|
||||||
|
[/unit]
|
||||||
|
|
||||||
[/side]
|
[/side]
|
||||||
|
|
||||||
[side]
|
[side]
|
||||||
#controller=human
|
#controller=human
|
||||||
name=FormulaAI
|
name=FormulaAI
|
||||||
@ -91,17 +98,30 @@ Gs^Fp , Gs^Fp , Wwf , Wwf , Mm , Rd
|
|||||||
type="Ghost"
|
type="Ghost"
|
||||||
generate_description=yes
|
generate_description=yes
|
||||||
[/unit]
|
[/unit]
|
||||||
|
[unit]
|
||||||
|
x,y=10,6
|
||||||
|
type="Lich"
|
||||||
|
experience=149
|
||||||
|
generate_description=yes
|
||||||
|
[/unit]
|
||||||
|
|
||||||
ai_algorithm=formula_ai
|
ai_algorithm=formula_ai
|
||||||
[ai]
|
[ai]
|
||||||
eval_list=yes
|
eval_list=yes
|
||||||
[register_candidate_move]
|
[register_candidate_move]
|
||||||
name=test
|
name=scouting
|
||||||
type=test
|
type=movement
|
||||||
action="{ai/formula/scouting_move.fai}"
|
action="{ai/formula/scouting_move.fai}"
|
||||||
evaluation="{ai/formula/scouting_eval.fai}"
|
evaluation="{ai/formula/scouting_eval.fai}"
|
||||||
[/register_candidate_move]
|
[/register_candidate_move]
|
||||||
|
|
||||||
|
[register_candidate_move]
|
||||||
|
name=level_up_attack
|
||||||
|
type=attack
|
||||||
|
action="{ai/formula/level_up_attack_move.fai}"
|
||||||
|
evaluation="{ai/formula/level_up_attack_eval.fai}"
|
||||||
|
[/register_candidate_move]
|
||||||
|
|
||||||
[team_formula]
|
[team_formula]
|
||||||
rulebase="{ai/formula/opening.fai}"
|
rulebase="{ai/formula/opening.fai}"
|
||||||
[/team_formula]
|
[/team_formula]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user