Path: utzoo!hoptoad!amdahl!chuck From: chuck@amdahl.uts.amdahl.com (Charles Simmons) Newsgroups: alt.sources Subject: empire sources (part 5 of 6) Message-ID: <27523@amdahl.uts.amdahl.com> Date: 11 Apr 88 01:01:13 GMT Distribution: alt Organization: Amdahl Corporation, Sunnyvale CA Lines: 1536 # This is a shell archive. Remove anything before this line, then # unpack it by saving it in a file and typing "sh file". (Files # unpacked will be owned by you and have default permissions.) # # This archive contains: # empire.6 util.c data.c COPYING echo x - empire.6 sed -e 's/^X//' > "empire.6" << '//E*O*F empire.6//' X.\" %W% %G% %U% - (c) Copyright 1987, 1988 Chuck Simmons */ X.\" X.\" Copyright (C) 1987, 1988 Chuck Simmons X.\" X.\" See the file COPYING, distributed with empire, for restriction X.\" and warranty information. X.\" X.TH Empire 6 X.SH NAME Xempire -- the wargame of the century X.SH SYNOPSIS Xempire [-w water] [-s smooth] [-d delay] X.SH DESCRIPTION XEmpire is a simulation of a full-scale war between two Xemperors, the computer and you. Naturally, there is only Xroom for one, so the object of the game is to destroy Xthe other. The computer plays by the same rules that you Xdo. X.TP 10 X.BI \-w water\^ XThis option controls the amount of water on the map. XThis is given as the percentage of the map which should Xbe water. The default is 70% water. \f2water\fP Xmust be an integer in the between 10 and 90 inclusive. X.TP X.BI \-s smooth\^ XThis controls the smoothness of the map. A low value Xwill produce a highly chaotic map with lots of small Xislands or lakes. A high value will produce a map Xwith a few scattered continents. Be forewarned that Xa high value will cause the program to take a long Xtime to start up. The default value is 5. X.TP X.BI \-d delay\^ XThis option controls the length of time the computer will Xdelay after printing informational messages at the top of Xthe screen. \f2delay\fP is specified in milliseconds. The Xdefault value is 2000 which allows the user two seconds to Xread a message. X.SH EXAMPLES Xempire -w90 -s2 X.P XThis produces a map with many islands. X.P Xempire -w50 -s0 X.P XThis produces a really strange map. These values Xare not recommended for the faint at heart. X.P Xempire -w10 X.P XThis produces a map with lots of land and a few lakes. XThe computer will have a hard time on this sort of map Xas it will try and produce lots of troop transports, Xwhich are fairly useless. X.SH INTRODUCTION XEmpire is a war game played between you and the user. The world Xon which the game takes place is a square rectangle containing cities, Xland, and water. Cities are used to build armies, planes, and ships Xwhich can move across the world destroying enemy pieces, exploring, Xand capturing more cities. The objective of the game is to destroy Xall the enemy pieces, and capture all the cities. X.P XThe world is a rectangle 60 by 100 squares on a side. The world Xconsists of sea (.), land (+), uncontrolled Xcities (*), computer-controlled cities (X), and cities that you Xcontrol (O). X.P XThe world is displayed on the player's screen during Xmovement. (On terminals with small screens, only a portion of Xthe world is shown at any one time.) XEach piece is represented by a unique Xcharacter on the map. With a few exceptions, you can Xonly have one piece on a given location. On the map, you Xare shown only the 8 squares adjacent to your units. XThis information is updated before and during each of your moves. XThe map displays the most recent information known. X.P XThe game starts by assigning you one city and the Xcomputer one city. Cities can produce new pieces. Every Xcity that you own produces more pieces for you according Xto the cost of the desired piece. The typical play of the Xgame is to issue the Automove command until you decide Xto do something special. During movement in each round, Xthe player is prompted to move each piece that does not Xotherwise have an assigned function. X.P XMap coordinates are 4-digit numbers. The first two Xdigits are the row, the second two digits are the Xcolumn. X.SH PIECES XThe pieces are as follows: X.P X.TS Xcenter box tab(;); Xl | c | c | r | r | r | c. XPiece;You;Enemy;Moves;Hits;Str;Cost X_ XArmy;A;a;1;1;1;5(6) XFighter;F;f;8;1;1;10(12) XPatrol Boat;P;p;4;1;1;15(18) XDestroyer;D;d;2;3;1;20(24) XSubmarine;S;s;2;2;3;20(24) XTroop Transport;T;t;2;1;1;30(36) XAircraft Carrier;C;c;2;8;1;30(36) XBattleship;B;b;2;10;2;40(48) XSatellite;Z;z;10;--;--;50(60) X.TE X.P XThe second column shows the map representation for your Xunits. X.P XThe third shows the representations of enemy units. X.P XMoves is the number of squares that the unit can move in a Xsingle round. X.P XHits is the amount of damage a unit can take before it Xis destroyed. X.P XStrength is the amount of damage a unit can inflict upon an Xenemy during each round of an attack. X.P XCost is the number of rounds needed for a city to produce Xthe piece. X.P XThe number in parenthesis is the cost for a city to Xproduce the first unit. X.P XEach piece has certain advantages associated with it that Xcan make it useful. One of the primary strategic aspects Xof this game is deciding which pieces will be produced Xand in what quantities. X.P X\f3Armies\f1 can only move on land, and are the only piece that can Xmove on land. Only armies can capture cities. XThis means that you must produce armies in order to win the Xgame. Armies have a 50% chance of capturing a city when they Xattack. (Attacking one's own city results in the army's Xdestruction. Armies that move onto the sea will drown. XArmies can attack objects at sea, but even if they win, they Xwill drown.) Armies can be carried by troop transports. XIf an army is moved onto a troop transport, then whenever Xthe transport is moved, the army will be moved with the Xtransport. You cannot attack any piece at sea while on a Xtransport. X.P X\f3Fighters\f1 move over both land and sea, and they move 8 squares Xper round. Their high speed and great mobility make fighters Xideal for exploring. However, fighters must periodically land Xat user-owned cities for refueling. A fighter can travel 32 Xsquares without refeuling. Fighters are also shot down if they Xattempt to fly over a city which is not owned by the user. X.P X\f3Patrol boats\f1 are fast but lightly armored. Therefore Xthey are useful for patrolling ocean waters and exploring. XIn an attack against a stronger boat, however, patrol boats Xwill suffer heavy casulties. X.P X\f3Destroyers\f1 are fairly heavily armored and reasonably quick Xto produce. Thus they are useful for destroying enemy transports Xwhich may be trying to spread the enemy across the face of the Xworld. X.P XWhen a \f3submarine\f1 scores a hit, 3 hits are exacted instead of 1. XThus submarines can inflict heavy damage in a fight against Xheavily armored boats. Notice that healthy submarines will Xtypically defeat healthy destroyers two-thirds of the time. XHowever, a submarine will defeat a fighter about two-thirds Xof the time, while a destroyer will defeat a fighter three-fourths Xof the time. X.P X\f3Troop transports\f1 are the only pieces that can carry armies. XA maximum of six armies can be carried by a transport. XOn any world containing a reasonable amount of water, Xtransports will be a critical resource in winning the game. XNotice that the weakness of transports implies they need Xprotection from stronger ships. X.P X\f3Aircraft carriers\f1 are the only ships that can Xcarry fighters. Carriers carry a maximum of the number Xof hits left of fighters. Fighters are refueled when they Xland on a carrier. X.P X\f3Battleships\f1 are similar to destroyers except that they are Xmuch stronger. X.P X\f3Satellites\f1 are only useful for reconaissance. They can not Xbe attacked. They are launched in a random diagonal orbit, and Xstay up for 50 turns. They can see one square farther than other Xobjects. X.P XAll ships can move only on sea. Ships can also dock in a Xuser-owned city. Docked ships have damage repaired at the Xrate of 1 hit per turn. Ships which have suffered a lot Xof damage will move more slowly. X.P XBecause of their ability Xto be repaired, ships with lots of hits such as Carriers and XBattleships have an additional advantage. XAfter suffering minor damage while destroying enemy shipping, Xthese ships can sail back to port and be quickly repaired before Xthe enemy has time to replenish her destroyed shipping. X.P XThe following table gives the probability that the piece listed Xon the side will defeat the piece listed at the top in a battle. X(The table assumes that both pieces are undamaged.) X.P X.TS Xcenter box tab(;); Xl | c | c | c | c | c | c | c | c. X;A;F;P;D;S;T;C;B X_ XA;50%;50%;50%;25%;33%;50%;13%;10% XF;50%;50%;50%;25%;33%;50%;13%;10% XP;50%;50%;50%;25%;33%;50%;13%;10% XD;75%;75%;75%;50%;33%;75%;27%;17% XS;67%;67%;67%;67%;50%;67%;40%;20% XT;50%;50%;50%;25%;33%;50%;13%;10% XC;88%;88%;88%;73%;60%;88%;50%;29% XB;90%;90%;90%;84%;80%;90%;71%;50% X.TE X.P XNotice, however, that when a ship has been damaged, the odds of Xbeing defeated can go up quite a bit. For example, a healthy Xsubmarine has a 25% chance of defeating a battleship that has Xhad one hit of damage done to it, and a healthy submarine has Xa 50% chance of defeating a carrier which has suffered two hits Xof damage. X.SH "MOVEMENT FUNCTIONS" XThere are a variety of movement functions. The movement functions Xof pieces can be specified in user mode and edit mode. XCities can have movement functions set for each type of piece. XWhen a movement function for a type of pieces is set for a city, Xthen every time that type of piece appears in the city, the piece Xwill acquire that movement function. Be forewarned that moving Xloaded transports or loaded carriers into a city can have undesirable Xside effects. X.P XNormally, when a movement Xfunction has been specified, the piece will continue moving according to Xthat function until one of the following happen: X.TP 5 X.B * XAn enemy piece or unowned city appears next to the piece. In this case Xthe piece will be completely awoken, unless its movement function has Xbeen set to a specific destination. XArmies on ships and pieces inside Xcities will not be awoken if the enemy piece is gone by the time it is Xtheir turn to move. X.TP X.B * XYou explicitly awaken the piece. X.TP X.B * XThe piece can no longer move in accordance with its programmed function. XIn this case, the piece will awaken \f2temporarily\fP. You will be asked Xto move the piece at which time you may awaken it. X.TP X.B * XThe piece is a fighter which has just enough fuel (plus a small reserve) Xto get to the nearest city. XIn this case, Xthe piece will awaken completely, unless its movement function has Xbeen set to a specific destination, or its movement function has been Xset to \f2land\fP. X.P XThe rationale behind this complexity is that fighters must be awoken Xcompletely before they are out of range of a city Xto prevent one from accidentally forgetting to waken the Xfighter and then watching it fly off to its doom. However, it is presumed Xthat when a path is set for the fighter, the fighter is not in danger of Xrunning out of fuel. X.P XPieces do not completely awaken when their function has been set to a Xdestination because it is slightly time consuming to reset the destination, Xbut very simple (one keystroke) to wake the piece. X.P XThe movement functions are: X.TP 10 X.B Attack XThis function applies only to armies. When this function is set, Xthe army will move toward the nearest enemy city, unowned city, or Xenemy army. This is useful when fighting off an invading enemy or Xtaking over a new continent. When an army is set to this mode, Xit will also explore nearby territory. This tends to make Xthe "grope" movement mode pretty useless. X.TP X.B Awake XWhen pieces are awake, you will be asked for the direction in which Xthe piece should move on each turn. X.TP X.B Fill XThis function applies to carriers and transports. When this function is Xspecified, these ships sleep until they have been filled with fighters or Xarmies respectively. X.TP X.B Grope XThis function causes a piece to explore. The piece heads toward the nearest Xunseen square of the map on each of its moves. Some attempt is made to Xexplore in an optimal fashion. X.TP X.B Land XThis function applies to fighters and causes the fighter to head toward Xthe nearest transport or carrier. X.TP X.B Random XThis movement function causes a piece to move at random to an adjacent Xempty square. X.TP X.B Sentry XThis movement function puts a piece to sleep. XThe function of a city cannot be set to 'sleep'. X.TP X.B Transport XThis movement function only works on armies. The army sleeps until Xan unfull transport passes by, at which point the army wakes up and Xboards the transport. X.TP X.B Upgrade XThis movement function only works with ships. The ship will move Xto the nearest owned city and remain there until it is repaired. X.TP X.B XPieces can be set to move in a specified direction. X.TP X.B XPieces can be set to move toward a specified square. In this movement Xmode, pieces take a shortest path toward the destination. Pieces moving Xin accordance with this function prefer diagonal moves that explore Xterritory. Because of this, the movement of the piece may be Xnon-intuitive. X.P XAs examples of how to use these movement functions, typically Xwhen I have a new city on a continent, I set the Army function of the Xcity to \f2attack\f1. Whenever an army is produced, it merrily goes off Xon its way exploring the continent and moving towards unowned cities Xor enemy armies or cities. X.P XI frequently set the ship functions for cities that are far from the Xfront to automatically move ships towards the front. X.P XWhen I have armies on a continent, but there is nothing to explore Xor attack, I move the army to the shore and use the \f2transport\f1 Xfunction to have that army hop aboard the first passing transport. X.SH COMMANDS XThere are three command modes. The first of these is "command mode". XIn this mode, you give commands that affect the game as a whole. XIn the second mode, "move mode", you give commands to move your Xpieces. The third mode is "edit mode", and in this mode you can Xedit the functions of your pieces and examine various portions of Xthe map. X.P XAll commands are one character long. The full mnemonic names are Xlisted below as a memorization aid. XThe mnemonics are somewhat contrived because there are so few Xcharacters in the English language. Too bad this program isn't Xwritten in Japanese, neh? X.P XIn all command modes, typing "H" will print out a screen of help Xinformation, and typing will redraw the screen. X.P X.SH COMMAND MODE XIn command mode, the computer will prompt you for your orders. XThe following commands can be given at this time: X.TP 10 X.B Automove XEnter automove mode. This command begins a new round of movement. XYou will remain in move mode after each of the computer's turns. X(In move mode, the "O" command will return you to command mode Xafter the computer finishes its next turn. X.TP X.B City XGive the computer a random unowned city. This command is useful if you Xfind that the computer is getting too easy to beat. X.TP X.B Date XThe current round is displayed. X.TP X.B Examine XExamine the enemy's map. This command is only valid after the computer Xhas resigned. X.TP X.B File XPrint a copy of the map to the specified file. X.TP X.B Give XThis command gives the computer a free move. X.TP X.B J XEnter edit mode where you can examine and change the functions Xassociated with your pieces and cities. X.TP X.B Move XEnter move mode for a single round. X.TP X.B N XGive the computer the number of free moves you specify. X.TP X.B Print XDisplay a sector on the screen. X.TP X.B Quit XQuit the game. (Note that your game will be saved in 'empsave.dat' Xafter each command you give, and after each move you make.) X.TP X.B Restore XRestore the game from empsave.dat. (Currently, this command is useless Xsince the game is restored when the program first starts up, and the Xgame is saved after each move.) X.TP X.B Save XSave the game in empsave.dat. (Currently, this command is useless Xsince the game is saved after each of your commands and after each move.) X.TP X.B Trace XThis command toggles a flag. When the flag is set, Xafter each move, either yours or the computer's, Xa picture of the world is written out to the file X'empmovie.dat'. \f3Watch out! This command produces lots of Xoutput.\f1 X.TP X.B Watch XThis command allows you to watch a saved movie. XThe movie is displayed in a condensed version so that Xit will fit on a single screen, so the output may be Xa little confusing. This command is only legal if the Xcomputer resigns. If you lose the game, you cannot replay Xa movie to learn the secrets of how the computer beat you. XNor can you replay a movie to find out the current positions Xof the computer's pieces. When replaying a movie, it is Xrecommended that you use the \f2-d\f1 option to set the delay Xto around 2000 milliseconds or so. Otherwise the screen will be Xupdated too quickly for you to really grasp what is going on. X.TP X.B Zoom XDisplay a condensed version of the map on the screen. The user map is Xdivided into small rectangles. Each rectangle is displayed as one square Xon the screen. If there is a city in a rectangle, then it Xis displayed. Otherwise enemy pieces are displayed, then user pieces, Xthen land, then water, and then unexplored territory. When pieces are Xdisplayed, ships are preferred to fighters and armies. X.SH MOVE MODE XIn move mode, the cursor will appear on the screen at the position Xof each piece that needs to be moved. You can then give commands Xto move the piece. Directions to move are specified by the Xfollowing keys: X.P X.fp 5 TT X.ft 5 X.nf X QWE X A D X ZXC X.fi X.ft 1 X.P XThese keys move in the direction of the key from S. The Xcharacters are not echoed and only 1 character is Xaccepted, so there is no need for a . Hit the Xbar if you want the piece to stay put. X.P XOther commands are: X.TP 10 X.B Build XChange the production of a city. X.TP X.B Fill XSet the function of a troop transport or aircraft carrier to X\f2fill\f1. X.TP X.B Grope XSet the function of a piece to \f2grope\f1. X.TP X.BI I dir XSet the direction for a piece to move. X.TP X.B J XEnter edit mode. X.TP X.B Kill XWake up the piece. If the piece is a transport or carrier, Xpieces on board will not be awoken. X.TP X.B Land XSet a fighter's function to \f2land\f1. X.TP X.B Out XCancel automove mode. At the end of the round, you will Xbe placed in command mode. X.TP X.B Print XRedraw the screen. X.TP X.B Random XSet a piece's function to \f2random\f1. X.TP X.B Sentry XSet a piece's function to \f2sentry\f1. X.TP X.B Transport XSet an army's function to \f2transport\f1. X.TP X.B Upgrade XSet a ship's function to \f2upgrade\f1. X.TP X.BI V "piece func" XSet the city movement function for the specified piece Xto the specified function. For example, typing "VAY" would Xset the city movement function for armies to \f2attack\f1. Whenever Xan army is produced in the city (or whenever a loaded transport Xenters the city), the army's movement function Xwould be set to \f2attack\f1. X.TP X.B Y XSet an army's function to \f2attack\f1. X.TP X.B ? XDisplay information about the piece. The Xfunction, hits left, range, and number of items on board are Xdisplayed. X.P XAttacking something is accomplished by moving onto the Xsquare of the unit you wish to attack. Hits are traded Xoff at 50% probability of a hit landing on one or the Xother units until one unit is totally destroyed. There Xis only 1 possible winner. X.P XYou are "allowed" to do \f3fatal\f1 things like attack your Xown cities or other pieces. If you try to make a fatal Xmove, the computer will warn you and give you a chance to Xchange your mind. X.P XYou cannot move onto the edge of the world. X.SH EDIT MODE XIn edit mode, you can move around the world and examine pieces Xor assign them new functions. XTo move the cursor around, use the standard direction Xkeys. XOther commands are: X.TP 10 X.B Build XChange the production of the city under the cursor. XThe program will prompt for the new production, and you Xshould respond with the key corresponding to the letter of the piece Xthat you want produced. X.TP X.B Fill XSet a transport's or carrier's function to \f2fill\f1. X.TP X.B Grope XSet a piece's function to \f2grope\f1. X.TP X.BI I dir XSet the function of a piece (or city) to the specified direction. X.TP X.B Kill XWake all pieces at the current location. If the location is a city, Xthe fighter path will also be canceled. X.TP X.B Mark XSelect the piece or city at the current location. This command Xis used with the "N" command. X.TP X.B N XSet the destination of the piece previously selected with the "M" Xcommand to the current square. X.TP X.B Out XExit edit mode. X.TP X.BI Print sector XDisplay a new sector of the map. The map is divided into Xten sectors of size 20 by 70. Sector zero is in the upper-left Xcorner of the map. Sector four is in the lower-left corner of Xthe map. Sector five is in the upper-right corner, and sector Xnine is in the lower-right corner. X.TP X.B Random XSet a piece to move randomly. X.TP X.B Sentry XPut a piece to sleep. X.TP X.B Transport XSet an army's function to \f2transport\f1. X.TP X.B Upgrade XSet a ship's function to \f2upgrade\f1. X.TP X.BI V "piece func" XSet the city movement function for a piece. X.TP X.B Y XSet an army's function to \f2attack\f1. X.TP X.B ? XDisplay information about a piece or city. XFor a city, the production, time of completion of Xthe next piece, movement functions, and the number of fighters and ships Xin the city are displayed. X.P XNote that you cannot directly affect anything inside a city with Xthe editor. X.SH HINTS XAfter you have played this game for a while, you will probably Xfind that the computer is immensely easy to beat. Here are some Xideas you can try that may make the game more interesting. X.TP 5 X.B * XGive the computer one or more extra cities before starting the game. X.TP X.B * XTry playing the game with a low smoothness value (try using the X-s2 or even -s0 option). X.TP X.B * XWhen starting the game, the program will ask you what difficulty Xlevel you want. Here "difficulty level" is a misnomer. To compute Xa difficulty level, the program looks at each continent and counts Xthe number of cities on the continents. A high "difficulty level" Xgives the computer a large continent with many cities, while the Xuser gets a small continent with few cities. A low "difficulty level" Xhas the opposite effect. It may be the case that the computer will Xplay better when the "difficulty level" is low. The reason for this Xis that the computer is forced to move armies to multiple continents Xearly in the game. X.SH HISTORY XApparently, this game was originally written outside of Digital, Xprobably at a university. The game was ported to DEC's VAX/VMS Xfrom the TOPS-10/20 FORTRAN sources available around fall 1979. XThe original authors listed in my old documentation are XMario DeNobili and Thomas N. Paulson. XSupport for different terminal types was added by Craig Leres. X.P XEd James got hold of the sources at Berkeley and converted Xportions of the code to C, mostly to use curses for the screen Xhandling. He published his modified sources on the net in XDecember 1986. Because this game ran on VMS machines for so Xlong, a previous version is known as VMS Empire. X.P XIn 1987 Chuck Simmons at Amdahl Xreverse engineered the program and wrote a Xversion completely written in C. In doing so, he completely Xmodified the computer strategy, the commands, the piece types, Xmany of the piece attributes, and the algorithm for creating maps. X.SH FILES X.TP 10 X\f2empsave.dat\f1 Xholds a backup of the game. Whenever empire is run, Xit will reload any game in this file. X.TP X\f2empmovie.dat\f1 Xholds a history of the game so that the game can be replayed as Xa "movie". X.SH BUGS XNo doubt numerous. X.P XSatellites are not completely implemented. You should be able to Xmove to a square that contains a satellite, but the program won't Xlet you. Enemy satellites should not cause your pieces to awaken. X.SH AUTHORS X.nf XOriginal concept by Mario DeNobili and Thomas N. Paulson. XSupport for different terminal types added by Craig Leres. XCurses support added by Ed James. XC/Unix version written by Chuck Simmons X.fi X.SH COPYLEFT X.fn XCopyright (C) 1987, 1988 Chuck Simmons X XSee the file COPYING, distributed with empire, for restriction Xand warranty information. X.fi //E*O*F empire.6// echo x - util.c sed -e 's/^X//' > "util.c" << '//E*O*F util.c//' X/* %W% %G% %U% - (c) Copyright 1987, 1988 Chuck Simmons */ X X/* X * Copyright (C) 1987, 1988 Chuck Simmons X * X * See the file COPYING, distributed with empire, for restriction X * and warranty information. X */ X X/* Xutil.c -- various utility routines. X*/ X X#include X#include X#include "empire.h" X#include "extern.h" X X X/* XConvert a string to uppercase. XShirley this is defined elsewhere? X*/ X X#include X Xvoid Xtupper (str) Xchar *str; X{ X while (*str) { X if (islower (*str)) *str = upper (*str); X str++; X } X} X X/* XConvert a character to uppercase (if it is lowercase) X*/ X Xchar Xupper (c) Xchar c; X{ X if (islower (c)) X return toupper (c); X else return c; X} X X/* XClear the end of a specified line starting at the specified column. X*/ X Xvoid Xclreol(linep, colp) Xint linep, colp; X{ X (void) move (linep, colp); X (void) clrtoeol(); X} X X/* XInitialize the terminal. X*/ X Xvoid Xttinit() X{ X (void) initscr(); X (void) noecho(); X (void) crmode(); X lines = LINES; X cols = COLS; X if (lines > MAP_HEIGHT + NUMTOPS + 1) X lines = MAP_HEIGHT + NUMTOPS + 1; X if (cols > MAP_WIDTH + NUMSIDES) X cols = MAP_WIDTH + NUMSIDES; X} X X X/* XClear the screen. We must also kill information maintained about the Xdisplay. X*/ X Xvoid Xclear_screen () { X (void) clear (); X (void) refresh (); X kill_display (); X} X X/* XRedraw the screen. X*/ X Xvoid Xredraw () { X (void) clearok (curscr, TRUE); X (void) refresh (); X} X X/* XWait a little bit to give user a chance to see a message. We refresh Xthe screen and pause for a few milliseconds. X*/ X Xvoid Xdelay () { X (void) refresh (); X (void) napms (delay_time); /* pause a bit */ X} X X X/* XClean up the display. This routine gets called as we leave the game. X*/ X Xvoid Xclose_disp() X{ X (void) move (LINES - 1, 0); X (void) clrtoeol (); X (void) refresh (); X (void) endwin (); X} X X/* XPosition the cursor and output a string. X*/ X Xvoid X/* VARARGS3 */ Xpos_str (row, col, str, a, b, c, d, e, f, g, h) Xint row, col; Xchar *str; Xint a, b, c, d, e, f, g, h; X{ X (void) move (row, col); X addprintf (str, a, b, c, d, e, f, g, h); X} X Xvoid X/* VARARGS1 */ Xaddprintf (str, a, b, c, d, e, f, g, h) Xchar *str; Xint a, b, c, d, e, f, g, h; X{ X char junkbuf[STRSIZE]; X X (void) sprintf (junkbuf, str, a, b, c, d, e, f, g, h); X (void) addstr (junkbuf); X} X X/* XReport a bug. X*/ X Xvoid Xassert (expression, file, line) Xchar *expression; Xchar *file; Xint line; X{ X char buf[STRSIZE]; X int a; X X (void) move (lines, 0); X close_disp (); X X (void) sprintf (buf, "assert failed: file %s line %d: %s", X file, line, expression); X X a = 1; /* keep lint quiet */ X a /= 0; /* force a core dump */ X a = a; /* keep lint quiet */ X} X X/* XEnd the game by cleaning up the display. X*/ X Xvoid Xempend () X{ X close_disp (); X exit (0); X} X X/* X * 03a 01Apr88 aml .Hacked movement algorithms for computer. X * 02b 01Jun87 aml .First round of bug fixes. X * 02a 01Jan87 aml .Translated to C. X * 01b 27May85 cal .Fixed round number update bug. Made truename simple. X * 01a 01Sep83 cal .Taken from a Decus tape X */ X Xvoid Xver () X{ X (void) addstr ("EMPIRE, Version 5.00 site Amdahl 1-Apr-1988"); X} X X/* XHere is a little routine to perform consistency checking on the Xdatabase. I'm finding that my database is becoming inconsistent, Xand I've no idea why. Possibly this will help. X XWe perform the following functions: X X1) Make sure no list contains loops. X X2) Make sure every object is in either the free list with 0 hits, Xor it is in the correct object list and a location list with non-zero hits, Xand an appropriate owner. X X3) Make sure every city is on the map. X X4) Make sure every object is in the correct location and that Xobjects on the map have non-zero hits. X X5) Make sure every object in a cargo list has a ship pointer. X X6) Make sure every object with a ship pointer is in that ship's Xcargo list. X*/ X Xstatic int in_free[LIST_SIZE]; /* TRUE if object in free list */ Xstatic int in_obj[LIST_SIZE]; /* TRUE if object in obj list */ Xstatic int in_loc[LIST_SIZE]; /* TRUE if object in a loc list */ Xstatic int in_cargo[LIST_SIZE]; /* TRUE if object in a cargo list */ X Xvoid Xcheck () { X void check_cargo(), check_obj(), check_obj_cargo(); X X long i, j; X piece_info_t *p; X X /* nothing in any list yet */ X for (i = 0; i < LIST_SIZE; i++) { X in_free[i] = 0; X in_obj[i] = 0; X in_loc[i] = 0; X in_cargo[i] = 0; X } X X /* Mark all objects in free list. Make sure objects in free list X have zero hits. */ X X for (p = free_list; p != NULL; p = p->piece_link.next) { X i = p - object; X ASSERT (!in_free[i]); X in_free[i] = 1; X ASSERT (p->hits == 0); X if (p->piece_link.prev) X ASSERT (p->piece_link.prev->piece_link.next == p); X } X X /* Mark all objects in the map. X Check that cities are in corect location. X Check that objects are in correct location, X have a good owner, and good hits. */ X X for (i = 0; i < MAP_SIZE; i++) { X if (map[i].cityp) ASSERT (map[i].cityp->loc == i); X X for (p = map[i].objp; p != NULL; p = p->loc_link.next) { X ASSERT (p->loc == i); X ASSERT (p->hits > 0); X ASSERT (p->owner == USER || p->owner == COMP); X X j = p - object; X ASSERT (!in_loc[j]); X in_loc[j] = 1; X X if (p->loc_link.prev) X ASSERT (p->loc_link.prev->loc_link.next == p); X } X } X X /* make sure all cities are on map */ X X for (i = 0; i < NUM_CITY; i++) X ASSERT (map[city[i].loc].cityp == &(city[i])); X X /* Scan object lists. */ X X check_obj (comp_obj, COMP); X check_obj (user_obj, USER); X X /* Scan cargo lists. */ X X check_cargo (user_obj[TRANSPORT], ARMY); X check_cargo (comp_obj[TRANSPORT], ARMY); X check_cargo (user_obj[CARRIER], FIGHTER); X check_cargo (comp_obj[CARRIER], FIGHTER); X X /* Make sure all objects with ship pointers are in cargo. */ X X check_obj_cargo (comp_obj); X check_obj_cargo (user_obj); X X /* Make sure every object is either free or in loc and obj list. */ X X for (i = 0; i < LIST_SIZE; i++) X ASSERT (in_free[i] != (in_loc[i] && in_obj[i])); X} X X/* XCheck object lists. We look for: X X1) Loops and bad prev pointers. X X2) Dead objects. X X3) Invalid types. X X4) Invalid owners. X*/ X Xvoid Xcheck_obj (list, owner) Xpiece_info_t **list; Xint owner; X{ X long i, j; X piece_info_t *p; X X for (i = 0; i < NUM_OBJECTS; i++) X for (p = list[i]; p != NULL; p = p->piece_link.next) { X ASSERT (p->owner == owner); X ASSERT (p->type == i); X ASSERT (p->hits > 0); X X j = p - object; X ASSERT (!in_obj[j]); X in_obj[j] = 1; X X if (p->piece_link.prev) X ASSERT (p->piece_link.prev->piece_link.next == p); X } X} X X/* XCheck cargo lists. We assume object lists are valid. Xas we will place bits in the 'in_cargo' array that are used by X'check_obj'. X XCheck for: X X1) Number of items in list is same as cargo count. X X2) Type of cargo is correct. X X3) Location of cargo matches location of ship. X X4) Ship pointer of cargo points to correct ship. X X5) There are no loops in cargo list and prev ptrs are correct. X X6) All cargo is alive. X*/ X Xvoid Xcheck_cargo (list, cargo_type) Xpiece_info_t *list; Xint cargo_type; X{ X piece_info_t *p, *q; X long j, count; X X for (p = list; p != NULL; p = p->piece_link.next) { X count = 0; X for (q = p->cargo; q != NULL; q = q->cargo_link.next) { X count += 1; /* count items in list */ X ASSERT (q->type == cargo_type); X ASSERT (q->owner == p->owner); X ASSERT (q->hits > 0); X ASSERT (q->ship == p); X ASSERT (q->loc == p->loc); X X j = q - object; X ASSERT (!in_cargo[j]); X in_cargo[j] = 1; X X if (p->cargo_link.prev) X ASSERT (p->cargo_link.prev->cargo_link.next == p); X } X ASSERT (count == p->count); X } X} X X/* XScan through object lists making sure every object with a ship Xpointer appears in a cargo list. We assume object and cargo Xlists are valid. X*/ X Xvoid Xcheck_obj_cargo (list) Xpiece_info_t **list; X{ X piece_info_t *p; X long i; X X for (i = 0; i < NUM_OBJECTS; i++) X for (p = list[i]; p != NULL; p = p->piece_link.next) { X if (p->ship) ASSERT (in_cargo[p-object]); X } X} //E*O*F util.c// echo x - data.c sed -e 's/^X//' > "data.c" << '//E*O*F data.c//' X/* %W% %G% %U% - (c) Copyright 1987, 1988 Chuck Simmons */ X X/* X * Copyright (C) 1987, 1988 Chuck Simmons X * X * See the file COPYING, distributed with empire, for restriction X * and warranty information. X */ X X/* XStatic data. X XOne of our hopes is that changing the types of pieces that Xexist in the game is mostly a matter of modifying this file. XHowever, see also the help routine, empire.h, and empire.doc. X*/ X X#include "empire.h" X X/* XPiece attributes. Notice that the Transport is allowed only one hit. XIn the previous version of this game, the user could easily win simply Xby building armies and troop transports. We attempt to alleviate this Xproblem by making transports far more fragile. We have also increased Xthe range of a fighter from 20 to 30 so that fighters will be somewhat Xmore useful. X*/ X Xpiece_attr_t piece_attr[] = { X {'A', /* character for printing piece */ X "army", /* name of piece */ X "army", /* nickname */ X "an army", /* name with preceding article */ X "armies", /* plural */ X "+", /* terrain */ X 5, /* units to build */ X 1, /* strength */ X 1, /* max hits */ X 1, /* movement */ X 0, /* capacity */ X INFINITY}, /* range */ X X /* X For fighters, the range is set to an even multiple of the speed. X This allows user to move fighter, say, two turns out and two X turns back. X */ X X {'F', "fighter", "fighter", "a fighter", "fighters", X ".+", 10, 1, 1, 8, 0, 32}, X X {'P', "patrol boat", "patrol", "a patrol boat", "patrol boats", X ".", 15, 1, 1, 4, 0, INFINITY}, X X {'D', "destroyer", "destroyer", "a destroyer", "destroyers", X ".", 20, 1, 3, 2, 0, INFINITY}, X X {'S', "submarine", "submarine", "a submarine", "submarines", X ".", 20, 3, 2, 2, 0, INFINITY}, X X {'T', "troop transport", "transport", "a troop transport", "troop transports", X ".", 30, 1, 1, 2, 6, INFINITY}, X X {'C', "aircraft carrier", "carrier", "an aircraft carrier", "aircraft carriers", X ".", 30, 1, 8, 2, 8, INFINITY}, X X {'B', "battleship", "battleship", "a battleship", "battleships", X ".", 40, 2, 10, 2, 0, INFINITY}, X X {'Z', "satellite", "satellite", "a satellite", "satellites", X ".+", 50, 0, 1, 10, 0, 500} X}; X X/* Direction offsets. */ X Xint dir_offset [] = {-MAP_WIDTH, /* north */ X -MAP_WIDTH+1, /* northeast */ X 1, /* east */ X MAP_WIDTH+1, /* southeast */ X MAP_WIDTH, /* south */ X MAP_WIDTH-1, /* southwest */ X -1, /* west */ X -MAP_WIDTH-1}; /* northwest */ X X/* Names of movement functions. */ X Xchar *func_name[] = {"none", "random", "sentry", "fill", "land", X "explore", "load", "attack", "load", "repair", X "transport", X "W", "E", "D", "C", "X", "Z", "A", "Q"}; X X/* The order in which pieces should be moved. */ Xint move_order[] = {SATELLITE, TRANSPORT, CARRIER, BATTLESHIP, X PATROL, SUBMARINE, DESTROYER, ARMY, FIGHTER}; X X/* types of pieces, in declared order */ Xchar type_chars[] = "AFPDSTCBZ"; X X/* Lists of attackable objects if object is adjacent to moving piece. */ X Xchar tt_attack[] = "T"; Xchar army_attack[] = "O*TACFBSDP"; Xchar fighter_attack[] = "TCFBSDPA"; Xchar ship_attack[] = "TCBSDP"; X X/* Define various types of objectives */ X Xmove_info_t tt_explore = { /* water objectives */ X COMP, /* home city */ X " ", /* objectives */ X {1} /* weights */ X}; Xmove_info_t tt_load = { /* land objectives */ X COMP, "$", {1} X}; X X/* XRationale for 'tt_unload': X X Any continent with four or more cities is extremely attractive, Xand we should grab it quickly. A continent with three cities is Xfairly attractive, but we are willing to go slightly out of our Xway to find a better continent. Similarily for two cities on a Xcontinent. At one city on a continent, things are looking fairly Xunattractive, and we are willing to go quite a bit out of our way Xto find a better continent. X X Cities marked with a '0' are on continents where we already Xhave cities, and these cities will likely fall to our armies anyway, Xso we don't need to dump armies on them unless everything else is Xreal far away. We would prefer to use unloading transports for Xtaking cities instead of exploring, but we are willing to explore Xif interesting cities are too far away. X X It has been suggested that continents containing one city Xare not interesting. Unfortunately, most of the time what the Xcomputer sees is a single city on a continent next to lots of Xunexplored territory. So it dumps an army on the continent to Xexplore the continent and the army ends up attacking the city Xanyway. So, we have decided we might as well send the tt to Xthe city in the first place and increase the speed with which Xthe computer unloads its tts. X*/ X Xmove_info_t tt_unload = { X COMP, "9876543210 ", {1, 1, 1, 1, 1, 1, 11, 21, 41, 101, 61} X}; X X/* X '$' represents loading tt must be first X 'x' represents tt producing city X '0' represnets explorable territory X*/ Xmove_info_t army_fight = { /* land objectives */ X COMP, "O*TA ", {1, 1, 1, 1, 11} X}; Xmove_info_t army_load = { /* water objectives */ X COMP, "$x", {1, W_TT_BUILD} X}; X Xmove_info_t fighter_fight = { X COMP, "TCFBSDPA ", {1, 1, 5, 5, 5, 5, 5, 5, 9} X}; Xmove_info_t ship_fight = { X COMP, "TCBSDP ", {1, 1, 3, 3, 3, 3, 21} X}; Xmove_info_t ship_repair = { X COMP, "X", {1} X}; X Xmove_info_t user_army = { X USER, " ", {1} X}; Xmove_info_t user_army_attack = { X USER, "*Xa ", {1, 1, 1, 12} X}; Xmove_info_t user_fighter = { X USER, " ", {1} X}; Xmove_info_t user_ship = { X USER, " ", {1} X}; Xmove_info_t user_ship_repair = { X USER, "O", {1} X}; X X/* XVarious help texts. X*/ X Xchar *help_cmd[] = { X "COMMAND MODE", X "Auto: enter automove mode", X "City: give city to computer", X "Date: print round", X "Examine: examine enemy map", X "File: print map to file", X "Give: give move to computer", X "Help: display this text", X "J: enter edit mode", X "Move: make a move", X "N: give N moves to computer", X "Print: print a sector", X "Quit: quit game", X "Restore: restore game", X "Save: save game", X "Trace: save movie in empmovie.dat", X "Watch: watch movie", X "Zoom: display compressed map", X ": redraw screen" X}; Xint cmd_lines = 19; X Xchar *help_user[] = { X "USER MODE", X "QWE", X "A D movement directions", X "ZXC", X ": sit", X "Build: change city production", X "Fill: set func to fill", X "Grope: set func to explore", X "Help: display this text", X "I : set func to dir", X "J: enter edit mode", X "Kill: set func to awake", X "Land: set func to land", X "Out: leave automove mode", X "Print: redraw screen", X "Random: set func to random", X "Sentry: set func to sentry", X "Upgrade: set func to repair", X "V : set city func", X "Y: set func to attack", X ": redraw screen", X "?: describe piece" X}; Xint user_lines = 22; X Xchar *help_edit[] = { X "EDIT MODE", X "QWE", X "A D movement directions", X "ZXC", X "Build: change city production", X "Fill: set func to fill", X "Grope: set func to explore", X "Help: display this text", X "I : set func to dir", X "Kill: set func to awake", X "Land: set func to land", X "Mark: mark piece", X "N: set dest for marked piece", X "Out: exit edit mode", X "Print: print sector", X "Random: set func to random", X "Sentry: set func to sentry", X "Upgrade: set func to repair", X "V : set city func", X "Y: set func to attack", X ": redraw screen", X "?: describe piece" X}; Xint edit_lines = 22; //E*O*F data.c// echo x - COPYING sed -e 's/^X//' > "COPYING" << '//E*O*F COPYING//' X X EMPIRE GENERAL PUBLIC LICENSE X X Copyright (C) 1987, 1988 Chuck Simmons X Copyleft (GNU) 1987, 1988 Chuck Simmons X X Everyone is permitted to copy and distribute verbatim copies X of this license, but changing it is not allowed. You can also X use this wording to make the terms for other programs. X X The license agreements of most software companies keep you at the Xmercy of those companies. By contrast, our general public license is Xintended to give everyone the right to share EMPIRE. To make sure that Xyou get the rights we want you to have, we need to make restrictions Xthat forbid anyone to deny you these rights or to ask you to surrender Xthe rights. Hence this license agreement. X X Specifically, we want to make sure that you have the right to give Xaway copies of EMPIRE, that you receive source code or else can get it Xif you want it, that you can change EMPIRE or use pieces of it in new Xfree programs, and that you know you can do these things. X X To make sure that everyone has such rights, we have to forbid you to Xdeprive anyone else of these rights. For example, if you distribute Xcopies of EMPIRE, you must give the recipients all the rights that you Xhave. You must make sure that they, too, receive or can get the Xsource code. And you must tell them their rights. X X Also, for our own protection, we must make certain that everyone Xfinds out that there is no warranty for EMPIRE. If EMPIRE is modified by Xsomeone else and passed on, we want its recipients to know that what Xthey have is not what we distributed, so that any problems introduced Xby others will not reflect on our reputation. X X Therefore we (Chuck Simmons) make the following terms which say what Xyou must do to be allowed to distribute or change EMPIRE. X X X COPYING POLICIES X X 1. You may copy and distribute verbatim copies of EMPIRE source code Xas you receive it, in any medium, provided that you conspicuously and Xappropriately publish on each copy a valid copyright notice "Copyright X(C) 1988 Chuck Simmons" (or with whatever year is appropriate); keep Xintact the notices on all files that refer to this License Agreement Xand to the absence of any warranty; and give any other recipients of Xthe EMPIRE program a copy of this License Agreement along with the Xprogram. You may charge a distribution fee for the physical act of Xtransferring a copy. X X 2. You may modify your copy or copies of EMPIRE or any portion of it, Xand copy and distribute such modifications under the terms of XParagraph 1 above, provided that you also do the following: X X a) cause the modified files to carry prominent notices stating X that you changed the files and the date of any change; and X X b) cause the whole of any work that you distribute or publish, X that in whole or in part contains or is a derivative of EMPIRE or X any part thereof, to be licensed at no charge to all third X parties on terms identical to those contained in this License X Agreement (except that you may choose to grant more extensive X warranty protection to some or all third parties, at your option). X X c) You may charge a distribution fee for the physical act of X transferring a copy, and you may at your option offer warranty X protection in exchange for a fee. X XMere aggregation of another unrelated program with this program (or its Xderivative) on a volume of a storage or distribution medium does not bring Xthe other program under the scope of these terms. X X 3. You may copy and distribute EMPIRE (or a portion or derivative of it, Xunder Paragraph 2) in object code or executable form under the terms of XParagraphs 1 and 2 above provided that you also do one of the following: X X a) accompany it with the complete corresponding machine-readable X source code, which must be distributed under the terms of X Paragraphs 1 and 2 above; or, X X b) accompany it with a written offer, valid for at least three X years, to give any third party free (except for a nominal X shipping charge) a complete machine-readable copy of the X corresponding source code, to be distributed under the terms of X Paragraphs 1 and 2 above; or, X X c) accompany it with the information you received as to where the X corresponding source code may be obtained. (This alternative is X allowed only for noncommercial distribution and only if you X received the program in object code or executable form alone.) X XFor an executable file, complete source code means all the source code for Xall modules it contains; but, as a special exception, it need not include Xsource code for modules which are standard libraries that accompany the Xoperating system on which the executable file runs. X X 4. You may not copy, sublicense, distribute or transfer EMPIRE Xexcept as expressly provided under this License Agreement. Any attempt Xotherwise to copy, sublicense, distribute or transfer EMPIRE is void and Xyour rights to use the program under this License agreement shall be Xautomatically terminated. However, parties who have received computer Xsoftware programs from you with this License Agreement will not have Xtheir licenses terminated so long as such parties remain in full compliance. X X 5. If you wish to incorporate parts of EMPIRE into other free programs Xwhose distribution conditions are different, write to Chuck Simmons Xat 1250 E. Arques Ave (MS 269), Box 3470, Sunnyvale, CA 94088-3470, XUSA. We have not yet worked out a simple rule that can be stated here, Xbut we will often permit this. We will be guided by the two goals of Xpreserving the free status of all derivatives of our free software and Xof promoting the sharing and reuse of software. X XYour comments and suggestions about our licensing policies and our Xsoftware are welcome! This contract was based on the contract made by Xthe Free Software Foundation. Please contact the Free Software XFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or call (617) X876-3296 for details on copylefted materal in general, or contact us Xvia electronic mail at amdahl!chuck. X X(Please note that the Free Software Foundation is in no way associated Xwith EMPIRE, and any lack of quality inherent in EMPIRE should not Xreflect on the reputation of that noble enterprise.) X X X NO WARRANTY X X BECAUSE EMPIRE IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY NO XWARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT WHEN XOTHERWISE STATED IN WRITING, CHUCK SIMMONS AND/OR OTHER PARTIES PROVIDE XEMPIRE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, XINCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY XAND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY XAND PERFORMANCE OF EMPIRE IS WITH YOU. SHOULD EMPIRE PROVE DEFECTIVE, XYOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. X X IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL CHUCK SIMMONS XAND/OR ANY OTHER PARTY WHO MAY MODIFY AND REDISTRIBUTE EMPIRE AS PERMITTED XABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST XMONIES, OR OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING XOUT OF THE USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS XOF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD XPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) XEMPIRE, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, XOR FOR ANY CLAIM BY ANY OTHER PARTY. //E*O*F COPYING// echo shar: End of archive 5 \(of 6\). cp /dev/null ark5isdone MISSING="" for I in 1 2 3 4 5 6 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 6 archives. rm -f ark[1-9]*isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0