diff agent.pl @ 232:978a949602e5

Auto-update Scientists numbers for Academy. Refined the rules for safehouse, the safe house must be same or higher level then Town Hall. Make people very happy, when the townHall is less then 16. Build museum first then tavern THG: changed warfare.pl
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Thu, 06 Nov 2008 20:31:05 +0800
parents f6836ef11203
children b7ea7c43dbad
line wrap: on
line diff
--- a/agent.pl	Wed Nov 05 03:08:16 2008 +0800
+++ b/agent.pl	Thu Nov 06 20:31:05 2008 +0800
@@ -63,7 +63,16 @@
 sub is_safehouse_enough {
     my ($self, $city) = @_;
     return 0 if(!defined($city->{buildings}->{safehouse}));
-    return (($city->{buildings}->{townHall} <= ($city->{buildings}->{safehouse} + 4)) ? 0 : 1);
+
+    # build the higgest safehouse.
+    # maybe we should have more then 4 towns, then we consider that we should upgrade safehouse at level 20.
+    # return (($city->{buildings}->{townHall} > $city->{buildings}->{safehouse}) ? 0 : 1) 
+        # if($$city->{buildings}->{townHall} >= 20);
+    # return (($city->{buildings}->{townHall} <= ($city->{buildings}->{safehouse} + 4)) ? 0 : 1);
+
+    # Safehouse must be same level as townHall,
+    # Maybe one level higher is better.
+    return (($city->{buildings}->{townHall} > $city->{buildings}->{safehouse}) ? 0 : 1);
 }
 
 sub is_warehouse_enough {
@@ -107,7 +116,7 @@
     my ($self, $city) = @_;
 
     return ($city->{growth} >= 5 ?  1 : 0) 
-        if($city->{buildings}->{townHall} <= 10);
+        if($city->{buildings}->{townHall} <= 16);
 
     return 1 if($city->{buildings}->{townHall} >= 20);
  
@@ -379,6 +388,9 @@
  
     # build spy
     $i->buildSpy('spy', $cityId);
+    # enlarge the scientist number.
+    $i->set("academy", $cityId);
+    $i->set("tavern", $cityId);
 
     # build military!
     $tree  = LoadFile('military.yaml');