NAME

xbattle - a multi-user battle strategy game

SYNOPSIS

xbattle [-<color> <display>...] [-<option> <argument>...]
Assign a team color and display to each player, and any
number of options with argument where required. <color>
can be a monochrome tone, -black -white -gray1 -gray3, or a
color, -red -green -blue -cyan -magenta -yellow; <display>
is the name of the x display for each player. Command
line arguments can be supplied in any order.

RUN-TIME COMMAND SUMMARY

LEFT MOUSE: toggle command vector to move troops
MIDDLE MOUSE: clear all commands and set new command vector
RIGHT MOUSE: artillery or paratroops
SHIFT-RIGHT MOUSE: paratroops
CONTROL-C or CONTROL-Q: exit the game
CONTROL-G: ring bell on all game displays
ANY OTHER CHARACTER: append to message string on all
displays

DESCRIPTION

xbattle is a concurrent multi-player battle strategy
game that captures the dynamics of a wide range of
military situations. The game board is a matrix of game
squares which can be occupied by troops of various colors
or shades. The number of troops in a square is
indicated by the size of a colored troop square within
the game square. The troops are commanded by clicking the
mouse near the edge of the square in the direction that
the movement is to take place. The command will be
acknowledged by the appearance of a command vector,
and thereafter, in each update cycle, a certain proportion
of the troops will move from the source square to the
destination square until the source square is exhausted.
Command vectors can be set in several directions at once,
in which case the movement is divided evenly between
the vector directions, and the command remains active until
cancelled. Thus a trail of squares can be set up as a
supply line that will deliver troops steadily at its
endpoint. The game is concurrent, so that commands are
given continuously by all players without waiting for
turns. Different combinations of options create radically
different games, see EXAMPLES below.

Team Colors and Displays (-)

The game is started from one display, and each player must
play from a separate display, players being assigned to
a color team by the command line option "-<color>
<display>". The parameter <color> determines the color
of the troops of that team, which can be either a monochrome
tone like black, white, gray1, grey3, or a true color like
red, green, blue, cyan, yellow and magenta, although the
true colors will appear on a monochrome monitor as either
black or white with an identifying character in each troop
square which is the first letter of the color name. So
for instance, the team color "-red" would appear on a
monochrome monitor as black with a letter "R" in the
middle of each troop square. A number of people can be
assigned to the same team by repeating the color for
different displays, for example "-red display1 -red
display2", and each member of the team will be able to
command any troops of that team. The <display>
argument designates the name of the display on which the
team of that color is playing, so each player must be given
a color and a display. Display names can be found with
the unix command "who", which will list display names for
users in the last column like (cnsxk:0.0). The system
console is always designated unix:0.0. The display name can
be modified for remote games, for example the terminal
cnsxk:0.0 on park.bu.edu (email address of machine
"park") is designated cnsxk.bu.edu:0.0 . Xbattle
recognizes :0.0 as the default (screen zero on the
display), so the :0.0 may be omitted from the display
name. Xbattle also recognizes a special display name
"me", which means the display from which the program is
started. Colored teams are displayed on a monochrome
monitor in black or white, with the first letter of the
color appearing in each troop square of that color.
When playing between color and monochrome displays the
colors can be specified more exactly by concatenating a
color name with a monochrome name, for example "-redwhite"
(color first), which would display that team as red on
color monitors and white on monochrome monitors. All
command line flags and arguments for the game can be given
in any order as long as the argument directly follows its
flag, and most arguments are scaled to range from 1 to 10,
with 5 being the default value.

Troops (-bases, -rbases, -armies, -militia)

