added a very basic poison handling.
This is a proof of concept to be improved on. Patch by Velory
This commit is contained in:
parent
01de0050e6
commit
a81013ff9d
6 changed files with 194 additions and 0 deletions
|
@ -20,6 +20,8 @@ Version 1.7.0-svn:
|
|||
* FormulaAI:
|
||||
* Fixed bug #13230: added debug_float FormulaAI function to allow debugging
|
||||
via floating popups on the specified hex
|
||||
* Added run_file FormulaAI function to allow running .fai scripts directly
|
||||
from in-game console
|
||||
* WML Engine:
|
||||
* Added [show_objectives] tag (part of bug #13042)
|
||||
* Made moveto events set $x2,$y2 to the source hex. (bug #13140)
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
{scenario-test.cfg}
|
||||
{scenario-formula.cfg}
|
||||
{scenario-formula-recruitment.cfg}
|
||||
{scenario-poisoning.cfg}
|
||||
[textdomain]
|
||||
name="wesnoth"
|
||||
[/textdomain]
|
||||
|
|
13
data/ai/formula/poisoner_attack.fai
Normal file
13
data/ai/formula/poisoner_attack.fai
Normal file
|
@ -0,0 +1,13 @@
|
|||
fai 'poisoner_attack.fai'
|
||||
|
||||
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, att_weap)
|
||||
|
||||
|
||||
where att_weap = index_of(['poison'],map(me.attacks,special))
|
||||
|
||||
faiend
|
17
data/ai/formula/poisoner_eval.fai
Normal file
17
data/ai/formula/poisoner_eval.fai
Normal file
|
@ -0,0 +1,17 @@
|
|||
fai 'poisoner_eval.fai'
|
||||
|
||||
if(filter(me.attacks,'att',filter(att.special,'spe',contains_string(spe,'poison'))),
|
||||
if(target.undead = 0,
|
||||
if(target.hitpoints >= 5,
|
||||
if(target.max_experience - target.experience > 8,
|
||||
if(index_of('regenerates',target.abilities) = -1,
|
||||
if(index_of('poisoned',keys(target.states)) = -1, 1
|
||||
,-1)
|
||||
,-1)
|
||||
,-1)
|
||||
,-1)
|
||||
,-1)
|
||||
,-1)
|
||||
|
||||
|
||||
faiend
|
|
@ -755,6 +755,11 @@
|
|||
name = "Ben Anderman (crimson_penguin)"
|
||||
comment = "unit list"
|
||||
[/entry]
|
||||
[entry]
|
||||
name = "Burkay Özdemir (Velory)"
|
||||
comment = "Poisoning improvement for Formula AI"
|
||||
[/entry]
|
||||
|
||||
[entry]
|
||||
name = "Chris Hopman (cjhopman)"
|
||||
[/entry]
|
||||
|
|
156
data/scenario-poisoning.cfg
Normal file
156
data/scenario-poisoning.cfg
Normal file
|
@ -0,0 +1,156 @@
|
|||
#textdomain wesnoth
|
||||
# @file data/scenario-test.cfg
|
||||
|
||||
[test]
|
||||
name="Test scenario"
|
||||
map_data=" border_size=1
|
||||
usage=map
|
||||
|
||||
Hh , Hh , Gg , Wwf , Wwf , Gs^Fp , Mm , Hh , Gg , Gs^Fp , Gg , Hh , Gg , Mm , Hh , Mm , Wwf , Wwf , Hh , Gs^Fp , Hh , Mm , Mm
|
||||
Hh , Hh , Gg^Ve , Wwf , Wwf , Gs^Fp , Mm , Hh , Gg , Gs^Fp , Gg , Hh , Gg , Mm , Hh , Mm , Wwf , Wwf , Hh , Gs^Fp , Hh , Mm , Mm
|
||||
Wwf , Wwf , Wwf , Wwf , Gg , Wwf , Wwf , Hh , Gg , Gg , Wwf , Ch , Wwf , Gs^Fp , Wwf , Wwf , Re , Re , Hh , Mm , Wwf , Mm , Mm
|
||||
Mm , Mm , Wwf , Gs^Fp , Gg^Vh , Wwf , Gg , Gg , Wwf , Wwf , Wwf , 1 Kh , Ch , Wwf , Re , Re , Rd , Rd , Wwf , Wwf , Gs^Fp , Wwf , Wwf
|
||||
Wwf , Wwf , Mm , Wwf , Gs^Fp , Wwf , Wwf , Wwf , Gg^Vh , Gg , Wwf , Ch , Wwf , Ch , Rd , Rd , Wwf , Wwf , Gg^Vh , Gs^Fp , Re^Gvs , Hh , Hh
|
||||
Hh , Hh , Wwf , Gs^Fp , Wwf , Wwf , Gg , Gg , Gg , Gg , Wwf , Ch , Gg , Wwf , Wwf , Wwf , Mm , Gs^Fp , Re , Re^Gvs , Gg^Wm , Re^Gvs , Re^Gvs
|
||||
Wwf , Wwf , Mm , Wwf , Hh , Gs^Fp , Rd , Rd , Gg , Gg , Wwf , Wwf , Gs^Fp , Gg , Hh , Gg , Re , Re , Rd , Rd , Gg , Hh , Hh
|
||||
Hh , Hh , Gs^Fp , Gg , Gg , Rd , Gg , Gg , Wwf , Wwf , Gs^Fp , Wwf , Gs^Fp , Mm , Re , Re , Rd , Rd , Gg , Ggf , Mm , Gs^Fp , Gs^Fp
|
||||
Gs^Fp , Gs^Fp , Gg , Gg , Wwf , Gg , Wwf , Wwf , Mm , Hh , Wwf , Wwf , Re , Re , Rd , Rd , Rd , Gg , Gs^Fp , Gs^Fp , Gs^Fp , Hh , Hh
|
||||
Hh , Hh , Wwf , Wwf , Hh , Wwf , Gg , Gg , Gg , Gg , Wwf , Re , Re , Rd , Gg , Gg , Gg , Gg^Vh , Hh , Gg , Wwf , Ggf , Ggf
|
||||
Wwf , Wwf , Hh , Ggf , Gs^Fp , Hh^Vhh , Gg , Gg , Gg , Ss^Vhs , Hh , Ww , Gs^Fp , Gg , Gs^Fp , Hh , Wwf , Wwf , Wwf , Wwf , Gg , Wwf , Wwf
|
||||
Hh , Hh , Gg , Gg , Re , Gg , Re , Re , Gg , Ss , Gs^Fp , Ww , Hh , Mm , Ww , Wwf , Gg , Gg , Ds , Gg , Gg , Gs^Fp , Gs^Fp
|
||||
Gs^Fp , Gs^Fp , Gg , Rd , Rd , Re , Rd , Re , Hh , Mm , Wwf , Ww , Ww , Ww , Gg , Gg , Hh , Gs^Fp , Rd , Rd , Hh , Gg , Gg
|
||||
Rd , Rd , Gs^Fp , Hh , Rd , Rd , Gs^Fp , Re , Gg , Gg , Wwf , Gg , Wwf , Gg , Gg , Re , Gs^Fp , Hh , Rd , Mm , Gs^Fp , Rd , Rd
|
||||
Rd , Rd , Hh , Mm , Rd , Hh , Hh , Re , Gg , Gg , Ww , Gg , Wwf , Gg , Hh , Re , Rd , Rd , Rd , Hh , Gg , Rd , Rd
|
||||
Gg , Gg , Gg , Rd , Ds , Gs^Fp , Gg , Gg , Ww , Ww , Hh , Ww , Gs^Fp , Mm , Gg , Re , Re , Re , Re , Rd , Gg , Gs^Fp , Gs^Fp
|
||||
Gs^Fp , Gs^Fp , Gg , Gg , Wwf , Gg , Wwf , Wwf , Gs^Fp , Mm , Gs^Fp , Ww , Hh , Ss , Gg , Re , Gg , Gg , Gs^Fp , Gg , Hh , Hh , Hh
|
||||
Wwf , Wwf , Wwf , Wwf , Hh , Wwf , Gg , Hh , Gg , Gg , Re , Ww , Wwf , Ss^Vhs , Gg , Gg , Gg , Hh^Vhh , Hh , Ggf , Wwf , Wwf , Wwf
|
||||
Ggf , Ggf , Gs^Fp , Gg , Gs^Fp , Gg^Vh , Rd , Gg , Rd , Rd , Re , Re , Wwf , Gg , Mm , Gg , Wwf , Wwf , Wwf , Wwf , Gg , Mm , Mm
|
||||
Hh , Hh , Mm , Gs^Fp , Gg , Gg , Rd , Rd , Re , Re , Gs^Fp , Wwf , Gs^Fp , Hh , Wwf , Wwf , Gg , Gg , Gg , Gg , Gs^Fp , Gs^Fp , Gs^Fp
|
||||
Gs^Fp , Gs^Fp , Gg , Ggf , Rd , Rd , Re , Re , Hh , Mm , Gg , Wwf , Wwf , Wwf , Gg , Gg , Rd , Rd , Hh , Gg , Mm , Hh , Hh
|
||||
Hh , Hh , Gg^Wm , Rd , Re , Re , Mm , Gg , Wwf , Wwf , Wwf , Ch , Gg , Gg , Gg , Rd , Gg , Gs^Fp , Wwf , Wwf , Wwf , Wwf , Wwf
|
||||
Re^Gvs , Re^Gvs , Re^Gvs , Re^Gvs , Gg^Vh , Gs^Fp , Wwf , Wwf , Rd , Ch , Ch , Ch , Gg , Gg , Gg^Vh , Gg , Wwf , Wwf , Gs^Fp , Gs^Fp , Gg^Ve , Gg , Gg
|
||||
Hh , Hh , Gs^Fp , Gs^Fp , Wwf , Wwf , Rd , Rd , Re , Re , Wwf , 2 Kh , Wwf , Gg , Wwf , Wwf , Gg , Wwf , Wwf , Wwf , Wwf , Gs^Fp , Gs^Fp
|
||||
Gs^Fp , Gs^Fp , Wwf , Wwf , Mm , Rd , Gs^Fp , Hh , Wwf , Wwf , Gg , Ch , Gg , Wwf , Hh , Gg , Wwf , Wwf , Gg^Vh , Gg , Wwf , Mm , Mm
|
||||
Gs^Fp , Gs^Fp , Wwf , Wwf , Mm , Rd , Gs^Fp , Wwf , Wwf , Gg , Gg , Gg , Gg , Gg , Hh , Gg , Wwf , Wwf , Gg , Gg , Wwf , Mm , Mm
|
||||
"
|
||||
|
||||
turns=90
|
||||
id=poison
|
||||
|
||||
{DEFAULT_SCHEDULE}
|
||||
|
||||
[label]
|
||||
x,y=3,8
|
||||
text="Target Choose test"
|
||||
[/label]
|
||||
[label]
|
||||
x,y=17,3
|
||||
text="Weapon test with low hp target"
|
||||
[/label]
|
||||
[label]
|
||||
x,y=13,8
|
||||
text="Regeneration attack Test"
|
||||
[/label]
|
||||
[label]
|
||||
x,y=7,3
|
||||
text="Undead Target Test"
|
||||
[/label]
|
||||
|
||||
[side]
|
||||
name="Azalin"
|
||||
type=Necromancer
|
||||
id=side_1_leader
|
||||
canrecruit=yes
|
||||
recruit=Assassin,Thief,Poacher,Footpad
|
||||
gold=90
|
||||
controller=human
|
||||
|
||||
[unit]
|
||||
x,y=13,8
|
||||
type="Ancient Wose"
|
||||
generate_name=yes
|
||||
[/unit]
|
||||
[unit]
|
||||
x,y=3,7
|
||||
type="Arch Mage"
|
||||
generate_name=yes
|
||||
[/unit]
|
||||
[unit]
|
||||
x,y=2,7
|
||||
type="Elvish Archer"
|
||||
generate_name=yes
|
||||
[/unit]
|
||||
[unit]
|
||||
x,y=16,5
|
||||
type="Elvish Archer"
|
||||
generate_name=yes
|
||||
[/unit]
|
||||
[unit]
|
||||
x,y=2,8
|
||||
type="Elvish Archer"
|
||||
generate_name=yes
|
||||
[/unit]
|
||||
[unit]
|
||||
x,y=17,2
|
||||
type="Elvish Fighter"
|
||||
hitpoints=3
|
||||
generate_nema=yes
|
||||
[/unit]
|
||||
[unit]
|
||||
x,y=7,2
|
||||
type="Skeleton"
|
||||
generate_name=yes
|
||||
[/unit]
|
||||
[/side]
|
||||
|
||||
[side]
|
||||
name=FormulaAı
|
||||
type=Dark Sorcerer
|
||||
side=2
|
||||
canrecruit=yes
|
||||
recruit=Skeleton,Skeleton Archer,Ghost,Ghost,Vampire Bat,Vampire Bat,Ghoul
|
||||
gold=100
|
||||
shroud=yes
|
||||
|
||||
[unit]
|
||||
x,y=5,8
|
||||
type="Ghoul"
|
||||
generate_name=yes
|
||||
[/unit]
|
||||
[unit]
|
||||
x,y=6,9
|
||||
type="Cuttle Fish"
|
||||
generate_name=yes
|
||||
[/unit]
|
||||
[unit]
|
||||
x,y=13,7
|
||||
type="Cuttle Fish"
|
||||
generate_name=yes
|
||||
[/unit]
|
||||
[unit]
|
||||
x,y=17,3
|
||||
type="Cuttle Fish"
|
||||
generate_name=yes
|
||||
[/unit]
|
||||
[unit]
|
||||
x,y=7,3
|
||||
type="Ghoul"
|
||||
generate_name=yes
|
||||
[/unit]
|
||||
|
||||
ai_algorithm=formula_ai
|
||||
[ai]
|
||||
eval_list=yes
|
||||
|
||||
[register_candidate_move]
|
||||
name=poisoner
|
||||
type=attack
|
||||
evaluation="{ai/formula/poisoner_eval.fai}"
|
||||
action="{ai/formula/poisoner_attack.fai}"
|
||||
[/register_candidate_move]
|
||||
|
||||
[/ai]
|
||||
[/side]
|
||||
[/test]
|
||||
|
||||
# vim: tabstop=4: shiftwidth=4: expandtab: softtabstop=4: autoindent:
|
Loading…
Add table
Reference in a new issue