Olympia II Battle Simulator - version 1.5
=========================================

Olympia II is an all e-mail PBM game run by Shadow Island Games. I don't
have any connection to Shadow Island Games other than as a player.

The battle simulator is a program that can be used to run a series of battle
simulations to determine the probable outcome of a pending battle. The program
tallies the results for all battles and then displays a summary.

A data file 'fight.dat' is used to specify unit characteristics. It is preset
with all the standard units that I know of. It may be edited to include the
characteristics of non-standard nobles or anyone using magic items that
modify their combat ratings. Alternatively these may be supplied along with
the battle definitions when using the -f flag.

The 'fight.dat' must be in the current directory when the program is run.

Running:

  fight -h

Will output full instructions on how to run the program and specify the
participants of a fight.

If you have obtained this from the file 'fight.zip' or 'fight.oly' then it
includes the full source for the program, my OS/2 build files, a 'fight.exe'
that will run under OS/2 or MS-DOS, the 'fight.dat' data file and a file
listing standard tests should you wish to compile it yourself.

If you obtained this from 'fight.tar', 'fight.tar.Z' or 'fight.tar.gz' then
you will only have the source, 'fight.dat' and the list of standard tests.
You will need to compile it on the machine you intend to run it on. You
should run the standard tests to verify that your compiler produces the same
results as mine.

I have compiled it under Microsoft C version 6.00a and various flavours of
UNIX. The make file is for OS/2 and produces a dual mode executable that can
run under both OS/2 and MS-DOS.

Under UNIX you can compile using either:

  cc -O -o fight fight.c

Or if using GNU C you can compile with:

  gcc -DGCC -O2 -o fight fight.c

This will produce an executable called 'fight' which you can run.

To do the standard tests run:

  fight -ftests >tests.out

Visually compare 'tests.out' against the supplied 'tests.ex' for major
differences. Don't bother using diff as it will spot too many differences to
be useful!

There are four environment variables that can be used to modify the
programs behaviour:

  FIGHT_RUNTIME      Maximum number of seconds simulation is to run for. A
                     value of 0 (the default) means no limit.

  FIGHT_BATTLETIME   Maximum number of seconds a single battle is to run for.
                     A value of 0 (the default) means no limit. This is the
                     upper limit for the -t flag.

  FIGHT_INTERVAL     Number of seconds that is to elapse between progress
                     messages. Default is 10 seconds.

  FIGHT_MAXLINES     Maximum number (approximately) of lines of output the
                     program is allowed to generate.

On MS-DOS and OS/2 these are set by the SET command, eg:

  SET FIGHT_RUNTIME=120

On UNIX they are set by variable assignment and must be exported, eg:

  FIGHT_RUNTIME=120
  export FIGHT_RUNTIME

This program no longer uses any floating point arithmetic (version 1.0 did)
and so there should not be any problem running it on machines without math
co-processors.

If you have any problems please let me know.

DISCLAIMER: This program implements my interpretation of the Olympia II
            combat rules. I do NOT warrant that they match Rich Skrenta's
            implementation of the same. This program aims to give you an
            idea of the likely outcome of a battle. It does not make any
            guarantees about what the real game outcome will actually be.

Ross Inglis

Compuserve: [100115,1665]
Internet:   R.A.Inglis@bra0801.wins.icl.co.uk

17 Nov 1994

-------------------------------

REVISION HISTORY:

Version 1.5

 - Added angry peasants, inns and put back temples in the fight.dat file.
   Inns and temples do not add any defense but can be damaged

 - As I have finally seen some castles in the game, the castle defense
   bonus has been increased to the correct value of 40

 - Wind and rain now reduce the value of troops for purposes of calculating
   when they break

 - The -a -d and -b flags can now all be optionally followed by an integer
   that specifies the break percentage, eg. -d10 means defender breaks when
   his total value is reduced to 10% of his starting value

 - Added -t flag to set maximum run time from the command line parameters.
   The FIGHT_RUNTIME will determine the upper limit that may be specified for
   this flag. If no -n flag then the number of battles simulated will be as
   many as can be done in the time specified. Note that this is checked only
   at the end of the current battle

 - Flags followed by numbers can now have a space character or two that
   separate the flag from the number

 - Added new "-f filename" parameter. This will let a number of different
   battles be fought. Lines in the specified file beginning @ are added to
   the unit definitions and follow exactly the format of the fight.dat file.
   Lines beginning with anything except # or @ specify a battle and follows
   exactly the same format as command line parameters including all flags.
   Empty lines or lines beginning with # are treated as comment lines. Lines
   ending with \ are continued on the next line. Any command line parameters
   become the defaults for the battles specified in "filename".

 - Combat factors for troops at sea have been added. This is optional and
   is indicated by an integer value in parentheses that follows the normal
   attack or defense value. Troops are considered to be at sea if they are
   inside a ship

 - Have included blessed soldiers. In the fight.dat file specify this as an
   extra field following the missile factor. This will get an nn% save versus
   death. Default for nn is zero, ie. no save vs death

 - Added FIGHT_BATTLETIME and FIGHT_MAXLINES environment variables

 - Included a summary of total average casualties for each side, similiar to
   what you get on a real battle report

 - Corrected an error in damage inflicted by a catapult. It used to only
   reduce the fortifications defense bonus by 1 on a successful hit. Now
   it does the full 5-10. Structure damage was unaffected. Also it would
   occasionally give a fortification 2 times the defense it should have

 - A CTRL+C interrupt will now terminate the run at the end of the next
   battle, results for the battles run will be displayed before terminating

 - No longer rely on a rand() function from stdlib.h or elsewhere. I have
   taken a standard textbook algorithm so you should no longer have to
   worry about the wide variations in how rand() seems to be implemented
   between different compilers. It should work for all implementations which
   implement 'long' as 32 bits or greater.

 - Only show win chance, no longer bother with loss chance as it plus win
   chance are always 100% in this version (in a very earlier prototype there
   used to be a certain percentage of unresolved battles as well).

 - Corrected bug where n@2[n] was transferring behind status of first number
   to the inner noble as well.


Version 1.4

 - Squashed a bug in the defender selection code that could result in a
   null pointer being referenced while using troops that are behind others

 - Fixed some more porting problems for different environments. In particular
   all 'short' types have been changed to 'int' to avoid standard library
   problems where an 'int' is expected

 - Improved validation and error reporting on data file and parameters

 - Fixed a second defender NULL pointer problem that occurs when there are
   seige engines behind which successfully destroy the opposing fortification

 - Wind and Rain switches were only working if they were put in front of
   force declaration parameters. Have fixed it so they now work anywhere


Version 1.3

 - Defender now fights to the death by default. New flag -e sets both
   attacker and defender back to NOT fighting to the death. This is my
   attempt to stop people complaining when they run simulations without
   any flags set then find they lose a real battle that they thought
   they would win

   THIS MEANS IF BOTH SIDES ARE IDENTICAL WITH DEFAULT FLAGS THEN THE
   ATTACKER WILL LOSE 100% OF THE TIME!

   Use the -e flag to put this back to 50/50

 - Made some performance improvements

 - Changed the blow by blow battle trace again

 - Removed tem (temple) from fight.dat as they don't appear to have any
   defense value

 - Program detects if output is going to the console, progress messages are
   only displayed if it is. Progress messages appear every 15 seconds now.
   Interval can be changed by setting the FIGHT_INTERVAL environment variable

 - The environment variable FIGHT_RUNTIME can be set to limit how long the
   program will run for regardless of how many battles are requested ( I know
   of a mail server that will find this useful ). Setting this to 0 (the
   default) will let it run without a time limit

 - Program will now print its version number whenever it is run

 - Added na (noble archer) to the fight.dat file

 - Command line parameters are reflected to standard out

 - Had some trouble getting it to work on the two unix systems I can access
   so rewrote the fight.dat parsing to use more reliable library functions.
   This seems to have gotten rid of the segmentation fault/violation that
   one could sometimes get when trying to run 'fight'


Version 1.2

 - Corrected typo that can cause a segmentation error if behind status
   is used (result of algorithm change at version 1.1)

 - Tightened up the validation of parameters a bit more


Version 1.1

 - Removed all floating point operations.

 - Allows: '(' instead of '['
           ')' instead of ']'
           ':' or '!' instead of '*'
   on the command line.

 - Corrected gross misinterpretation of the combat rules. Previous version
   would select an attacker only from 1 side and alternate whose side it
   would pick from. This version now correctly (or so I believe) picks an
   attacker from all eligible attackers on BOTH sides.

 - Parameter 'n[30s]' now gives an error rather than having you fight with
   30 nobles and 1 soldier.

 - Made some minor changes to make porting easier, no longer uses obscure
   subroutines like stricmp and memicmp. Porting to unix should now only
   require the removal of CR characters from the source.


Version 1.0

 - First public version
