mail[Wesnoth-commits] r28296 - in /trunk/data: ./ ai/ ai/formula/ ai/python/ ai/python/wail/ ais/


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by dhains on August 01, 2008 - 02:39:
Author: dhains
Date: Fri Aug  1 00:42:13 2008
New Revision: 28296

URL: http://svn.gna.org/viewcvs/wesnoth?rev=28296&view=rev
Log:
reorganized directory structure for python and formula ais

Added:
    trunk/data/ai/
    trunk/data/ai/formula/
    trunk/data/ai/formula/opening.fai
    trunk/data/ai/formula/scouting_eval.fai
    trunk/data/ai/formula/scouting_move.fai
    trunk/data/ai/python/
    trunk/data/ai/python/ai_init.py
      - copied unchanged from r28295, trunk/data/ais/ai_init.py
    trunk/data/ai/python/ai_launcher.py
      - copied unchanged from r28295, trunk/data/ais/ai_launcher.py
    trunk/data/ai/python/bruteforce.py
      - copied unchanged from r28295, trunk/data/ais/bruteforce.py
    trunk/data/ai/python/bruteforce_unsafe.py
      - copied unchanged from r28295, trunk/data/ais/bruteforce_unsafe.py
    trunk/data/ai/python/bruteforce_wail.py
      - copied unchanged from r28295, trunk/data/ais/bruteforce_wail.py
    trunk/data/ai/python/documentation.py
      - copied unchanged from r28295, trunk/data/ais/documentation.py
    trunk/data/ai/python/parse.py
      - copied unchanged from r28295, trunk/data/ais/parse.py
    trunk/data/ai/python/safe.py
      - copied unchanged from r28295, trunk/data/ais/safe.py
    trunk/data/ai/python/sample.py
      - copied unchanged from r28295, trunk/data/ais/sample.py
    trunk/data/ai/python/wail/
    trunk/data/ai/python/wail/__init__.py
      - copied unchanged from r28295, trunk/data/ais/wail/__init__.py
    trunk/data/ai/python/wail/decorator.py
      - copied unchanged from r28295, trunk/data/ais/wail/decorator.py
    trunk/data/ai/python/wail/rwlock.py
      - copied unchanged from r28295, trunk/data/ais/wail/rwlock.py
    trunk/data/ai/python/wail/rwlocktest.py
      - copied unchanged from r28295, trunk/data/ais/wail/rwlocktest.py
Removed:
    trunk/data/ais/
    trunk/data/opening.fai
    trunk/data/scouting_eval.fai
    trunk/data/scouting_move.fai
Modified:
    trunk/data/scenario-formula.cfg

