# HG changeset patch # User "Rex Tsai " # Date 1234380281 -28800 # Node ID c4ef89a7412850327e2b39114dd5539c9a3f1d0d # Parent 118605b58d09f537b44aeecd5448c271a3913d01 fixed timing diff -r 118605b58d09 -r c4ef89a74128 enemy.pl --- a/enemy.pl Thu Feb 12 03:23:06 2009 +0800 +++ b/enemy.pl Thu Feb 12 03:24:41 2009 +0800 @@ -13,7 +13,7 @@ sub travelTime { my ($x1, $y1, $x2, $y2, $speed) = @_; - $speed = 20 unless(defined($speed)); + $speed = 50 unless(defined($speed)); return int( (sqrt((abs($x1 - $x2) * abs($x1 - $x2)) + (abs($y1 - $y2) * abs($y1 - $y2)))+1) * (400/$speed)); } @@ -68,7 +68,7 @@ my @cities = (); foreach (glob("city-*-dump.yaml")) { my $city = LoadFile($_); - $city->{distance} = travelTime($island->x, $island->y, $city->{island}->{x}, $city->{island}->{y}, 20); + $city->{distance} = travelTime($island->x, $island->y, $city->{island}->{x}, $city->{island}->{y}, 50); push (@cities, $city); } @cities = sort { $a->{distance} <=> $b->{distance}; } (@cities); @@ -77,10 +77,8 @@ for my $x (0..$n) { printf("%s (%d)\t- ", $cities[$x]->{name}, $cities[$x]->{id}); printf("Land %3d Ship %3d Catapult %3d Ram %3d\n", - travelTime($cities[$x]->{island}->{x}, $cities[$x]->{island}->{y}, $island->x, $island->y), - travelTime($cities[$x]->{island}->{x}, $cities[$x]->{island}->{y}, $island->x, $island->y, 8), - travelTime($cities[$x]->{island}->{x}, $cities[$x]->{island}->{y}, $island->x, $island->y, 6), - travelTime($cities[$x]->{island}->{x}, $cities[$x]->{island}->{y}, $island->x, $island->y, 10), + travelTime($cities[$x]->{island}->{x}, $cities[$x]->{island}->{y}, $island->x, $island->y, 50), + travelTime($cities[$x]->{island}->{x}, $cities[$x]->{island}->{y}, $island->x, $island->y, 33), ); } }