Author: dhains
Date: Mon Aug 18 09:00:02 2008
New Revision: 28697
URL: http://svn.gna.org/viewcvs/wesnoth?rev=28697&view=rev
Log:
* added level up attack candidate move
* registered move in scenario-formula.cfg and added units to test functionality
Added:
trunk/data/ai/formula/level_up_attack_eval.fai
trunk/data/ai/formula/level_up_attack_move.fai
Modified:
trunk/data/scenario-formula.cfg
Added: trunk/data/ai/formula/level_up_attack_eval.fai
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/ai/formula/level_up_attack_eval.fai?rev=28697&view=auto
==============================================================================
--- trunk/data/ai/formula/level_up_attack_eval.fai (added)
+++ trunk/data/ai/formula/level_up_attack_eval.fai Mon Aug 18 09:00:02 2008
@@ -1,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
Added: trunk/data/ai/formula/level_up_attack_move.fai
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/ai/formula/level_up_attack_move.fai?rev=28697&view=auto
==============================================================================
--- trunk/data/ai/formula/level_up_attack_move.fai (added)
+++ trunk/data/ai/formula/level_up_attack_move.fai Mon Aug 18 09:00:02 2008
@@ -1,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
Modified: trunk/data/scenario-formula.cfg
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/scenario-formula.cfg?rev=28697&r1=28696&r2=28697&view=diff
==============================================================================
--- trunk/data/scenario-formula.cfg (original)
+++ trunk/data/scenario-formula.cfg Mon Aug 18 09:00:02 2008
@@ -47,8 +47,15 @@
recruit=Dwarvish Guardsman,Dwarvish Fighter,Dwarvish
Thunderer,Thief,Poacher,Footpad
gold=100
controller=human
+ [unit]
+ x,y=10,8
+ type="Elvish Archer"
+ hitpoints=1
+ generate_description=yes
+ [/unit]
+
[/side]
-
+
[side]
#controller=human
name=FormulaAI
@@ -91,15 +98,28 @@
type="Ghost"
generate_description=yes
[/unit]
-
+ [unit]
+ x,y=10,6
+ type="Lich"
+ experience=149
+ generate_description=yes
+ [/unit]
+
ai_algorithm=formula_ai
[ai]
eval_list=yes
[register_candidate_move]
- name=test
- type=test
+ name=scouting
+ type=movement
action="{ai/formula/scouting_move.fai}"
evaluation="{ai/formula/scouting_eval.fai}"
+ [/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]
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits