diff agent.pl @ 74:27b16506231f

improved the tech trees
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Wed, 22 Oct 2008 20:49:29 +0800
parents 2af91e80353e
children 9d92e8c12f58
line wrap: on
line diff
--- a/agent.pl	Wed Oct 22 06:49:42 2008 +0800
+++ b/agent.pl	Wed Oct 22 20:49:29 2008 +0800
@@ -28,7 +28,7 @@
 
 sub is_wall_enough {
     my ($self, $city) = @_;
-    # TODO 應該以防禦力計算
+    # http://ikariam.wikia.com/wiki/Wall_Defense
     return ($city->{buildings}->{wall} >= $city->{buildings}->{townHall} ?  1 : 0);
 }
 
@@ -52,13 +52,19 @@
 sub is_warehouse_enough {
     my ($self, $city) = @_;
     # TODO 以速率計算容納率
-    # XXX: not implemented yet.
     return 1;
 }
 
 sub is_risk {
     my ($self, $city) = @_;
     # TODO 計算可搶劫比例, 城牆防護, 軍事分數
+    # 
+    # my $capture = $city->{buildings}->{townHall} * ($city->{buildings}->{townHall} - 1) * $city->{resource}->gold / 10000;
+    # 計算軍人消耗
+    #
+    # 方陣兵, 1.58 軍分, 24 維護費
+    # 劍士, 4.64 軍分, 16 維護費
+    # army_score_main > (occupied * 0.3)
     return 0;
 }
 
@@ -91,14 +97,19 @@
     return (defined($city->{research}->{1030}) ?  1 : 0);
 }
 
+sub is_culturalexchange_researched {
+    my ($self, $city) = @_;
+    return (defined($city->{research}->{1040}) ?  1 : 0);
+}
+
 sub is_wealth_researched {
     my ($self, $city) = @_;
     return (defined($city->{research}->{2030}) ?  1 : 0);
 }
 
-sub is_professionalarmy_researched {
+sub is_winepress_researched {
     my ($self, $city) = @_;
-    return (defined($city->{research}->{4030}) ?  1 : 0);
+    return (defined($city->{research}->{2040}) ?  1 : 0);
 }
 
 sub is_paper_researched {
@@ -106,31 +117,39 @@
     return (defined($city->{research}->{3020}) ?  1 : 0);
 }
 
+sub is_espionage_researched {
+    my ($self, $city) = @_;
+    return (defined($city->{research}->{3030}) ?  1 : 0);
+}
+
+sub is_invention_researched {
+    my ($self, $city) = @_;
+    return (defined($city->{research}->{3040}) ?  1 : 0);
+}
+
+sub is_professionalarmy_researched {
+    my ($self, $city) = @_;
+    return (defined($city->{research}->{4030}) ?  1 : 0);
+}
+
 sub is_drydock_researched {
     my ($self, $city) = @_;
     return (defined($city->{research}->{4010}) ?  1 : 0);
 }
 
-sub is_winepress_researched {
-    my ($self, $city) = @_;
-    return (defined($city->{research}->{2040}) ?  1 : 0);
-}
-
-sub is_invention_researched {
-    my ($self, $city) = @_;
-    return (defined($city->{research}->{3040}) ?  1 : 0);
-}
-
 sub is_barracks_level_enough {
     my ($self, $city) = @_;
-    return 0 if(!defined($city->{building}->{barracks}));
-    return ($city->{building}->{barracks} >= 3 ? 1 : 0);
+    return 0 if(!defined($city->{buildings}->{barracks}));
+    # 方陣兵需要 level 4
+    # optimum is 5
+    return ($city->{buildings}->{barracks} >= 3 ? 1 : 0);
 }
 
 sub is_shipyard_level_enough {
     my ($self, $city) = @_;
-    return 0 if(!defined($city->{building}->{shipyard}));
-    return ($city->{building}->{shipyard} >= 2 ? 1 : 0);
+    return 0 if(!defined($city->{buildings}->{shipyard}));
+    # optimum is 5
+    return ($city->{buildings}->{shipyard} >= 3 ? 1 : 0);
     return 0;
 }