Added: trunk/data/ai/formula/opening.fai
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/ai/formula/opening.fai?rev=28296&view=auto
==============================================================================
--- trunk/data/ai/formula/opening.fai (added)
+++ trunk/data/ai/formula/opening.fai Fri Aug  1 00:42:13 2008
@@ -1,0 +1,114 @@
+def opening(ai*) 
+       if(turn = 1, [ 
+               recruit('Skeleton Archer', loc(11,21)),
+               recruit('Dark Adept', loc(11,22)),
+               recruit('Dark Adept', loc(10,22)),
+               recruit('Skeleton Archer', loc(9,22)),
+               recruit('Ghost', loc(11,24)),
+               move(loc(11,23), loc(14,22)) ],
+       if(turn = 2, [ 
+               move(loc(11,21),loc(13,17)),
+               if(unit_at(loc(11,22)).total_movement = 6,
+               move(loc(11,22),loc(13,18)),
+               move(loc(11,22),loc(15,19))),
+               move(loc(10,22),loc(7,19)),
+               move(loc(9,22),loc(4,22)),
+               move(loc(11,24),loc(18,24)),
+               move(loc(14,22),loc(11,23)),
+               recruit('Dark Adept', loc(11,21)),
+               recruit('Dark Adept', loc(11,22)) ],
+       if(turn = 3, [
+               move(loc(18,24),loc(20,22)),
+               move(loc(15,19),loc(17,17)),
+               move(loc(4,22),loc(5,18)),
+               recruit('Skeleton Archer', loc(11,21)) ],
+       if(turn = 4, [
+               recruit('Skeleton Archer', loc(11,21)) ],
+        []))));
+
+def rate_position_defensiveness(ai*,src,dst) 
+       units_can_reach(ai.my_moves, dst).size - 
units_can_reach(ai.enemy_moves, dst).size; 
+
+def rate_position_danger(ai*,unit,dst) 
+       (100*sum(map(units_can_reach(ai.enemy_moves, dst), 'enemy', 
max_possible_damage(enemy, unit)*defense_on(unit, dst)))) / unit.hitpoints; 
+
+def build_attacks(attack_move) 
+       if(attack_move, 
+               map(attack_move.movements, attack(src, dst, 
attack_move.target)), 
+       []); def targets(ai) 
+       ai.enemy_and_unowned_villages; 
+
+def distance_to_target(ai,dst) 
+       min(map(targets(ai), distance_between(dst, self))); 
+
+def move_to_targets(ai*) 
+       find(moves, src != my_leader.loc and rate_position_defensiveness(ai, 
src, dst) > 0)
+               where moves = sort(my_moves.moves, distance_to_target(ai, 
a.dst) < distance_to_target(ai, b.dst)); 
+
+def get_village_captures(ai) 
+       sum(map(ai.enemy_and_unowned_villages, 'village', 
map(units_can_reach(ai.my_moves, village), move(loc, village))), []); 
+
+def get_village_garrisons(ai*) 
+       sum(map(my_villages, 'village', map(units_can_reach(ai.my_moves, 
village), move(loc, village))), []); 
+
+def uncontended_captures(ai) 
+       filter(get_village_captures(ai), (src != ai.my_leader.loc) and 
(units_can_reach(ai.enemy_moves, dst).empty)); 
+
+def move_to_keep(ai*) 
+       if(keep_in_range, 
+               move(my_leader.loc, keep_in_range), 
+       null())
+               where keep_in_range = find(unit_moves(my_leader.loc), 
'moveto', find(keeps, moveto = self)); 
+
+def village_value(ai*) 400; 
+
+def rate_healing(unit*) 
+       value * ((min(max_hitpoints - hitpoints, 8)*100)/max_hitpoints); 
+
+def rate_village_garrison(ai*, move_from, village) 
+       if(find(enemy_moves, dst = village), 
+               village_value(ai), 
+       0);
+
+def rate_village_capture(ai*,src,dst) village_value(ai); 
+
+def rate_village_proximity(ai*, unit, dst) 
+       if(distance = 1, 
+               0, 
+       village_value(ai)/(distance/unit.total_movement + 1))
+               where distance = distance_to_nearest_unowned_village(dst); 
+
+def rate_move(ai*,src,dst) 
+       if(is_village(map, dst), 
+               rate_healing(u) + if(find(my_villages, self = dst), 
+                       rate_village_garrison(ai, src, dst), 
+               rate_village_capture(ai, src, dst)), 
+       rate_village_proximity(ai, u, dst)) - (danger*u.value)/2
+               where u = unit_at(src), danger = rate_position_danger(ai, 
unit_at(src), dst); 
+
+def rate_attack(ai*,attack) 
+       if(attack, 
+               (attack.chance_to_kill*attack.target_value + 
(((attack.avg_damage_inflicted*100)/unit_at(attack.target).max_hitpoints)*attack.target_value)
 + sum(map(attack.movements, rate_move(ai, src, 
dst))))/attack.movements.size, 
+       null()); 
+
+def get_best_move(ai*, candidate_moves) 
+       if(rate_attack(ai, best_attack) > 
+               if(best_move, rate_move(ai, best_move.src, 
+                       best_move.dst), 
+               0),
+        build_attacks(best_attack), 
+       [best_move])
+       where best_attack = choose(attacks, rate_attack(ai, self)),
+       best_move = choose(candidate_moves, rate_move(ai, src, dst)); 
+
+def move_leader_to_keep(ai*) 
+       if(dest, 
+               [move(my_leader.loc, dest)], 
+       [])
+               where dest = find(unit_moves(my_leader.loc), 'dst', 
find(keeps, 'keep', keep = dst)); 
+
+if(vars.turn_opening != turn, 
+       [set_var('turn_opening', turn)] + opening(self),
+if(my_leader.loc and find(keeps, self = my_leader.loc) = null(), 
+       move_leader_to_keep(self), 
+[]) + get_best_move(self, filter(my_moves.moves, src != my_leader.loc)) + [ 
recruit('Skeleton Archer', loc(11,21)), recruit('Dark Adept', loc(11,22)) ])

Added: trunk/data/ai/formula/scouting_eval.fai
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/ai/formula/scouting_eval.fai?rev=28296&view=auto
==============================================================================
--- trunk/data/ai/formula/scouting_eval.fai (added)
+++ trunk/data/ai/formula/scouting_eval.fai Fri Aug  1 00:42:13 2008
@@ -1,0 +1,8 @@
+if(size(shroud) = 0, 
+       -5,
+if(size(enemies_in_range) != 0,
+       -5,
+if(me.id='Ghost', 
+       100, 
+       -5)))
+where enemies_in_range = 
filter(unit_moves(me.loc),units_can_reach(enemy_moves, self))

