changeset 137:362184763c04

added comments and added new research (greek fire)
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Fri, 31 Oct 2008 02:21:05 +0800
parents 4374173bab47
children 454657d0308f
files agent.pl city.yaml overall.yaml
diffstat 3 files changed, 29 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/agent.pl	Fri Oct 31 00:20:41 2008 +0800
+++ b/agent.pl	Fri Oct 31 02:21:05 2008 +0800
@@ -37,10 +37,11 @@
 
 sub is_space_enough {
     my ($self, $city) = @_;
-    # TODO 應該以消耗率/時間計算
-    # $self->{ikariam}->{growth}
+    # The maximum town hall is level 20, then we build new town
     return 1 if($city->{buildings}->{townHall} >= 20);
-    return ($city->{space}->{total} <= ($city->{space}->{occupied}+6) ?  0 : 1)
+    # TODO 應該以 成長率 * 升級所需時間計算
+    # 6 hours earlier, we upgrade the twonHall.
+    return ($city->{space}->{total} <= ($city->{space}->{occupied} + ($city->{growth}*6)) ?  0 : 1)
 }
 
 sub is_corruption {
@@ -51,7 +52,16 @@
 sub is_happiness {
     my ($self, $city) = @_;
     # TODO 以 fuzzy 取出合理 happiness 值
-    return ($city->{happiness} >= 2 ?  1 : 0)
+
+    # we should update the travl
+    # return ($city->{growth} >= 5 ?  1 : 0) 
+    #    if($city->{buildings}->{townHall} <= 10);
+
+    return 0;
+ 
+    # FIXME.
+    # we should update the tavern setting.
+    # return ($city->{happiness} >= 2 ?  1 : 0);
 }
 
 sub is_warehouse_enough {
@@ -66,7 +76,6 @@
     # 
     # 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)
@@ -143,6 +152,11 @@
     return (defined($self->{'ikariam'}->{research}->{4010}) ?  1 : 0);
 }
 
+sub is_greekfire_researched {
+    my ($self) = @_;
+    return (defined($self->{'ikariam'}->{research}->{6077}) ?  1 : 0);
+}
+
 sub is_barracks_level_enough {
     my ($self, $city) = @_;
     return 0 if(!defined($city->{buildings}->{barracks}));
@@ -226,6 +240,7 @@
 
 our $i = new Ikariam($::server, $::user, $::pass);
 $i->login;
+$i->checkMilitaryAdvisorCombatReports();
 my $cities = $i->check;
 
 # Genereic rules for both overall and city level arranagement.
@@ -237,7 +252,7 @@
 $decision->{parse_answer} = undef;
 my $action = ParseTree($tree, $rules, $decision);
 triggerAction($action, (keys(%$cities))[0]) if(defined($action));
-print STDERR Dump($decision) if(defined($verbose));
+# print STDERR Dump($decision) if(defined($verbose));
 
 # show cities.
 foreach my $cityId (keys(%$cities)) {
--- a/city.yaml	Fri Oct 31 00:20:41 2008 +0800
+++ b/city.yaml	Fri Oct 31 02:21:05 2008 +0800
@@ -1,7 +1,7 @@
 ---
 # city level
 # 基本建設規則
-# 若糟攻擊則暫停建設
+# 若遭受攻擊則暫停建設
 - is_attacked:
     # we are in Peace :D
     0:
@@ -24,19 +24,17 @@
                0: build_warehouse
             - is_happiness:
                0: 
-                  - is_space_enough:
-                     0: 
-                        - is_winepress_researched:
-                           1: build_tavern
+                  - is_winepress_researched:
+                     # FIXME: we should update the tavern setting.
+                     1: build_tavern
             # TODO
             # http://ikariam.wikia.com/wiki/List_of_buildings
             # http://ikariam.wikia.com/wiki/Technology_Tree
             # is_conservation_researched
-            #    -build_warehouse
+            # -build_warehouse
             # build_academy
             # build_palace (Expansion, Capital only)
             # build_embassy (副城, 不建)
-
             - is_risk:
                1: 
                   - is_professionalarmy_researched:
@@ -50,10 +48,8 @@
                         - is_drydock_researched: 
                            # requireed more army ?
                            1: build_shipyard
-
+                  #    - build one boat
 # 應該把 Barracks 建到最佳等級
-# 1:
-#    - build one board
             # 要蓋到何種程度?
             # is_invention_researched
             #    1: 
--- a/overall.yaml	Fri Oct 31 00:20:41 2008 +0800
+++ b/overall.yaml	Fri Oct 31 02:21:05 2008 +0800
@@ -26,13 +26,7 @@
      - is_culturalexchange_researched:
         0: research_seafaring
      # 希臘火, 建造噴火船
-
-     # is_reousrce_balanced.
-        # 酒館
-        # 學院
-     # balance resources
-     # 從其他城移動資源到特定城市
-     # 預先計算可能需要的資源
-   # let's find something to build up
+     - is_greekfire_researched:
+        0: research_seafaring
    1: run_defence
    # we are being attacked!!!!!!!!!!!!!