wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth/src ai.cpp ai.hpp ai_attack.cpp campaig...


From: David White
Subject: [Wesnoth-cvs-commits] wesnoth/src ai.cpp ai.hpp ai_attack.cpp campaig...
Date: Sun, 19 Sep 2004 16:48:53 -0400

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     David White <address@hidden>    04/09/19 20:42:35

Modified files:
        src            : ai.cpp ai.hpp ai_attack.cpp 
        src/campaign_server: campaign_server.cpp 

Log message:
        added new AI parameter: attack_depth

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/ai.cpp.diff?tr1=1.116&tr2=1.117&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/ai.hpp.diff?tr1=1.55&tr2=1.56&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/ai_attack.cpp.diff?tr1=1.49&tr2=1.50&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/campaign_server/campaign_server.cpp.diff?tr1=1.4&tr2=1.5&r1=text&r2=text

Patches:
Index: wesnoth/src/ai.cpp
diff -u wesnoth/src/ai.cpp:1.116 wesnoth/src/ai.cpp:1.117
--- wesnoth/src/ai.cpp:1.116    Sun Sep 19 11:30:23 2004
+++ wesnoth/src/ai.cpp  Sun Sep 19 20:42:35 2004
@@ -1,4 +1,4 @@
-/* $Id: ai.cpp,v 1.116 2004/09/19 11:30:23 silene Exp $ */
+/* $Id: ai.cpp,v 1.117 2004/09/19 20:42:35 Sirp Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -197,7 +197,7 @@
           : ai_interface(info), threats_found_(false), disp_(info.disp),
             map_(info.map), gameinfo_(info.gameinfo), units_(info.units),
             teams_(info.teams), team_num_(info.team_num),
-            state_(info.state), consider_combat_(true)
+            state_(info.state), consider_combat_(true), attack_depth_(0)
 {}
 
 bool ai::recruit_usage(const std::string& usage)
@@ -1979,3 +1979,14 @@
 
        return avoid_;
 }
+
+int ai::attack_depth() const
+{
+       if(attack_depth_ > 0) {
+               return attack_depth_;
+       }
+
+       const config& parms = current_team().ai_parameters();
+       attack_depth_ = 
maximum<int>(1,lexical_cast_default<int>(parms["attack_depth"],4));
+       return attack_depth_;
+}
Index: wesnoth/src/ai.hpp
diff -u wesnoth/src/ai.hpp:1.55 wesnoth/src/ai.hpp:1.56
--- wesnoth/src/ai.hpp:1.55     Sat Sep 18 21:27:39 2004
+++ wesnoth/src/ai.hpp  Sun Sep 19 20:42:35 2004
@@ -1,4 +1,4 @@
-/* $Id: ai.hpp,v 1.55 2004/09/18 21:27:39 silene Exp $ */
+/* $Id: ai.hpp,v 1.56 2004/09/19 20:42:35 Sirp Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -260,6 +260,9 @@
        const std::set<location>& avoided_locations() const;
 
        mutable std::set<location> avoid_;
+
+       int attack_depth() const;
+       mutable int attack_depth_;
 };
 
 #endif
Index: wesnoth/src/ai_attack.cpp
diff -u wesnoth/src/ai_attack.cpp:1.49 wesnoth/src/ai_attack.cpp:1.50
--- wesnoth/src/ai_attack.cpp:1.49      Sat Sep 18 21:27:39 2004
+++ wesnoth/src/ai_attack.cpp   Sun Sep 19 20:42:35 2004
@@ -1,4 +1,4 @@
-/* $Id: ai_attack.cpp,v 1.49 2004/09/18 21:27:39 silene Exp $ */
+/* $Id: ai_attack.cpp,v 1.50 2004/09/19 20:42:35 Sirp Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -43,7 +43,7 @@
        //this function is called fairly frequently, so interact with the user 
here.
        user_interact();
 
-       if(cur_analysis.movements.size() > 4)
+       if(cur_analysis.movements.size() > size_t(attack_depth()))
                return;
 
        static double best_results[6];
Index: wesnoth/src/campaign_server/campaign_server.cpp
diff -u wesnoth/src/campaign_server/campaign_server.cpp:1.4 
wesnoth/src/campaign_server/campaign_server.cpp:1.5
--- wesnoth/src/campaign_server/campaign_server.cpp:1.4 Sun Sep 19 05:48:18 2004
+++ wesnoth/src/campaign_server/campaign_server.cpp     Sun Sep 19 20:42:35 2004
@@ -50,8 +50,13 @@
 
 void campaign_server::run()
 {
-       for(;;) {
+       for(int increment = 0; ; ++increment) {
                try {
+                       //write config to disk every ten minutes
+                       if((increment%(60*10*2)) == 0) {
+                               write_file(file_,cfg_.write());
+                       }
+
                        network::process_send_queue();
 
                        network::connection sock = network::accept_connection();
@@ -132,7 +137,7 @@
                        std::cerr << "error in receiving data...\n";
                }
 
-               SDL_Delay(20);
+               SDL_Delay(500);
        }
 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]