Added: trunk/data/ai/formula/scouting_move.fai
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/ai/formula/scouting_move.fai?rev=28296&view=auto
==============================================================================
--- trunk/data/ai/formula/scouting_move.fai (added)
+++ trunk/data/ai/formula/scouting_move.fai Fri Aug  1 00:42:13 2008
@@ -1,0 +1,5 @@
+if(size(villages) != 0, 
+       move(me.loc, 
nearest_loc(nearest_loc(me.loc,villages),unit_moves(me.loc))),
+       move(me.loc, 
nearest_loc(nearest_loc(me.loc,shroud),unit_moves(me.loc))))
+where villages = filter(unit_moves(me.loc),is_unowned_village(map,x,y)),
+      shroud   = find_shroud()

Removed: trunk/data/opening.fai
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/opening.fai?rev=28295&view=auto
==============================================================================
--- trunk/data/opening.fai (original)
+++ trunk/data/opening.fai (removed)
@@ -1,114 +1,0 @@
-def opening(ai*) 
-       if(turn = 1, [ 
-               recruit('Skeleton Archer', loc(11,21)),
-               recruit('Dark Adept', loc(11,22)),
-               recruit('Dark Adept', loc(10,22)),
-               recruit('Skeleton Archer', loc(9,22)),
-               recruit('Ghost', loc(11,24)),
-               move(loc(11,23), loc(14,22)) ],
-       if(turn = 2, [ 
-               move(loc(11,21),loc(13,17)),
-               if(unit_at(loc(11,22)).total_movement = 6,
-               move(loc(11,22),loc(13,18)),
-               move(loc(11,22),loc(15,19))),
-               move(loc(10,22),loc(7,19)),
-               move(loc(9,22),loc(4,22)),
-               move(loc(11,24),loc(18,24)),
-               move(loc(14,22),loc(11,23)),
-               recruit('Dark Adept', loc(11,21)),
-               recruit('Dark Adept', loc(11,22)) ],
-       if(turn = 3, [
-               move(loc(18,24),loc(20,22)),
-               move(loc(15,19),loc(17,17)),
-               move(loc(4,22),loc(5,18)),
-               recruit('Skeleton Archer', loc(11,21)) ],
-       if(turn = 4, [
-               recruit('Skeleton Archer', loc(11,21)) ],
-        []))));
-
-def rate_position_defensiveness(ai*,src,dst) 
-       units_can_reach(ai.my_moves, dst).size - 
units_can_reach(ai.enemy_moves, dst).size; 
-
-def rate_position_danger(ai*,unit,dst) 
-       (100*sum(map(units_can_reach(ai.enemy_moves, dst), 'enemy', 
max_possible_damage(enemy, unit)*defense_on(unit, dst)))) / unit.hitpoints; 
-
-def build_attacks(attack_move) 
-       if(attack_move, 
-               map(attack_move.movements, attack(src, dst, 
attack_move.target)), 
-       []); def targets(ai) 
-       ai.enemy_and_unowned_villages; 
-
-def distance_to_target(ai,dst) 
-       min(map(targets(ai), distance_between(dst, self))); 
-
-def move_to_targets(ai*) 
-       find(moves, src != my_leader.loc and rate_position_defensiveness(ai, 
src, dst) > 0)
-               where moves = sort(my_moves.moves, distance_to_target(ai, 
a.dst) < distance_to_target(ai, b.dst)); 
-
-def get_village_captures(ai) 
-       sum(map(ai.enemy_and_unowned_villages, 'village', 
map(units_can_reach(ai.my_moves, village), move(loc, village))), []); 
-
-def get_village_garrisons(ai*) 
-       sum(map(my_villages, 'village', map(units_can_reach(ai.my_moves, 
village), move(loc, village))), []); 
-
-def uncontended_captures(ai) 
-       filter(get_village_captures(ai), (src != ai.my_leader.loc) and 
(units_can_reach(ai.enemy_moves, dst).empty)); 
-
-def move_to_keep(ai*) 
-       if(keep_in_range, 
-               move(my_leader.loc, keep_in_range), 
-       null())
-               where keep_in_range = find(unit_moves(my_leader.loc), 
'moveto', find(keeps, moveto = self)); 
-
-def village_value(ai*) 400; 
-
-def rate_healing(unit*) 
-       value * ((min(max_hitpoints - hitpoints, 8)*100)/max_hitpoints); 
-
-def rate_village_garrison(ai*, move_from, village) 
-       if(find(enemy_moves, dst = village), 
-               village_value(ai), 
-       0);
-
-def rate_village_capture(ai*,src,dst) village_value(ai); 
-
-def rate_village_proximity(ai*, unit, dst) 
-       if(distance = 1, 
-               0, 
-       village_value(ai)/(distance/unit.total_movement + 1))
-               where distance = distance_to_nearest_unowned_village(dst); 
-
-def rate_move(ai*,src,dst) 
-       if(is_village(map, dst), 
-               rate_healing(u) + if(find(my_villages, self = dst), 
-                       rate_village_garrison(ai, src, dst), 
-               rate_village_capture(ai, src, dst)), 
-       rate_village_proximity(ai, u, dst)) - (danger*u.value)/2
-               where u = unit_at(src), danger = rate_position_danger(ai, 
unit_at(src), dst); 
-
-def rate_attack(ai*,attack) 
-       if(attack, 
-               (attack.chance_to_kill*attack.target_value + 
(((attack.avg_damage_inflicted*100)/unit_at(attack.target).max_hitpoints)*attack.target_value)
 + sum(map(attack.movements, rate_move(ai, src, 
dst))))/attack.movements.size, 
-       null()); 
-
-def get_best_move(ai*, candidate_moves) 
-       if(rate_attack(ai, best_attack) > 
-               if(best_move, rate_move(ai, best_move.src, 
-                       best_move.dst), 
-               0),
-        build_attacks(best_attack), 
-       [best_move])
-       where best_attack = choose(attacks, rate_attack(ai, self)),
-       best_move = choose(candidate_moves, rate_move(ai, src, dst)); 
-
-def move_leader_to_keep(ai*) 
-       if(dest, 
-               [move(my_leader.loc, dest)], 
-       [])
-               where dest = find(unit_moves(my_leader.loc), 'dst', 
find(keeps, 'keep', keep = dst)); 
-
-if(vars.turn_opening != turn, 
-       [set_var('turn_opening', turn)] + opening(self),
-if(my_leader.loc and find(keeps, self = my_leader.loc) = null(), 
-       move_leader_to_keep(self), 
-[]) + get_best_move(self, filter(my_moves.moves, src != my_leader.loc)) + [ 
recruit('Skeleton Archer', loc(11,21)), recruit('Dark Adept', loc(11,22)) ])

