                    Genetic Warfare - The flexible AI project
                    -----------------------------------------

IMPORTANT !!!
BEFORE YOU START PLAYING, PLEASE READ THE FILE  'QUESTION.TXT'
This file contains the questions about the AI, that I would like you to answer.
It is important that you read through the questions before you play.
When you are done, e-mail your answers to purple@diku.dk.
Try to send your answers before the 1st of December 2000. If you cannot make
this date, send your answers anyway, they may still be useful to me.

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

Requirements
------------

Windows 95+
DirectX 5.0+
Pentium-class CPU
32MB RAM
Graphics card capable of displaying 800x600 in hicolor.


Instructions for playing Genetic Warfare A
------------------------------------------

You are the commander of a small group of military units.
Your aim is to score as many victory points as possible.
The game is in two rounds. In round 1 you are the attacker, while the computer is
the defender. In round 2 you switch sides. The winner is the one who has scored the
most points in total over both rounds.
The game is turn based. In each turn, the attacker first gets to move his pieces,
as well as shoot and perform reload actions. Then the defender gets to act. When
both players have acted, victory points are awarded to the players.


Victory points are awarded for holding certain key locations on the playing field.
On the map, victory point locations are marked with a number, either 25 or 50.
This is the number of points you receive each turn you hold the location. To conquer
a victory location, move a piece into that hex. It is not necessary for a unit to
be positioned on the hex in order to hold it. The location will be under your control
until the enemy moves a unit into the hex.

Each round is 15 turns long.

The attacker and the defender do not start with the same units. The attacker starts
with 8 units: 
  2 infantry, 2 machineguns, 3 tanks and 1 artillery.
The defender starts with 7 units:
  2 infantry, 2 machineguns, 1 tank, 2 artillery.
The defender has the advantage that when the game starts, he holds 3 of the 5
victory locations, while the attacker holds none.


Units
-----

The units in the game have the following characteristics:

           |Accuracy |Soft damage |Hard damage |Shots per salvo |Range    |
---------------------------------------------------------------------------
Infantry   | 85%     | 2 - 3      | 0 -  1     | 1              | 1 hex   |
Machinegun | 60%     | 2 - 3      | 0 -  1     | 3              | 1 hex   |
Tank       | 70%     | 5 - 8      | 4 -  6     | 1              | 2 hexes |
Artillery  | 70%     | 6 - 8      | 8 - 10     | 1              | 8 hexes |

           |Defense |Hit-points |Ammo |Reload cost |Move-points |View range |Type |
-----------------------------------------------------------------------------------
Infantry   | 20     |  3        |  6  | 4 MP       | 4 MP       | 6 hexes   |Soft |
Machinegun | 15     |  3        | 24  | 4 MP       | 4 MP       | 5 hexes   |Soft |
Tank       |  5     | 10        |  4  | 6 MP       | 6 MP       | 4 hexes   |Hard |
Artillery  |  3     |  5        |  4  | 4 MP       | 4 MP       | 4 hexes   |Hard |

Move-points (MPs) are required for any action. Moving costs at least 1 MP per hex,
depending on which type of terrain it is. Shooting also costs MPs. You only need 
1 MP to shoot, but no matter how many MPs the unit has left, it will always use all
of them when it shoots. In other words, you should move your unit first, and then
it can shoot once if it still has at least 1 MP left.

As you can see there are two types of units, soft and hard. The weapons used by the
units, have different damage ratings when aimed at a soft target than when aimed at
a hard target (eg. the rifles and hand-grenades used by infantry have little effect
on hard units like tanks).

When firing on an enemy unit, the shooter's accuracy and the target's defense and the
range to the target, determine the chance to hit. Accuracy is reduced by 20% for every
hex (more than the first) the target is away.
Example 1:
  An artillery unit fires on a machinegun which is right next to it.
  The chance to hit is: 70 (accuracy) - 15 (defense) = 55%
Example 2:  
  An artillery unit fires on a machinegun which is 3 hexes away.
  The chance to hit is: (70 - 15) * 0.80 * 0.80 = 35.2%
Note that in some forms of terrain, the target gets a defense bonus.

With every shot, one unit of ammo is used. Machineguns fire three shots in one salvo,
so they use 3 units of ammo with every attack. A unit can reload at any time.
Reloading takes an entire turn. If you want one of your units to reload, press key 'R' 
on the keyboard. Also, if you try to fire on an enemy, and your unit is out of ammo
and has not used any MPs, the unit will reload automatically.

Hit-points determine how much damage a unit can take. Once its hit-points have been
reduced to 0 or less, the unit is destroyed.

View range determines how far the unit can see. This is explained below in the section
on terrain.


Terrain
-------

There are different types of terrain on the map. The terrain types have these
characteristics:

            |Movement cost |Defense bonus |Cover
--------------------------------------------------
Asphalt     | 1            |  0           |  0% 
Grass       | 1            |  0           | 20%
Bushes      | 3            |  5           | 60%
Forest      | 4            | 10           | 80%
Building    | 1            | 10           | 70%

The movement cost is the number of MPs a unit uses when moving into the hex.

