Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 63 lines (58 sloc) 1.512 kb
4126d8e improvements
Bernhard M. Wiedemann authored
1 my %rentability=qw"hf 0.9 rf 1.7 gc 1 rl 0.7 sb 0.4";
2 my %max=qw(hf 13 rf 13 gc 99 rl 13 sb 0);
3 #my %rentability=qw"hf 1.2 rf 1.5 gc 1 rl 0.8 sb 0.0004";
9a1100b initial checkin
Bernhard M. Wiedemann authored
4 #my %rentability=qw"hf 0.9 rf 1 gc 1 rl 1 sb 1";
5
6 # returns value>0
7 sub rentability($$){my ($p,$building)=@_;
4126d8e improvements
Bernhard M. Wiedemann authored
8 my $rf=$$p{"rf"};
9 my $result=$rentability{$building};
22c272b assume eog = end of game after max(6000,$turns)
Bernhard M. Wiedemann authored
10 my $eog=6000;
11 if($options{turns}>$eog) {$eog=$options{turns}}
4126d8e improvements
Bernhard M. Wiedemann authored
12 if($$p{$building}>=$max{$building}) {return 0.00001}
9a1100b initial checkin
Bernhard M. Wiedemann authored
13 if($building eq "gc") {
4126d8e improvements
Bernhard M. Wiedemann authored
14 $result+=$rf/15;
9a1100b initial checkin
Bernhard M. Wiedemann authored
15 }
4126d8e improvements
Bernhard M. Wiedemann authored
16 if($building eq "rl") {
17 $result+=$rf/35;
18 }
19 if($building eq "rl" and $rf<6) {return 0.0001}
20 if($building eq "rf" or $building eq "rl") {
22c272b assume eog = end of game after max(6000,$turns)
Bernhard M. Wiedemann authored
21 if(buildcost($$p{$building})*$updatetime>$eog-$turn) { return 0.0001; }
4126d8e improvements
Bernhard M. Wiedemann authored
22 }
23 return $result;
9a1100b initial checkin
Bernhard M. Wiedemann authored
24 }
25
26 sub findtarget($) { my($p)=@_;
27 my ($min,$mint);
28 for my $t(@buildings) {
4126d8e improvements
Bernhard M. Wiedemann authored
29 if($$p{$t}>=$max{$t}){next}
30 my $val=buildcost($$p{$t})/rentability($p,$t);
9a1100b initial checkin
Bernhard M. Wiedemann authored
31 # print "$t:$val ";
32 if(!defined($min) || $val<$min) {
33 $min=$val;
34 $mint=$t;
35 }
36 }
37 # print "$mint:$min\n";
38 return $mint;
39 }
40
41 sub spend1()
42 {
43 foreach my $p (@planet) {
4126d8e improvements
Bernhard M. Wiedemann authored
44 # my $val=$$p{rf}+$$p{pop};
45 if(int($player{cul})>@planet) {
46 my $n=@planet;
47 $planet[0]{pp}-=60;
48 initplanet(\%{$planet[$n]});
49 if($planet[0]{pp}>0) {
50 my $rate=1.0-$n*0.05;
51 if($rate<0.2) {$rate=0.2}
52 $planet[$n]{pp}=$planet[0]{pp}*$rate;
53 $planet[0]{pp}=0;
54 }
55 }
9a1100b initial checkin
Bernhard M. Wiedemann authored
56 do {
57 $target=findtarget($p);
4126d8e improvements
Bernhard M. Wiedemann authored
58 } while(defined($target) && build($p,$target,0));
9a1100b initial checkin
Bernhard M. Wiedemann authored
59 }
60 }
61
62 1;
Something went wrong with that request. Please try again.