Initial troop allocation is controlled by several command
options, including -bases <n>, -rbases <n>, -armies <n>
and -militia <n>. Armies and militia are troops on the
gameboard, whereas bases which are indicated by circles on
the gameboard, provide a steady supply of troops. The -
bases option allocates <n> bases to each team,
symmetrically arranged on the game board, whereas -rbases
<n> arranges them randomly (which works well with the
-horizon option). The -armies option allocates <n> armies
(full troop squares) symmetrically arranged, whereas
-militia <n> scatters militia of random strengths to random
locations, with a probabilistic density of <n>. At least
one of these four options is required to provide initial
troops for the game, and they may be used in combination.
The -bases and -armies options will only work for four or
less teams.

Resupply (-towns, -farms, -decay)

The bases created by the -bases or -rbases, produce a steady
supply of fresh troops. The bases can be occupied by an
opposing team, and the troops produced by such bases are
always the color of the occupying force. The capture of
all bases thus becomes the strategic objective of the
game. This arrangement simulates desert warfare, as long
and tenuous supply lines develop between the base and the
battle areas. Another form of resupply is provided by
the command option "-towns <n>". This produces a number
of smaller unoccupied supply sources scattered randomly
over the game board at a density determined by the argument
<n>, and with random rates of troop production, indicated
by the radius of the circle on the game board. Towns must
be occupied by a team to begin producing troops. This
option simulates yet a larger scale of operation as the
combatants battle to occupy the towns. A more distributed
form of resupply is evoked by the command option "-farms
<n>" whereby every square of the game board will
produce troops as soon as it is occupied, at a rate
proportional to the argument <n>, and the strategic
objective becomes the occupation of the largest areas of
the gameboard. This option simulates a yet larger
scale of operation and requires complex management of
resources to concentrate the distributed resources and
deliver them to the battle front. In large scale
scenarios additional realism may be added by using the
-decay option whereby the troop strength in all troop
squares decays constantly in proportion to the value of
the decay argument. This reflects the fact that armies
constantly consume resources even while they are idle, and
an army without constant resupply will wither away.
With the decay option, a set of bases, towns or farms can
only support armies of limited size, and the armies will
dynamically grow or shrink until they reach that size.
Since this number includes the troops that make up the
supply line, the fighting power of an army diminishes
with the length of the supply line. The default decay
value is zero, i.e. no decay. All the resupply
options can be used in any combination.

Interactive commands (mouse and keyboard)

Movement commands are performed with the left and
middle mouse buttons, to direct the command vector. A
click in the center of the game square clears all command
vectors; a click near an edge sets the vector in that
direction, and a click near a corner sets the two
adjacent vectors. The left mouse toggles command vectors
while the middle mouse clears existing vectors and sets a
new vector. The right mouse is used for artillery or
paratroop operations when the -guns and or -para options
are active, and if both -guns and -para are active then
the right mouse is for artillery and the shifted right
mouse (press SHIFT key and click right mouse) is for
paratroops. The keys control-c and control-q both exit the
player from the game, although the game continues among the
remaining players until they also quit. The rest of the
keyboard is used for communication between
participants through a pair of text lines at the
bottom of the gameboard. This is especially useful
when playing between remote sites, and the color of the
text matches the color of the team who sent the message.
The control-g key rings the bell on all displays, which
can be used to draw attention to a new message.

Combat (-fight, -disrupt)