The defense bonus is added to the unit's basic defense rating when it is positioned
in a hex with this terrain type.

Cover is how difficult it is for the enemy to spot the unit. A cover of 60% means
that any enemy unit that has this unit within its view range, has a 40% chance to spot
the unit. Whether or not a unit is visible to the enemy, is redetermined every time the
unit moves, and every time an enemy unit with this unit in its view range, moves.
When your unit is not within the view range of any enemy unit, it is always invisible
to the enemy, with one exception:
Whenever a unit fires its weapon, it becomes visible to the enemy, even when no enemy
unit has it within its view range (muzzle flash and noise makes it visible over
greater distances).


The interface
-------------

Here is a quick explanation of the graphical interface:

The big area on the left is the map window. Position the mouse cursor at the edge
of the screen (not the edge of this window) to scroll across the map. Alternatively
you can use the arrow keys on the keyboard.

When you place the mouse cursor over a unit, some information about the unit will
be displayed in the lower of the two small windows on the right.
When you select one of your own units by left-clicking on it, information about this
selected unit is displayed in the upper of the two windows on the right.

When a unit is selected, a number of hexes are marked in blue. The blue hexes are
where the selected unit can move to.
If there are any enemy units within firing range of the selected unit, those enemy
units will be marked with a red crosshair.

To fire on an enemy unit which is within range, left-click on it.

Whenever an information window is displayed on top of the map, you can right-click to
close it.

Press the 'R' key to give the selected unit a reload order.

When you are done moving your units for this turn, press the 'F1' key.


Keyboard commands
-----------------

        F1 - End turn. Press this key when you have finished moving your units.
         R - Reload. Press this key to give a unit the reload order.
         N - Next unit. Selects one of your units which still has move points left.
Arrow keys - Move your view across the map. 
       ESC - Exit the game. The game will exit instantly, no warning is given, so
             do not press this key by mistake!

Bugs
----

Please report any bugs you find to purple@diku.dk.

There are a few known bugs:

1. Sometimes when you click on an enemy unit to fire on it, nothing happens.
Solution: Click on your own unit, then click on the enemy again.

2. When a unit is in a hex which is a least 50% covered by the left border of the
map window, the unit graphic may not be drawn on the map.


Notes on artificial intelligence (AI)
-------------------------------------

As this game is part of an AI project, I should tell you a bit about the system and
the AI techniques involved.

The basic idea here, was to create a flexible AI engine. Instead of writing an AI
program to one specific games, I have tried to create an AI engine that can play
a set of games. The (unlimited number of) games available within this set, follow
the same basic rules. However, the game designer can set up different types
of units, as well as modify some other parameters. That is the reason why there
are two Genetic Warfare games available (called A and B).

To be able to adapt to different game setups, the AI engine has a number of parameters
that can be modified. Some of these are simply numbers, while another is a program
called 'the officer program'. The AI system is two-layered. The officer layer gives
each unit an order to carry out. The soldier layer determines how each unit should
carry out this order exactly. While the officer layer looks at the battlefield in
its entirety, the soldier layer is concerned with its own single unit and its
immediate surroundings.

The number parameters and the officer program are adapted to each game setup
automatically by a program called GenSearch.
Now how does this all work? GenSearch uses something called genetic algorithms,
which is basically a search method. It starts by creating a number of randomly
generated number paramaters and officer programs. It then tests these parameters
by letting the setups play against each other. After some time, the worst setups
are killed, and some new are created by recombining (called crossing over in genetic
terminology) and mutating the numbers and programs. Then the new population is tested
and so on. After X number of hours, this process is stopped by the game designer,
who then picks out the setup to be used in the final game.
Is it magic? No it is just science.


For the computer geeks reading this, the officer program used by Genetic Warfare A
looks like this:

if d > b
  o2 = Conquer
a = GetCPrio() + d or DestroyOrder(p2, p1) and 62 - 83858152
c = 65 * EscortOrder(p1, p2) - d or c * DestroyOrder(p2, p1)
p1 = OwnNextPiece(p1)
b = d and Order(p1, o2, l1) * 350
a = 300
own_piece_loop
  if_above0 a
    a = OwnHealth(p2) / 40
  p1 = OwnNextPiece(p1)
  d = EscortOrder(p1, p2)
  b = c and 417 - GetCPrio()
  l2 = NextVictoryloc(p1)
  a = d / Order(p1, o2, l2) or d
  if o1 = o2
if a < b
  c = OwnHealth(p2) - Attacker() + EnemyHealth(p2)
  if o1 = NoOrder
    c = GetCPrio()

As it is a computer generated program it does some silly things here and there,
but overall it should gives pretty sensible orders to the soldiers.


AI cheating
-----------

In a lot of games the AI computer player cheats, by using information not available
to the human player, or by simply being made more lucky than the human player.

So you may ask if this AI system cheats?
Well it does in a very small way. While your units are set up automatically when you
start a new round, the computer player gets to set up its units the way it likes.
Apart from this, there is no cheating on the part of the computer player.


Advertisement
-------------

The animation running at the bottom-right of the screen is a BCS file.
If you are interested in video compression, please visit the BCS homepage:

  http://www.geocities.com/bcompshell