Modified: trunk/data/scenario-formula.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/scenario-formula.cfg?rev=28296&r1=28295&r2=28296&view=diff
==============================================================================
--- trunk/data/scenario-formula.cfg (original)
+++ trunk/data/scenario-formula.cfg Fri Aug  1 00:42:13 2008
@@ -98,12 +98,12 @@
                        [register_candidate_move]
                 name=test
                 type=test
-                               action="{scouting_move.fai}"
-                evaluation="{scouting_eval.fai}"
+                               action="{ai/formula/scouting_move.fai}"
+                evaluation="{ai/formula/scouting_eval.fai}"
             [/register_candidate_move]
 
             [team_formula]
-                rulebase="{opening.fai}"
+                rulebase="{ai/formula/opening.fai}"
             [/team_formula]
         [/ai]
     [/side]

Removed: trunk/data/scouting_eval.fai
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/scouting_eval.fai?rev=28295&view=auto
==============================================================================
--- trunk/data/scouting_eval.fai (original)
+++ trunk/data/scouting_eval.fai (removed)
@@ -1,8 +1,0 @@
-if(size(shroud) = 0, 
-       -5,
-if(size(enemies_in_range) != 0,
-       -5,
-if(me.id='Ghost', 
-       100, 
-       -5)))
-where enemies_in_range = 
filter(unit_moves(me.loc),units_can_reach(enemy_moves, self))

Removed: trunk/data/scouting_move.fai
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/scouting_move.fai?rev=28295&view=auto
==============================================================================
--- trunk/data/scouting_move.fai (original)
+++ trunk/data/scouting_move.fai (removed)
@@ -1,5 +1,0 @@
-if(size(villages) != 0, 
-       move(me.loc, 
nearest_loc(nearest_loc(me.loc,villages),unit_moves(me.loc))),
-       move(me.loc, 
nearest_loc(nearest_loc(me.loc,shroud),unit_moves(me.loc))))
-where villages = filter(unit_moves(me.loc),is_unowned_village(map,x,y)),
-      shroud   = find_shroud()




Related Messages


Powered by MHonArc, Updated Sat Aug 02 07:01:41 2008