Whenever troops of different colors occupy the same game
square, a battle ensues, indicated by concentric squares of
the two colors, and a "crossed swords" (X) symbol. During
battle, one or both sides can incur losses according to
a random nonlinear function that disproportionately
favors the more numerous troops. The steepness of the
nonlinearity, i.e. the advantage given to the more numerous
side, is controlled by the -fight parameter. A small
value will produce lengthy drawn out battles which favor a
defensive strategy, whereas a large value produces quick
decisive battles where the random element is more
significant, favoring an offensive strategy even against
superior odds. In the absence of the -fight option, the
default value of 5 is used. The -fight parameter is also
automatically modulated by the game speed parameter (-
speed) in order to slow down battles in fast games and
vice versa. Since only 1/3 of the troops can enter a
square in each update cycle (with the default -move 5),
attackers of a full square are always outnumbered
initially, unless a coordinated attack is launched from
three sides simultaneously. The -move argument thus
has a significant influence on the efficacy of an
attack. The -disrupt option dictates that when a game
square comes under attack, all its command vectors are
immediately cancelled, breaking supply lines which must be
repaired by hand after the attack. In other words, there
can be no movement under fire, and even small forces can
be used to provide covering fire to "pin down" a larger
force, at least until they are counter-attacked and
eliminated. A side effect of this option is that
when an attacking square is counterattacked, both squares
attemp to cancel each other's movement, i.e. to interrupt
the attack. The square that is updated next will prevail,
cancelling the command vector of the other square. Since
the game squares are updated in a random sequence, there
is no telling which square will prevail, and the commander
must click repeatedly to renew the command vector in
order to press home the attack under opposition. This
simulates the tactical situation where a commander must
personally intervene to ensure the maximal effort is
applied at the most critical points of the battle.

Guns and Paratroops (-guns, -para)

The command option -guns <n> enables the right mouse to
be used to control artillery, which can be shot from any
occupied gamesquare. The range and direction of the shot
are determined by the position of the click in the game
square, near center for short range and near the edge for
long range, as modulated by the argument <n>. Every
shell costs one troop from the source square and destroys
one troop at the destination square. The fall of shot
is indicated by the brief appearance of a little dot. With
the -horizon option the fall of shot may not be visible
for long range shots, although invisible enemy troops
will be destroyed where the shell falls. Artillery can
damage both friend and foe, so it must be used with caution.
Paratroops are enabled by the option -para <n>, and
are launched similarly to artillery using the right
mouse button, unless both -guns and -para are both active,
in which case the shift key must be depressed while
pressing the right mouse for paratroops. The cost of
dropping one troop at the destination square is three
troops from the source square, and the drop zone is
indicated by the brief appearance of a parachute symbol.

Environment (-hills, -forest, -sea, -wrap, -seed)

The command option -hills <n> initializes random hills
which restrict movement when going from low to high
elevation, and enhance movement from high to low, but do
not affect movement on the level. The elevation is
indicated by the shade of gray, light for high and dark for
low on monochrome, and brownish for high and greenish for
low on color displays. The argument controls the amount of
energy gained and lost on hills, i.e. the steepness. Hills
provide a tactical advantage when attacking downhill. With
very steep hills (-hills 9) movement from very low to
very high elevation (a cliff) is virtually impossible.
The command option -forest <n> initializes random forests
which restrict movement within the forest, but do not
affect movement from thin to thick forest. On both color
and monochrome displays, thick forest is dark, and thin
is light. When used in conjunction with hills, the
forests thickness correlates exactly with hill
elevation. When transitioning from one forest thickness
to another, the movement is determined by the destination
square, not the source square, so that troops deployed
within a forest but at the boundary have a tactical
advantage over those deployed outside the boundary. The
command option -sea <n> generates randomly distributed
bodies of water, whose prevalance is determined by the
argument <n>. Such bodies of water cannot be crossed by
infantry. A small value creates scattered ponds and lakes,
which influences the tactical deployment of troops, whereas
a large value creates a maze-like pattern of fjords or
rivers which isolate blocks of land into islands which
can only be taken by paratroops. On monochrome monitors
water appears dark grey unless there are hills or
forests, in which case the water appears black. On color
monitors water is always pale blue. The command option
-wrap (no arguments) allows wrap-around on the gameboard.
The command option -seed <n> allows control of the random
number seed, otherwise selected based on the process ID,
and printed to the text line. Using the same seed will
reproduce the same configuration of hills, towns, seas and
militia.

Visibility (-horizon, -hidden, -grid)

