mail[Wesnoth-commits] r28280 - in /trunk: data/scenario-formula.cfg data/scouting_eval.fai data/scouting_move.fai src/formula_ai.cpp


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

Header


Content

Posted by dhains on July 31, 2008 - 23:40:
Author: dhains
Date: Thu Jul 31 08:32:24 2008
New Revision: 28280

URL: http://svn.gna.org/viewcvs/wesnoth?rev=28280&view=rev
Log:
Broke scouting code out into fai files.
Removed hardcoded fallbacks from scouting move, incorporated into scoring of 
move.
Improved general readability.

Added:
    trunk/data/scouting_eval.fai
    trunk/data/scouting_move.fai
Modified:
    trunk/data/scenario-formula.cfg
    trunk/src/formula_ai.cpp

Modified: trunk/data/scenario-formula.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/scenario-formula.cfg?rev=28280&r1=28279&r2=28280&view=diff
==============================================================================
--- trunk/data/scenario-formula.cfg (original)
+++ trunk/data/scenario-formula.cfg Thu Jul 31 08:32:24 2008
@@ -80,25 +80,16 @@
             x,y=6,20
             type="Ghost"
             generate_description=yes
-          #  
formula="if(size(filter(unit_moves(me.loc),units_can_reach(enemy_moves, 
self))) != 0, fallback('default'), if(size(villages) != 0, move(me.loc, 
nearest_loc(nearest_loc(me.loc,villages),unit_moves(me.loc))), 
if(size(shroud) = 0, fallback('default'), 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()"
         [/unit]
                [unit]
             x,y=15,22
             type="Ghost"
             generate_description=yes
-           # 
formula="if(size(filter(unit_moves(me.loc),units_can_reach(enemy_moves, 
self))) != 0, fallback('default'), if(size(villages) != 0, move(me.loc, 
nearest_loc(nearest_loc(me.loc,villages),unit_moves(me.loc))), 
if(size(shroud) = 0, fallback('default'), 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()"
         [/unit]
                [unit]
             x,y=12,19
             type="Ghost"
             generate_description=yes
-         #   
formula="if(size(filter(unit_moves(me.loc),units_can_reach(enemy_moves, 
self))) != 0, fallback('default'), if(size(villages) != 0, move(me.loc, 
nearest_loc(nearest_loc(me.loc,villages),unit_moves(me.loc))), 
if(size(shroud) = 0, fallback('default'), 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()"
         [/unit]
 
         ai_algorithm=formula_ai
@@ -107,10 +98,8 @@
                        [register_candidate_move]
                 name=test
                 type=test
-                               
action="if(size(filter(unit_moves(me.loc),units_can_reach(enemy_moves, 
self))) != 0, fallback('default'), if(size(villages) != 0, move(me.loc, 
nearest_loc(nearest_loc(me.loc,villages),unit_moves(me.loc))), 
if(size(shroud) = 0, fallback('default'), 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()"
-                evaluation="if(me.id='Ghost', 100, -5)"
+                               action="{scouting_move.fai}"
+                evaluation="{scouting_eval.fai}"
             [/register_candidate_move]
 
             [team_formula]

Added: trunk/data/scouting_eval.fai
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/scouting_eval.fai?rev=28280&view=auto
==============================================================================
--- trunk/data/scouting_eval.fai (added)
+++ trunk/data/scouting_eval.fai Thu Jul 31 08:32:24 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/scouting_move.fai
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/scouting_move.fai?rev=28280&view=auto
==============================================================================
--- trunk/data/scouting_move.fai (added)
+++ trunk/data/scouting_move.fai Thu Jul 31 08:32:24 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()

Modified: trunk/src/formula_ai.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/formula_ai.cpp?rev=28280&r1=28279&r2=28280&view=diff
==============================================================================
--- trunk/src/formula_ai.cpp (original)
+++ trunk/src/formula_ai.cpp Thu Jul 31 08:32:24 2008
@@ -1275,8 +1275,6 @@
 
        while( best_move != candidate_moves_.end() ) {
                int best_score = (*best_move)->get_score();
-               std::cout << "size of set is " << candidate_moves_.size() << 
std::endl;
-               std::cout << "best score is " << best_score << std::endl;
                // If no evals > 0, fallback
                if(best_score < 0) {
                        ai_interface* fallback = create_ai("", get_info());
@@ -1303,7 +1301,6 @@
 
 
 void formula_ai::build_move_list() {
-       std::cout << "BUILDING MOVE LIST" << std::endl;
        candidate_moves_.clear();
        std::vector<candidate_move_ptr>::iterator itor = 
function_table.candidate_move_begin();
        for( ; itor != function_table.candidate_move_end(); ++itor) {
@@ -1369,7 +1366,6 @@
 
 bool formula_ai::make_move(game_logic::const_formula_ptr formula_, const 
game_logic::formula_callable& variables)
 {
-       std::cout << "Makin move yo" << std::endl;
        if(!formula_) {
                ai_interface* fallback = create_ai("", get_info());
                fallback->play_turn();




Related Messages


Powered by MHonArc, Updated Fri Aug 01 02:40:47 2008