From: colin@Cayman.COM (Colin "Atilla" Steele)
Newsgroups: rec.games.pbm
Subject: new galaxy utility
Date: 29 Aug 92 19:52:27 GMT
Distribution: rec
Organization: Cayman Systems Inc., Cambridge, MA

Below you'll find YAGU (yet another galaxy utility ;-).  This one's
called ship.pl.  It works in much the same way as the other utility I
posted.  You feed it a turn file, and it'll cough up some data about
the ships in the game.

use -a to see all ships, -o to see those owned by a particlar player.

Here's an example of the output it produces on a real turn file:

          Name  Dri Att Wea Shd Car Mass Diam  SS    AS  Move Owner
        Bosher  0   1   20  72  0   92   4.51  15.95 20  0.00  Your
    Cargo_ship  25  0   0   10  50  85   4.40  2.27  0   5.88  Marconians
      Cribbler  2   0   0   0   1   3    1.44  0.00  0   13.33 Your
      Dribbler  1   0   0   0   0   1    1.00  0.00  0   20.00 Your
         Elker  5   1   20  10  0   35   3.27  3.06  20  2.86  Your
        Ergler  2   1   10  0   0   12   2.29  0.00  10  3.33  Your
   Ergler_Plus  2   1   10  1   0   13   2.35  0.43  10  3.08  Your
       Mercury  1   0   0   0   0   1    1.00  0.00  0   20.00 Olympians
 Minuteman_III  0   1   60  12  7   79   4.29  2.80  60  0.00  Ghost_Bear
     Stingship  3   1   3   3   0   9    2.08  1.44  3   6.67  StarVampires
      dionysus  1   0   0   0   1   2    1.26  0.00  0   10.00 Olympians


The headings are pretty self-explanitory.  Here's some output from a
file of generic ship types:

          Name  Dri Att Wea Shd Car Mass Diam  SS    AS  Move Owner
AssaultFighter  4   1   1   0   0   5    1.71  0.00  1   16.00 
 BattleCruiser  30  5   6   30  0   90   4.48  6.69  30  6.67  
 BattleStation  60  4   25  100 0   260  6.38  15.67 100 4.62  
    Battleship  30  2   15  30  0   90   4.48  6.69  30  6.67  
       Cruiser  15  1   15  15  0   45   3.56  4.22  15  6.67  
     Destroyer  15  1   8   4   0   27   3.00  1.33  8   11.11 
       Fighter  1   1   1   1   0   3    1.44  0.69  1   6.67  
     Freighter  8   0   0   3   10  21   2.76  1.09  0   7.62  
       Gunship  4   2   2   4   0   12   2.29  1.75  4   6.67  
  HeavyFighter  2   1   1   2   0   5    1.71  1.17  1   8.00  
LightFreighter  8   0   0   3   5   16   2.52  1.19  0   10.00 
 MegaFreighter  80  2   2   30  100 214  5.98  5.02  4   7.48  
   OrbitalFort  0   4   25  100 0   200  5.85  17.10 100 0.00  
      SpaceGun  0   1   10  0   0   10   2.15  0.00  10  0.00  
        Trader  8   1   5   3   5   21   2.76  1.09  5   7.62  


I've found it useful for picking the right ship for the job, making
sure I'll have a well-balance fleet, and for doing comparisons against
other ships.

Once again, this's a perl utility, so see my last post or email me if
you have questions about how to get it running, or whether or not your
site has it, etc.

Enjoy.

----------------------------cut here-------------------------------------------
#!/bin/perl
#
#
###############################################################################
# SHIPS.PL
###############################################################################

require "getopts.pl";

#
# Check command line options - if no file is specified, use stdin.
#
&Getopts('af:o:');

$inGroups = 0;
undef $owner;

$FILE = $opt_f;
$OWNER = $opt_o;
$ALL = $opt_a;

(!$FILE) && ($FILE = STDIN);

if ($FILE ne "STDIN") {
		open(INFILE, "<$FILE") || die "Can't open input file $FILE: $!\n";
}

while (<INFILE>) {

		if (/\s*(\w*) Ship Types\s*/) {
				$owner = $1;
		}
		
		if (/N\s*D\s*A\s*W\s*S\s*C\s*$/) {
				if (($OWNER && ($owner eq $OWNER)) || !$OWNER || $ALL) {
						$inGroups = 1;
				}
		}
		
		if ($inGroups) {

				if (/^(\w*)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*/) {
						$shipOwner{$1} = $owner;
						$shipDrives{$1} = $2;
						$shipAttacks{$1} = $3;
						$shipWeapons{$1} = $4;
						$shipShields{$1} = $5;
						$shipCargo{$1} = $6;
						$shipMass{$1} = $2 + ($3 * $4) + $5 + $6;
						$shipMassRoot{$1} = $shipMass{$1} ** (1/3);
				}

				if (/^\s*$/) {
						$inGroups = 0;
				}
		}
}

printf "%14s  %s %s %s %s %s %s %s  %s    %s  %s %s\n",
       "Name",
       "Dri",
       "Att",
       "Wea",
       "Shd",
       "Car",
       "Mass",
       "Diam",
       "SS",
       "AS",
       "Move",
       "Owner";
for (sort keys %shipDrives) {
		if (($OWNER && ($shipOwner{$_} eq $OWNER)) ||
				(!$OWNER && ($shipOwner{$_} eq "Your")) ||
				$ALL) {
				printf "%14s  %-4d%-4d%-4d%-4d%-4d%-5d%-6.2f%-6.2f%-4d%-6.2f%s\n",
				$_,
				$shipDrives{$_},
				$shipAttacks{$_},
				$shipWeapons{$_},
				$shipShields{$_},
				$shipCargo{$_},
				$shipMass{$_},
				$shipMassRoot{$_},
				$shipShields{$_} / $shipMassRoot{$_},
				$shipAttacks{$_} * $shipWeapons{$_},
				20 * $shipDrives{$_} / $shipMass{$_},
				$shipOwner{$_};
		}
}
--


------------------------------------------------------------------------------
 Colin Steele     | Cayman Systems, 26 Landsdowne St., Cambridge, MA 02139
 colin@cayman.com | (617) 494-1916 x209 | applelink D0523 | Fax (617) 494-9270
Newsgroups: rec.games.pbm