The command option -horizon (no arguments) restricts the
view of enemy troop deployment to within two squares of
any friendly troops. Intelligence of more remote
regions can be gathered by use of paratroops. The
command option -hidden (no arguments) makes the command
vectors of the enemy invisible at any range. The option
-grid (no arguments) displays a grid on the game board to
help locate the gamesquares. This is especially useful for
novice players, or for use with artillery and paratroops.

Game Parameters (-move, -speed)

In each update cycle some fraction of the troops in a game
square move to adjacent squares indicated by the command
vectors. The default fraction is 1/3, so that in each
successive cycle, 1/3 of the remaining troops move out
of the square until it is empty. That fraction is
adjusted with the -move argument, 1 for less movement, and
10 for more movement. The -speed <n> option controls the
speed of the update cycle, making for a fast or slow
game. A fast game favors quick reaction time and fast
action, whereas a slow game favors strategy and
intellect.

Store and Replay (-store, -replay)

The -store <file> option allows you to store the
graphics drawing commands to a file, which can be viewed
later with the -replay <file> option. When -replay is
used, all other command options are ignored except the
-<color> <display> options, which can be used to send the
replay to other displays. When doing so, only the
<display> portion of the option is used, the <color> is
ignored. So, if you play a game with many command line
parameters and several displays with the argument -store
<file>, after the game you can repeat the same command line
but just change -store to -replay, and the game will be
replayed on the displays of all the original
combatants. When xbattle is called with the -replay
option alone, the default display will be "me". If store
or replay are called without a file name, the default name
"xbattle.xba" will be used. In the replay, the view
restrictions of the -horizon option are deactivated, i.e.
all enemy troops are visible.

EXTENSIONS

A great deal of effort has been made in the design of
this game to make it as simple and modular as
possible, with extensive documentation throughout the
source code, in the hope that others will create new and
exciting variations of the game while maintaining the
elegance and modularity of the original design. I would
be grateful if such variants were sent to us at
slehar@park.bu.edu and lesher@park.bu.edu to be combined
into a new version reflecting the best of the
modifications.

EXAMPLES

Here are some example games to give an idea of the
variability of the parameters. The first example is a
simple symmetrical game between "me" in black on my own
display, and a white opponent on the display "cnsxk:0.0".
The troops will be rapidly exhausted in this small
skirmish. The grid option is also used to help a beginner
learn the limits of the game square.
xbattle -black me -white cnsxk:0.0 -armies 4 -grid
The next example adds bases, which will produce a much
prolonged conflict involving long supply lines between the
front and the bases, much like desert warfare. One
conflict in this battle represents a skirmish like the
entire game of the previous example. In this example
black is playing on the display cnsxk:0.0, and white is on
the system console. Note that the extension ":0.0" can be
omitted.
xbattle -black cnsxk -white unix -armies 4 -bases 2
The next example is a game with militia scattered around
initially, that have to race to occupy the towns and
link up with their compatriots before they can eliminate
the enemy. This is a dynamic scenario requiring tactical
and strategic skill and fast reflexes. In this example
black is playing on cnsxk:0.0 while white is playing on
the system console of the remote machine thalamus.bu.edu.
xbattle -black cnsxk -white thalamus.bu.edu -towns 2
-militia 2 -hills 7
Here is a favorite around B.U. where the land is broken
up by many bodies of water creating isolated islands, and
view of the enemy is restricted to nearby squares,
resulting in lots of surprises. Paratroops can be
used for reconnaisance by launching them into unknown
sectors, and they must be used in conjunction with
heavy artillery barages for airborne assaults from one
landmass to the next. In this example the color display
will show cyan and red teams, while the monochrome monitor
will show white and black teams respectively. The decay
option prevents huge armies from building up at the end of
the game, and the -store option is used to store this game
to the file "battle.xba"
xbattle -cyanwhite thalamus:0.0 -redblack cnsxk -rbases 5
-sea 8 -guns 4 -para 4 -horizon -decay 3 -store xbattle.xba
Now, the previous stored game is replayed to the original
displays by repeating the original command line except that
-store is changed to -replay. This is convenient if
you have command line editing facilities.
xbattle -cyanwhite thalamus:0.0 -redblack cnsxk -rbases 5
-sea 8 -guns 4 -para 4 -horizon -replay xbattle.xba
With -replay, all arguments are actually ignored except the
displays, so you could achieve exactly the same result with
the simpler command
xbattle -black thalamus:0.0 -black cnsxk -replay
where the -black argument flags the subsequent
argument as a displayname, but is otherwise ignored,
i.e. any color name would suffice. The filename for
-replay is omitted, so that the default file name
"xbattle.xba" is used.

