[net.sources.games] WAR -- Part 1 of 2...

ejb@think.ARPA (Erik Bailey) (04/24/86)

See, I told you there wasn't a line-eater! The line above this still exists!

This is WAR, a two-player, FAST-ACTION maze war game. Each player
has about 10 men, of varying strength, and a maze. The goal of
each player is to infiltrate the other playere's maze and destroy
his "flag". It's a really neat game, although one will outgrow
it reasonably soon. Personally, it's one of my favorites. --Erik

-----------------fold, staple, mutilate, line-eater!-------------------
#---Cut here and place in it's own directory, then feed to Bourne shell---
# 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:
#   README (1036 chars)
#   war.6 (19117 chars)
#   objects.war (656 chars)
#   boards.war (3785 chars)
#   makefile (229 chars)
#   war.h (6354 chars)
#
echo x - README
sed -e 's/^X//' > "README" << '//E*O*F README//'
XThis program was written for 4.2 BSD running on a VAX 750.   It makes
Xuse of sockets for communicating between two copies of the program.
XTherefore, porting this program to other flavors of UNIX will be painful.
X
XThis program requires the "dpy" library module which I have previously
Xposted to net.sources.  If you do not have this module, then you must
Xget it from someone else on the net.  I can no longer supply copies of
Xdpy since this is my last day at Daisy.
X
XThe following files need to be handled specially:
X
Xobjects.war	This is the default object initialization file.  Copy it
X		to /usr/games/lib.
X
Xboards.war	This is an example setup file.  Each player actually has
X		their own setup file ".warsetups" in their HOME directory.
X
Xwar.6		This is the manual page for war.  Copy it to /usr/man/man6.
X
XThere are still several features that I would like to see in the game,
Xbut I am out of time (see the bug list in the man page).  However, the
Xcurrent version still contains enough features to be playable.  Enjoy!
X
X		David I. Bell
//E*O*F README//
echo x - war.6
sed -e 's/^X//' > "war.6" << '//E*O*F war.6//'
X.TH WAR 6 "3 April 1985"
X.UC
X.SH NAME
Xwar \- two person seek and destroy game played in mazes
X.SH SYNOPSIS
X.B war
X[
X.B \-f
Xsetupfile ] [
X.B \-s
Xsetupname ] [
X.B \-o
Xobjectfile ] username [ ttyname ]
X.br
X.B war -e
X[
X.B \-f
Xsetupfile ] [
X.B \-s
Xsetupname ] [
X.B \-o
Xobjectfile ]
X.SH DESCRIPTION
X.I War
Xis a war game played between two people on display terminals.
XIt is played on a board which has 24 rows and 48 columns.
XThe top and bottom ten rows of the board are the
X.I home
Xareas for the two players.
XThe middle four rows are the
X.IR "no man's land" .
XAt the beginning of the game each player creates a maze in his own home
Xarea, and populates it with fighting men, blasting men, and a goal.
XAfter this setup phase is complete, the two players fight each other.
XThe object of the game is to find and destroy the enemy goal.
XAlong the way, battles are fought between your men and the enemy's men,
Xthe enemy's maze is explored and perhaps blasted through,
Xand your own maze and goal is defended.
X.I War
Xis a game of imperfect information.
XYou know everything about your own men, but know very little about the enemy.
XAs the game progresses, you can determine the flow of the battle from a
Xset of statistics which are displayed for both players.
XHowever, you do not know the details concerning any specific men.
XTo know where the enemy men are, you must place your own men close enough
Xto them to seen them.
X.PP
XThe person to play with is specified by giving his login name.
XIf he is logged in on more than one terminal, you must then also give
Xthe terminal name to play with.
XOf course, for the game to actually play, the opponent must also run
X.I war
Xand specify you as the person for him to play with.
XIf you don't want to play with anyone, but just want to edit different
Xmazes for future play, then use the
X.B \-e
Xoption.
X.SH "THE DISPLAY"
XThe screen is split up into three parts.
XThe left half of the screen contains a picture of the playing board.
XThe board occupies all the space between the two vertical rows of characters.
XYour home area is always in the upper ten rows of the board, and the
Xenemy's home area is always in the lower ten rows.
XThis means that if you compare your view of the board with the other player,
Xhis view seems flipped over.
XHowever, directions are transformed uniformly so that no problems appear.
XYou can always see all of your own walls and men.
XHowever, you cannot see the enemy's walls or men unless you have men close
Xenough to them (even in your own maze).
XHowever, once you have see any of the enemy's walls (or other immovable
Xobjects), they will stay visible as long as they exist.
X.PP
XThe lower right of the screen shows the status of the game.
XYou can compare the status of your men with the enemy's men.
XEach pair of numbers separated with a slash gives the number of men
Xleft of that type, and the total life of those men.
X.PP
XThe upper right of the screen shows the current status of all of your men.
XThe parameters of the men are configurable, and are normally read from
Xthe file
X.IR /usr/games/lib/objects.war .
XYou can play with different men by creating a new configuration file and
Xspecifying it using the
X.B \-o
Xoption.
XThe enemy has men similar to yours, but you don't know their life values or
Xwhich ones are still alive.
XThis display only shows men which are still alive, so when a man of yours
Xdies, it is removed from the display.
XThe two characters under the OBJ heading are a description of your men.
XThe leftmost character is how your object (man or wall) appears to you.
XThe rightmost character is how your object appears to the enemy.
XNotice that several men appear identically to the enemy (as numbers), so
Xthat he can't distinguish between them.
XDifferent kinds of men have different characters, however.
X.PP
XThe life of the object is how many hits it can take before it is destroyed.
XFor walls, the life is instead an indication of how tough each wall is
Xto blast away.
XThe view of the object is the range at which the object can see enemy objects.
XThe range specifies a square of the specified radius (not a circle).
XThus a man with a view of 3 could see an enemy man which was 3 rows down
Xand 3 columns to the right.
XViewing is normally blocked by walls and men, so the full viewing range is
Xnot always usable (especially when inside a cramped maze).
X.PP
XThe flags column gives the capabilities of the object.
XThese capabilities are as follows:
X.TP 6
X.B b
XObject can blast walls.
X.TP
X.B f
XObject can fight men.
X.TP
X.B g
XObject is a goal.
X.TP
X.B i
XObject is immobile.
X.TP
X.B t
XObject is transparent.
X.TP
X.B v
XObject is always visible.
X.TP
X.B w
XObject is a wall.
X.TP
X.B x
XObject has x-ray vision.
XThis means it can see through walls and men.
X.SH "SETUP PHASE"
XThe first phase of the game is the setup, or editing phase.
XThis is when you design your maze and place your men into it.
XTo make this phase go quicker, you can read in a setup that you had
Xprevious created.
XThis can be done on the command line by using the
X.B \-s
Xoption.
XYou can also read in the setup after starting the program.
XThese setups are stored in the file ".warsetups" in your HOME directory.
XThis can be changed to be any file you wish by using the
X.B \-f
Xoption.
XA setup file contains a number of setups in sequence.
XEach setup begins with a line containing a name surrounded by double quotes.
XFollowing the name is simply a picture of the setup.
X.PP
XAn example of a setup file entry named 'nice' is:
X.sp
X.nf
X	"nice"
X	*    *                      *   *
X	*  *   ****************** *   * * * ***********
X	****** *             *  * ******* *          *
X	 ** **** ********* *    * *#      * ******** * *
X	      **    *   *   ***** ********* * *   *  *
X	 ******  ** * *   *                 *   *    **
X	 ******* ** ************************************
X						  E X
X	**********BDC*****H*****G***F*************Y Z***
X	***********A******************************* ****
X.fi
X.PP
XIf you read in a setup, you can still perform last minute changes to it
Xbefore playing.
XOnce you create a setup that you like, you can save it in your setup file
Xfor use in later games.
X.PP
XThere is a restriction on the creation of a setup.
XWalls cannot block off any location on the board (even other walls).
XThat is, there must be a path from below the setup to every location
Xin the home area, without having to travel through a wall.
XThe path must exist orthogonally (left-right or up-down).
XThis restriction prevents the creation of mazes which are just made up of
Xsolid walls.
XIt also guarantees that the goal is accessible without having to remove
Xany walls.
XThe program enforces this restriction rigidly, even if a saved setup is
Xread in.
X.PP
XCommands in the setup phase are single letter commands, possibly preceeded
Xby a numeric argument, which is used as a repeat count.
XThese commands do not echo, and need no terminating carriage return.
XBefore completion, the normal editing characters can be used, and
Xthe escape character will clear the command.
XUnknown or illegal commands will ring the terminal bell.
XMost commands are executed immediately when they are completely typed.
XBut those commands with dangerous consequences or that require input strings
Xwill prompt you for a response.
XAll such responses require a terminating carriage return.
XIf a blank response or an escape is typed, the command is aborted.
X.PP
XThe commands used for editing a setup are the following:
X.TP 6
X.B r
XClears the current setup and reads in a setup from your ".warsetups" file.
XThe name of the setup is prompted for.
XThe first setup in the file which matches the name is used.
XThe setup will be checked for legality, and unknown or illegal locations
Xwill be left blank.
X.TP
X.B w
XWrites the current setup to your ".warsetups" file.
XThe name of the setup will be prompted for.
XThe setup is appended to the end of the file, and so duplications of
Xa setup name are undetected.
X.TP
X.B f
XFlips the setup from left to right.
XThis allows you to create the mirror image of a setup.
X.TP
X.B c
XClears the current setup.
XYou are asked to confirm this command.
X.TP
X.B p
XPlaces an object at the current position.
XThe object to be placed is typed immediately after the 'p'.
XThis object is also remembered later for certain other commands.
XIf the object is unknown or cannot be placed, nothing is done.
X.TP
X.B "."
XPlaces the remembered object at the current position.
XThis is mostly useful for walls, so that you can easily place many of them.
X.TP
X.B x
XRemoves the object at the current position, and moves to the next column.
XIf a count is specified, many objects in a row can be removed.
X.TP
X.B <cr>
XMoves to the beginning of the next row.
X.TP
X.B \-
XMoves to the beginning of the previous row.
X.TP
X.B <tab>
XMoves to the next column which is at a multiple of 8.
X.TP
X.B ^
XMoves to the beginning of the current row.
X.TP
X.B $
XMoves to the end of the current row.
X.TP
X.B h
XMoves to the left.
X.TP
X.B j
XMoves down.
X.TP
X.B k
XMoves up.
X.TP
X.B l
XMoves right.
X.TP
X.B <space>
XMoves right.
X.TP
X.B y
XMoves to the upper left.
X.TP
X.B u
XMoves to the upper right.
X.TP
X.B b
XMoves to the lower left.
X.TP
X.B n
XMoves to the lower right.
X.TP
X.B H
XMoves to the left placing as many objects as it can.
XThe object that is placed is the remembered object from the 'p' command.
XThis and similar commands stop when an illegal placement is attempted,
Xor when the specified count is reached.
XIf no count is specifed, a large one is assumed.
XThis command is used to place many walls in a row.
X.TP
X.B J
XMoves down placing many objects.
X.TP
X.B K
XMoves up placing many objects.
X.TP
X.B L
XMoves right placing many objects.
X.TP
X.B Y
XMoves to the upper left placing many objects.
X.TP
X.B U
XMoves to the upper right placing many objects.
X.TP
X.B B
XMoves to the lower left placing many objects.
X.TP
X.B N
XMoves to the lower right placing many objects.
X.TP
X.B s
XStart to play the game.
XIf you have not specified a player you wish to play with,
Xor if your setup is not complete because of missing men,
Xthen the terminal bell will ring and the command will be ignored.
XIf playing is allowed, you are asked to confirm this command.
XOnce you have confirmed that you want to play, no further setup commands
Xcan be used.
XTherefore you must save your setup previous to this command if you want
Xto use it again in a new game.
X.I War
Xwill then wait until both players have said that they are ready to play.
XWhen this is so, the terminal bell will beep and the second phase of
Xthe game begins.
XYour input then controls the running of your men.
X.TP
X.B q
XQuit the program.
XYou are asked to confirm this command.
XIf you wish to save your setup, you must do so before quiting.
X.TP
X.B ^L
XRedraws the screen.
X.SH "PLAYING PHASE"
XThe game is played in turns lasting about 2 seconds each.
XPlay alternates between the two players in real-time.
XTherefore, the game does not wait for your input.
XInstead, you type your commands while the game plays,
Xand they are acted upon on the next time is is your turn.
XIf you type fast, then you can specify many commands each turn.
X.PP
XYou program each of your men with a sequence of simple commands which
Xtells each man how to act.
XThese simple commands direct the man to move, fight, or blast.
XWhen your turn arrives, each man tries to execute each command of his program
Xin sequence until one of them succeeds.
XAt that point, the man has finished moving for the current turn.
XWhen none of your men can successfully execute anything, then the turn is over.
XEach man will continue to try to execute its command sequence each turn,
Xuntil you supercede it or the man dies.
X.PP
XEach of your commands cancels the existing command sequence for a man,
Xand completely replaces it with the new sequence.
XYour skill in the game depends on recognizing when commands need changing
Xfor your men, and to specify the new commands quickly and accurately.
XYou specify a new set of commands for a man by typing the character of
Xthe man, the set of commands to be executed, and then a space or carriage
Xreturn character.
XUntil you type the terminating space or return, the command is incomplete
Xand can be edited with the normal editing characters.
XIt can also be cancelled by typing an escape character.
XWhen a command is completed, it is checked for legality before it is used.
XIf an illegal command was specified, the terminal bell will be rung,
Xand the man's previous commands are still in effect.
XIf the command sequence was legal, it then immediately becomes the new
Xcommand sequence for the specified man.
X.PP
XIf you require careful timing for the specifying of a sequence of commands,
Xthen you can type it all except for the final space, wait until conditions
Xare right, and then terminate the command.
XYou must do this immediately after the screen updates, otherwise the
Xnext turn could already be started.
X.SH "MOVEMENT"
XMovement of all men is orthogonal (left-right or up-down).
XWhen a man is able to move, it moves by exactly one location.
XThis means that it takes many turns for a man to cross the board.
XNo man can move through another man, or through a wall.
XIf commands are specified which attempt to do this, the command fails.
XHowever, if conditions later change (such as other men moving out of the way),
Xthen the command could then be executed successfully.
X.PP
XIt is very often useful to specify several directions for a man to move.
XThis allows a man to automatically travel around many obstacles.
XFor example, you can specify to move right and then down.
XWhen rightward movement is possible, the man moves right.
XWhenever that way is blocked, the man moves down instead.
XSometimes it is even convenient to specify three directions for movement.
X.PP
XIf a count is given for a movement command, then after that many moves have
Xbeen made, that movement command will be ignored.
XThis allows you to position a man exactly, since it will stop when the
Xspecified count runs out.
X.SH "FIGHTING"
XWhenever one of your men and one of the enemy's men are next to each other
Xin an orthogonal direction (left-right or up-down), then fighting can occur.
XIf you allow your man to fight, then he can take one shot each turn.
XEach shot has a 50% chance of success.
XIf successful, then the life of the enemy man is reduced by one.
XWhen the life is reduced to zero, the man dies and is removed from the board.
XIf there is someone to fight, the turn is used even if the shot misses.
X.PP
XYou normally do not need to actively specify that fighting should occur.
XAn implicit fight command is added to the end of every command you set
Xfor a man, so that if the man fails to execute your commands, fighting will
Xthen occur when possible.
XOne reason to explicitly specify a fight command is when you want to fight
Xfirst, and move only when there is no one to fight.
X.PP
XThe other reason for specifing the fight command is when there are multiple
Xmen you could fight with.
XIf you have a choice, and you have not specified otherwise, then your man
Xpicks one of the men at random each turn, and fights him.
XThis means that you are spreading your attacks between more than one person.
XIf you specify an attack in a certain direction, then the other men will
Xbe ignored.
XThis is important if you are surrounded and need to kill one of your
Xattackers in order to escape before you die.
X.SH "BLASTING"
XCertain men have the capability to blast walls.
XThis is done by moving your man next to the wall to be blasted, and
Xspecifying that a wall is to be blasted.
XBlasting of a wall is probabilistic, and depends on the "life" of the wall.
XEach time that your man can attempt blasting, the chance of the blast
Xsucceeding is the inverse of the walls' life.
XThus if a wall has a life of 10, there is a 10% chance of a blast succeeding.
XWhen a wall is successfully blasted, it is simply removed from the board.
XMen can then travel through the opening.
XEven when an attempt to blast fails, it succeeds in using up a turn.
X.PP
XUnlike fighting, blasting is not an implicit activity.
XMen only attempt to blast when you direct it.
XThis is because much harm can occur from misdirected blasting (especially
Xin your own maze).
X.PP
XWhen combined with movement commands, blasting can automatically punch a
Xhole through multiple walls.
XTo do this you specify that the man blasts in a direction, and then moves
Xin the direction.
XWhen blasting is possible, the man blasts.
XWhen blasting is not possible (because the wall is gone), the man moves.
X.PP
XYou should be careful of losing all of your blasting men, because if you
Xdo so then you cannot do anything about the opponent's maze defense.
X.SH "PLAYING COMMANDS"
XFollowing are the commands used in the playing phase of the game.
XThese commands can be preceeded by an optional number, which is a
Xrepeat count.
XThey can be edited before they are complete by using the normal
Xediting characters.
XA partial command can be cleared by typing an escape character.
X.TP 6
X.B h
XMove to the left when possible.
XA missing count means move left by one location.
X.TP
X.B j
XMove downward when possible.
X.TP
X.B k
XMove upward when possible.
X.TP
X.B l
XMove right when possible.
X.TP
X.B H
XMove to the left when possible.
XA missing count implies an infinite movement.
X.TP
X.B J
XMove downward when possible.
X.TP
X.B K
XMove upward when possible.
X.TP
X.B L
XMove to the right when possible.
X.TP
X.B F<dir>
XFight the man in the specified direction when possible.
XThe direction character can be one of the four characters 'h', 'j', 'k', or 'l'.
XAlso, 'a' picks randomly among all directions where men can be fought.
XFinally, 'n' fights in no direction at all.
X.TP
X.B B<dir>
XBlast a wall in the specified direction when possible.
XThe direction characters are the same as in the 'F' command.
X.TP
X.B <space>
XIf a null command is given, then this causes the man to stop and return
Xto the idle state.
XIn this state, fighting still occurs if possible because of the implicit
Xfight command.
X.TP
X.B ^L
XRedraw the screen to fix glitches.
XThis command does not need any terminating space or carriage return.
X.PP
XThe following gives some examples of commands to give to men.
XIn the following, "<sp>" represents the space character.
X.sp
X.TP 15
X.B aL4j<sp>
XTell man 'a' to move as far as possible to the right, and to move a total
Xof four rows down.
XThe rightmost movement is to occur first when possible.
X.TP
X.B ybkK<sp>
XTell man 'y' to try to blast a wall directly above him, and when there is
Xno wall to blast, then try to move up.
X.TP
X.B cfjfh<sp>
XTell man 'c' to fight a man directly down from him, and if there is no
Xman there, then fight the man to his left.
X.TP
X.B b<sp>
XTell man 'b' to do nothing.
XHowever, if any enemy is next to him, he will fight them.
X.TP
X.B efn<sp>
XTell man 'e' to really do nothing, not even fight.
X.SH AUTHOR
XDavid I. Bell
X.SH BUGS
XIf the two players don't use the same object file, havoc will result.
XMultiple setups in a setup file by the same name should be detected.
XThe other player should be notified that you are ready to play.
XPlayers should be able to send messages to each other.
XThere is no way to temporarily stop the game (except for using ^Z).
XThere is no code for determining when the game is won, so the game
Xwill keep playing until one player quits.
//E*O*F war.6//
echo x - objects.war
sed -e 's/^X//' > "objects.war" << '//E*O*F objects.war//'
X# Object definition file
X# Possible characters in the flags field:
X#   b	object can blast walls
X#   f	object can fight men
X#   g	object is a goal
X#   i	object is immobile
X#   t	object is transparent
X#   v	object is always visible
X#   w	object is a wall
X#   x	object has x-ray vision
X#
X#flags	display	life	view	min	max
Xw	**	10	0	0	1000		# normal walls
Xtw	..	5	0	0	1000		# windows
Xvwx	++	10	4	0	2		# sentry posts
Xf	A1	25	3	1	1		# best men
Xf	B1	25	3	1	1
Xf	C1	25	3	1	1
Xf	D2	20	2	1	1		# secondary men
Xf	E2	20	2	1	1
Xf	F2	20	2	1	1
Xf	G2	20	2	1	1
Xf	H2	20	2	1	1
Xfx	X3	15	2	1	1		# x-ray vision man
Xb	Y4	30	2	1	1		# wall eater men
Xb	Z4	30	2	1	1
Xgi	##	50	4	1	1		# goal
//E*O*F objects.war//
echo x - boards.war
sed -e 's/^X//' > "boards.war" << '//E*O*F boards.war//'
X"a"
X*    *                      *   *
X*  *   ****************** *   * * * ***********
X****** *             *  * ******* *          *
X ** **** ********* *    * *#      * ******** * *
X      **    *   *   ***** ********* * *   *  *
X ******  ** * *   *                 *   *    **
X ******* ** ************************************
X                                          E X
X**********BDC*****H*****G***F*************Y Z***
X***********A******************************* ****
X"b"
X        * *                        *
X ******** * *************** **** * * *** *** **
X        *   *      * *      **#* * * * * * * *
X******* ********** * ********* * * * * * * * * *
X *           *     *         * * * * * * * * *
X ***** ******* ************* * *** * * * * * **
X *                                 * * * * * *
X   ********* ***F****************  *** * * ***GH
X**           +*CED            Z*+            *XY
X***************B.A******************************
X"teeth"
X * * * * * * * * * * * * * * * * * * * * * * * *
X * * * * * * * * * * * * * * * * * * * * * * * *
X * * * * * * * * * * * * * * * * * * * * * * * *
X * * * * * * * * * * * * * * * * * * * * * * * *
X                                               *
X********************************* **************
X* * *X* * * * * * * * *Y* * * * * * * * * *Z* *
X* * * * * * * * # * * * * * * * * * * * * * * *
X* * * * * * * *G***H* * * * * * * * * * * * * *
X* * * * * *A*B*C*D*E*F* * * * * * * * * * * * *
X"rooms"
X     *      *       *      *      *      *
X****   ****   *****   ****   ****   ****   ****
X    * *    * *     * *    * *    * *    * *   *
X ** * * ** * * *** * * ** * * ** * * ** * * * *
X *  * * *  * * *#* * * *  * * *  * * *  * * * *
X  * * * *  * * *C  * * *  * * *  * * *  * * * *Z
X*  ** * **** * ***** * **** * **** * **** * ***F
X**    *              *             *        XGDE
XY**********************************************B
XH****+ ************** ************* ****** +***A
X"stronghole"
X       *            **  E  *   F*****      *
X *************** *** ***#*   **       **** * ***
X             * * * *  *******  G***** *  * * *
X************ * * * * *  *   **      * *  * * *
X        YZC
X********X**************************************
X    *  DAB *                 **           **
X* ***  * * ******* ************ ************ ***
X       * *
X********H***************************************
X"sinewave"
X          **               *  *      *
X**** *** *** *** **** **** *  * *  * *  * *
X      **       *    *    *      *  *C*  * *
X *******.***************************#*****  ****
X ****   ******* * ** * ** * **   *******   *****
X      *         *    *    *    *    *    *
X***** * *******   **   **   ** * **   ** * ****F
X***** ***************************************  E
X  HXY                  D                     ZGB
X** ************+****************+**************A
X"badsides"
X     ** ***         C#** *   **
X * * **     ************   *  * * ****   ** ***
X *   **  ***        ** * **   * * **   * **   *
X ******  *   ******    * *  **  * ** * * ******
X      **   ************  * *   *  ** *  **    *
X   *   **  **        *  *  * **  **    **   *
X******  **  *******  * **    *  **  ****  ******
XYG  *  **              *  *  ** **  ** **  * EXZ
X F*   **  **************   *  * **      **   *D
X*A************+*******H*******+***************B*
X"diag"
X*       *     *     *     *     *     *       C
X  *   *  *  *  *  *  *  *  *  *  *  *  *  *  * #
X *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  **
X  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
X*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
X *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
X  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
X      *  *  *     *     *     *     *     *    *
X ****  *      *  *  *  *  *  *  *  *  *  *  *  Z
XGABYE***************X**F**H********************D
//E*O*F boards.war//
echo x - makefile
sed -e 's/^X//' > "makefile" << '//E*O*F makefile//'
X# @(#)makefile	1.1	4/5/85
X# @(#)
X
XCFLAGS = -O
XCC = cc
X
XCFILES = main.c talk.c cmd.c view.c init.c scan.c
XOFILES = main.o talk.o cmd.o view.o init.o scan.o
X
Xwar:	${OFILES}
X	${CC} -o war ${OFILES} -ldpy -ltermlib
X
X${OFILES}:	war.h
//E*O*F makefile//
echo x - war.h
sed -e 's/^X//' > "war.h" << '//E*O*F war.h//'
X/*
X * @(#)war.h	1.1	4/5/85
X * @(#)Copyright (C) 1985 by D Bell
X */
X
X#include <stdio.h>
X#include <setjmp.h>
X#include <signal.h>
X#include <errno.h>
X#include <sgtty.h>
X
X#define	GAMEDIR	"/tmp"			/* for UNIX domain socket names */
X#define	LIBDIR	"/usr/games/lib"	/* object file library area */
X#define	OBJECTFILE "/usr/games/lib/objects.war"	/* default object file */
X#define	SETUPFILE ".warsetups"		/* default setup file in user's HOME */
X
X#define	ROWS	24		/* rows on board */
X#define	COLS	48		/* columns on board */
X#define	HOMEROW	9		/* last row of my home area */
X#define	DATAROW	17		/* row where data statistics go */
X#define	INFOCOL	(COLS + 3)	/* leftmost column of information area */
X#define	OBJS	50		/* max number of objects */
X#define	CMDS	20		/* maximum number of commands */
X#define	INFINITY 10000		/* "infinite" loop value */
X
X#define	SCAN_SIZE 100		/* buffer size for scanning */
X#define	SCAN_EDIT 2		/* kinds of scan longjmps */
X#define	SCAN_ABORT 3
X#define	SCAN_EOF 4
X
X#define	STDIN	0		/* normal file descriptors */
X#define	STDOUT	1
X#define	STDERR	2
X
X
X/*
X * Stored commands for execution by an object
X */
Xstruct	cmd	{
X	char	c_type;		/* command type */
X	char	c_subtype;	/* subtype */
X	short	c_count;	/* repeat counter */
X};
X
X
X/*
X * Information about each object in the game (walls, men, goals, or edges).
X * Singly placed objects point to the cell the object is at.
X * Multiply placed objects (such as walls) have a NULL pointer.
X * In all cases, each cell the object is at points back to the object.
X */
Xstruct	object	{
X	short o_flags;		/* flags about object (see below) */
X	short o_id;		/* unique id for object */
X	short o_life;		/* hit points left */
X	short o_min;		/* minimum number of this object to place */
X	short o_max;		/* maximum number of this object to place */
X	short o_count;		/* current count of objects on board */
X	char o_view;		/* viewing range of object */
X	char o_side;		/* which side object is owned by */
X	char o_ownch;		/* object as seen by its owner */
X	char o_altch;		/* object as seen by others */
X	struct cell *o_cell;	/* cell object is at if a single object */
X	struct cmd o_cmds[CMDS];	/* current command list */
X};
X
X
X/* Flags in the o_flags field of an object */
X#define	F_FIGHT 0x1		/* object can fight others - 'f' */
X#define	F_BLAST	0x2		/* object can blast walls - 'w' */
X#define	F_IMMOB	0x4		/* object is immobile - 'i' */
X#define	F_GOAL	0x8		/* object is a goal - 'g' */
X#define	F_WALL	0x10		/* object is a wall - 'w' */
X#define	F_XRAY	0x20		/* object has x-ray vision - 'x' */
X#define	F_TRANS	0x40		/* object is transparent - 't' */
X#define	F_VIS	0x80		/* object is always visible - 'v' */
X#define	F_MOVED	0x100		/* object has moved this turn */
X#define	F_EDGE	0x200		/* object is an edge */
X
X/* Macro to find the proper character for an object */
X#define	objectchar(obj)	(((obj)->o_side==myside)?(obj)->o_ownch:(obj)->o_altch)
X
X
X/*
X * Information about each location on the board.  Each cell has a pointer
X * to the object which is at that cell, if any.  Cells are linked together
X * in various ways to make it easy to move to adjacent cells.  The edges of
X * the board are linked to a special 'edge' cell.
X */
Xstruct	cell	{
X	unsigned char c_row;	/* row that this cell is for */
X	unsigned char c_col;	/* column that this cell is for */
X	char c_seen;		/* object is seen by the player */
X	struct object *c_obj;	/* object at this location */
X	long c_checkcount;	/* counter for board validity checking */
X	struct cell *c_next;	/* next cell on board */
X	struct cell *c_dirs[8];	/* pointers to other cells (see below) */
X};
X
X
X/* Directions.  The first four must be the orthagonal directions. */
X#define	c_up	c_dirs[0]	/* next cell upwards */
X#define	c_right	c_dirs[1]	/* next cell to the right */
X#define	c_down	c_dirs[2]	/* next cell downwards */
X#define	c_left	c_dirs[3]	/* next cell to the left */
X#define	c_ul	c_dirs[4]	/* cell to upper left */
X#define	c_ur	c_dirs[5]	/* cell to upper right */
X#define	c_ll	c_dirs[6]	/* cell to lower left */
X#define	c_lr	c_dirs[7]	/* cell to lower right */
X
X
X
X/*
X * Information which is transferred between the players.
X * When it is a player's turn to transmit, as many of these messages are
X * sent as is necessary.  The last such message has a type of 'r' as a
X * signal that it is the opponent's turn to transmit.
X */
Xstruct	info	{
X	unsigned char i_type;	/* type of information */
X	unsigned char i_row;	/* row number */
X	unsigned char i_col;	/* column number */
X	short i_id;		/* id of object */
X};
X
X
X/*
X * Statistics about the games which is known to both players.
X * There is one of these structures for each player.
X */
Xstruct	data	{
X	short d_fightmen;	/* count of fighting men */
X	short d_blastmen;	/* count of blasting men */
X	short d_movemen;	/* count of moving men */
X	short d_goalmen;	/* count of goal men */
X	short d_totalmen;	/* total number of men */
X	short d_fightlife;	/* total life of fighting men */
X	short d_blastlife;	/* total life of blasting men */
X	short d_movelife;	/* total life of movable men */
X	short d_goallife;	/* total life of goal men */
X	short d_totallife;	/* total life of all men */
X	short d_totalwalls;	/* total number of walls */
X};
X
X
Xextern	int	errno;			/* error value */
Xchar	myside;				/* what side I am on */
Xchar	newstat;			/* need new status display */
Xchar	playing;			/* actually playing now */
Xchar	editflag;			/* just want to edit some setups */
Xchar	*objectfile;			/* file name for reading objects */
Xchar	*setupfile;			/* file name for board setups */
Xchar	*setupname;			/* setup name to read in */
Xchar	*enemyname;			/* login name of the enemy */
Xchar	*enemytty;			/* tty name of the enemy (if given) */
Xstruct	object	*endobjects;		/* end of active objects */
Xstruct	cell	*firstcell;		/* first cell of whole board */
Xstruct	cell	*homecell;		/* first cell in home area */
Xstruct	cell	edge;			/* edge cell */
Xstruct	object	edgeobj;		/* edge object */
Xstruct	object	objects[OBJS];		/* table of objects */
Xstruct	cell	board[ROWS][COLS];	/* cells of the board */
Xstruct	data	mydata;			/* data for myself */
Xstruct	data	hisdata;		/* data for other player */
Xjmp_buf	ttyjmp;				/* input jump buffer */
X
Xstruct	cell	*pickdir();		/* routine to select a direction */
Xstruct	object	*findobject();		/* routine to look up an object */
Xstruct	object	*findid();		/* find an object by its id */
Xint	ttychar();			/* terminal input routine */
//E*O*F war.h//
echo done
-- 

Erik Bailey        -- 7 Oak Knoll                 (USENET courtesy of
ihnp4!think!ejb       Arlington, MA  02174        Thinking Machines Corp.
ejb@think.com         (617) 643-0732              Cambridge, MA)

	   It takes thought to make a program that thinks.
	   But it takes work to make a program that works.