Mercurial > eagle-eye
changeset 68:4ba1e981716d
merged kevint and hychen's work.
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Wed, 22 Oct 2008 06:24:39 +0800 |
parents | 6eccb3a95df5 (diff) 19d2a7b175b3 (current diff) |
children | 7ee3a8421936 |
files | |
diffstat | 4 files changed, 102 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/README Wed Oct 22 05:57:19 2008 +0800 +++ b/README Wed Oct 22 06:24:39 2008 +0800 @@ -15,13 +15,17 @@ = HOWTO = * Install *many* perl modules. -libclass-dbi-autoloader-perl - Class::DBI::AutoLoader -libclass-dbi-perl - Class::DBI -libclass-dbi-sqlite-perl - Class::DBI::SQLite -libhtml-tagparser-perl - HTML::TagParser; -libio-compress-zlib-perl - IO::Uncompress::Gunzip -libwww-perl - LWP -libwww-mechanize-perl - WWW::Mechanize +Carp::Assert - libcarp-assert-perl +Carp::Assert::More - libcarp-assert-more-perl +Class::DBI::AutoLoader - libclass-dbi-autoloader-perl +Class::DBI - libclass-dbi-perl +Class::DBI::SQLite - libclass-dbi-sqlite-perl +Decision::ParseTree - libdecision-parsetree-perl +HTML::TagParser; - libhtml-tagparser-perl +IO::Uncompress::Gunzip - libio-compress-zlib-perl +LWP - libwww-perl +WWW::Mechanize - libwww-mechanize-perl +YAML - libyaml-perl You can download missed debian packages from http://www.assembla.com/spaces/eagle-eye/documents @@ -30,13 +34,13 @@ * Create the config file, at ${HOME}/.eagleeye.pm. The file content are package main; -$::server = 's2.ikariam.tw'; +$::server = 's4.ikariam.tw'; # Delta server. $::user = "chihchun"; $::pass = "YOUKNOW"; 1; - * Run the bot, 'perl inference.pl' - * Update the islands by runing 'perl scan.pl' + * Run the bot, 'perl agent.pl' + * Update the islands information by runing 'perl scan.pl' * List sheeps, 'perl sheep.pl'
--- a/agent.pl Wed Oct 22 05:57:19 2008 +0800 +++ b/agent.pl Wed Oct 22 06:24:39 2008 +0800 @@ -16,7 +16,7 @@ return bless $self, $class; } -sub is_Attacked { +sub is_attacked { my ($self, $city) = @_; return ($city->{force}->{attacks} > 0 ) ? 1 : 0; } @@ -123,6 +123,25 @@ 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; +} + +sub is_shipyard_level_enough { + my ($self, $city) = @_; + return 0 if(!defined($city->{building}->{shipyard})); + return ($city->{building}->{shipyard} >= 2 ? 1 : 0); + return 0; +} + sub rule_engagement { my ($self, $city) = @_; @@ -177,7 +196,7 @@ } } # Debug - print(Dumper($cities->{$cityId}->{parse_path})); + # print(Dumper($cities->{$cityId}->{parse_path})); } $i->logout;
--- a/building.yaml Wed Oct 22 05:57:19 2008 +0800 +++ b/building.yaml Wed Oct 22 06:24:39 2008 +0800 @@ -1,7 +1,7 @@ --- # 基本建設規則 # 檢查是否被攻擊 -- is_Attacked: +- is_attacked: # we are in Peace :D 0: - is_constructing: @@ -13,26 +13,23 @@ # 財富 - is_wealth_researched: 0: research_economy - 1: - # 擴張 - - is_expansion_researched: - 0: research_seafaring - 1: - # 造紙 - - is_paper_researched: - 0: research_knowledge - 1: - # 釀酒 - - is_winepress_researched: - 0: research_economy - 1: - # 正規軍 - - is_professionalarmy_researched: - 0: resaerch_military + # 擴張 + - is_expansion_researched: + 0: research_seafaring + # 造紙 + - is_paper_researched: + 0: research_knowledge + # 正規軍 + - is_professionalarmy_researched: + 0: resaerch_military + # 釀酒 + - is_winepress_researched: + 0: research_economy + # 發明 + - is_invention_researched: + 0: research_knowledge # let's find something to build up 0: - # 確認是否為主城 - # 確認是否有學院 - is_gold_enoughforcargo: 1: increaseTransporter - is_wall_enough: @@ -53,13 +50,56 @@ - is_drydock_researched: 0: resaerch_military 1: build_shipyard + # build one board - is_happiness: 0: - is_winepress_researched: - 0: research_economy + # 0: research_economy 1: build_tavern - # reduce_trvern - # 是主城, 可隨意建任一尚未搭建之建築 + + # TODO + # http://ikariam.wikia.com/wiki/List_of_buildings + # http://ikariam.wikia.com/wiki/Technology_Tree + # is_conservation_researched + # -build_warehouse + # build_academy + # build_palace (Expansion, Capital only) + # build_embassy (副城, 不建) + + - is_professionalarmy_researched: + 1: + - is_shipyard_level_enough: + - build_shipyard + - is_professionalarmy_researched: + 1: + - is_barracks_level_enough: + - build_barracks + # is_invention_researched + # biuld_workshop + # biuld_hideout + # + # build_museum + + # 皇宮 # 副城, 不建 ... # 採取防禦措施 1: run_defense + # 若軍分 0, 進行焦土政策 針對特定城市 錢全部買船 拆港 + # increaseTransporter + # destroy TradingPort + # + # 計算出兵數量、到達時間與調動時間 + # 調動軍隊防護 (加入封鎖列表) + + # (保留兵力) 出兵對方城鎮, 拆港, keep gold + # (保留兵力) 出兵任一城鎮, 拆港, keep gold + +# blocking +# 計算軍方比例 +# 對方軍分 0, # 海軍一日三次, 每次八小時 # 陸軍每日三次, 八小時一次 +# 對方平等軍分, 半夜偷襲 +# 對方高軍分 # 累積分數 +# +# balance resources +# 從其他城移動資源到特定城市 +# 預先計算可能需要的資源
--- a/sheep.pl Wed Oct 22 05:57:19 2008 +0800 +++ b/sheep.pl Wed Oct 22 06:24:39 2008 +0800 @@ -37,7 +37,7 @@ SELECT user.id FROM user, cities WHERE user.id == cities.user - AND user.trader_score_secondary >= 20 + AND user.trader_score_secondary >= 200 AND user.army_score_main <= 100 AND cities.island IN (SELECT island.id FROM island WHERE island.x <= ? AND island.x >= ? AND island.y <= ? AND island.y >= ? ) } @@ -73,18 +73,18 @@ next if($c->status eq 'v'); unless($c->status eq 'i') { - next if($members > 3); + next if($members > 5); } my $island = Ikariam::Island->retrieve($c->island); # 所得金錢 = 對方城鎮等級x(對方城鎮等級-1)x對方金錢/10000 - my $robbery = $c->citylevel * ($c->citylevel - 1) * $sheep->trader_score_secondary / 10000; + my $capture = $c->citylevel * ($c->citylevel - 1) * $sheep->trader_score_secondary / 10000; - next if($robbery < 2000); + next if($capture < 100); $line = sprintf("%d %s army %d %s/%s(%d),", - $robbery, + $capture, $c->status, $sheep->army_score_main, $sheep->name, $sheep->ally, $members); $line .= sprintf("\"%s\" %d [%d,%d] %s http://s2.ikariam.tw/index.php?view=island&id=%d&selectCity=%d\n",