Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2004:
[Freeciv-Dev] Re: (PR#10722) Not enough grasslands/plains
Home

[Freeciv-Dev] Re: (PR#10722) Not enough grasslands/plains

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: mburda@xxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#10722) Not enough grasslands/plains
From: "Mike Jing" <miky40@xxxxxxxxxxx>
Date: Tue, 9 Nov 2004 19:03:33 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=10722 >

Here it is then:

[code]
#!/usr/bin/perl -w

if (@ARGV) {
    $savegame = $ARGV[0];
}
else {
    $savegame = 'civgame-4000m.sav';
}

open(SAVE, $savegame) or die "$savegame not found.\nUsage: $0 [ savegame 
(gunzipped) ]\n";
while (<SAVE>) {
    if (/^t\d+="([\s\w]+)"/) {
        $line = $1;
        @terrains = split //, $line;
        foreach $terrain (@terrains) {
            $count{$terrain}++;
            $map++
        }
    }
}

$land = $map - $count{" "};
foreach $terrain (sort keys %count) {
    unless ($terrain eq " ") {
        $percent = 100*$count{$terrain}/$land;
        print $terrain, " = ";
        printf "%2.1f", $percent;
        print "%\n";
        $total += $percent;
    }
}

print "sum = $total% \n";
print "land tiles = $land \n";
print "total tiles = $map \n";
[/code]

----Original Message Follows----
From: "Marcelo Burda" <mburda@xxxxxxxxx>
Reply-To: rt@xxxxxxxxxxx
To: miky40@xxxxxxxxxxx
Subject: Re: (PR#10722) Not enough grasslands/plains
Date: Mon, 8 Nov 2004 23:06:38 -0800


<URL: http://rt.freeciv.org/Ticket/Display.html?id=10722 >

Le lundi 08 novembre 2004 à 20:42 -0800, Mike Jing a écrit :
 > I simply used a perl script to count the number of different terrain
 > tiles from save games and calculate the percentages.
 >
 > Mike Jing
 >
i think Mateusz want you to post this script !

Marcelo






[Prev in Thread] Current Thread [Next in Thread]