Article View: net.games.emp
Article #25New famine checker.
From: utzoodecvaxharpodukeuncmp
Date: Wed, 19 May 1982 16:48
Date: Wed, 19 May 1982 16:48
54 lines
1606 bytes
1606 bytes
#! /bin/sh
:
:
: shell script that if run on a census report will print
: the census report with
:
: 1 the total population in that sector
:
: 2 the minimum amount of food for that sector for a day
:
: 3 an asterisk at the end of the line if that sector is too low
:
: 4 a < at the end of the line if sector not self-sustaining in food
:
: based on duke!decvax!ucbvax!ucsfcgl!sdcarl!rusty Thu May 13 18:39:30 1982
: M. Pique version 2. Handles checkpointed and defended sectors.
: Defaults to reading file 'census' in current directory
if test $# -lt 1
then
if test -r census
then
exec $0 census
else
echo "usage: $0 census1 census2 ..."
exit 1
fi
fi
for file
do
awk ' / sect / { print $0 " pop minf warn" ;next }
NF>11{ # non-header non-trailer lines:
cfield= NF-6 # field giving number of civilians
civ = $(cfield)
mil = $(cfield+1)
food = $(cfield+2)
fert = $(cfield+5)
pop = civ + mil
minf = pop * 0.048
if ( minf < 1 )
minf = 1
if ( food < minf ) warn = "*"
else warn = " "
if( mil > 1.66 * civ || pop > 2*fert ) alert = "<"
else alert = " "
printf "%s %3d %4.0f %s%s\n", $0, pop, minf, warn, alert
next
}
{ print $0;next }
END { print " * -- low food reserves < -- not self-sustaining"}
' $file
done
Technical Details
Message-ID:
<bnews.unc.3446>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
From: utzoo!decvax!harpo!duke!unc!mp Newsgroups: net.games.emp Title: New famine checker. Article-I.D.: unc.3446 Posted: Wed May 19 16:48:06 1982 Received: Thu May 20 03:31:23 1982 Subject: New famine checker. Date: Wed, 19 May 1982 16:48:06 +0000 Message-ID: <bnews.unc.3446>