PLAYING TIPS

The first thing you must learn is to click quickly and
accurately on the gamesquares. For beginners, the -grid
option is recommended to show the extent of the game
square. Do not focus your attention on one region of the
board, but scan the whole board frequently. Look at the
big picture- capture the towns that will support each
other, especially a well positioned cluster of big
towns. Eliminate all enemy troops from your rear, and
advance outwards, preferably from a corner, with a well
supplied front. Travel in convoy for speed and efficiency
in safe regions, especially if you are playing with -decay,
but fan out near the enemy to provide alternate routes
to a broad front (click on the corner to open
two command vectors simultaneously). Avoid head-on
assaults on the enemy, but rather dig in and wait for him
to attack while you try to turn his flank and cut off his
supplies to the front, or concentrate at his weakest
points. Go for the jugular- attack his supply sources
directly. When advancing, try to attack weak squares with
strong ones to gain maximum advantage, and be alert for
losing battles of your weak squares pouring into a strong
enemy square, which will drain your resources until you
cancel the attack and build up reserves. If however you are
fighting a delaying action, or retreating under fire then
you should attack strong enemy squares with your weak ones
on a broad front to conserve resources. This is
particularly effective with the -disrupt option. Always
try to attack a square from two or more sides, and build
up sufficient strength before launching an attack on a
large square. Always consider the "manufacturing capacity"
of the enemy, i.e. the number and size of bases and
towns, as the one with the most capacity will eventually
win. Watch out for single enemy commandos near your
unprotected bases, especially when playing with paratroops,
and use such commandos to good effect against an inattentive
opponent. You can keep a base fortified while sending
troops to the front by use of recurrent connections, going
in loops or in both directions, or by establishing dead-end
branches along the supply line to accumulate local
reserves. You should always have a few strong reserves
near your base when playing with -horizon or -para, to
ensure against surprise attacks. When playing with hills,
a cliff is best climbed in parallel, i.e. by splitting the
convoy into multiple parallel paths up the cliff face, and
the troops can rejoin at the top. When playing with horizon
and paratroops use the paratroops to gather intelligence
from beyond the horizon. When playing with paratroops or
artillery, you can create a network of recurrent
connections near the bases that will provide mutual
protection by automatically sending men into any part of
the net that is knocked out. Paratroops are expensive,
so test the aim with artillery (right mouse) before
launching the paratroops (shift right mouse), although this
works only if the -para and -guns arguments are equal.
When using artillery, have a large contingent of infantry
ready to move in immediately after the barage. Paratroops
and artillery are helpful, but it is the grunts that must
actually take the territory.

BUGS

When the -disrupt option is used, the multiple clicks
required to press home an attack can bog down the event
queue and lead to slow execution. Xbattle will only
accept the spelling "gray", although "grey" is an
acceptable alternate spelling in the English language, but
will cause problems for xbattle. The shade "gray2" is
available, although on monochrome monitors it will appear
the same color as the background, therefore this is a
"stealth" color. Some systems do not support the random
functions drand48() and srand48(), so drand48() is defined
but commented out, for your convenience at the end of
the source code in terms of rand(), and can be used by
removing the comment delimiters and editing all
occurances of srand48(seed) to srand(seed).