Sunday, 1 April 2012

Computer Moderated Gaming for Napoleonics. - Draft Specification

Computer Hacks of the Day

Here is a draft specification for something I am working on at the moment. Should keep me busy for a few months at least.

It is taking the bulk of Empire V rules, and using this as a specification for a computer moderated application to run Napoleonic Wargames.

I know that Carnage and Glory is out there, and it does a fantastic job of a difficult subject, but I am after something a little different.

ie :
  • I want to base it on deterministic rules that are well known / well understood. Empire V in this case. Might be a difficult set of rules for the average player to get their head around, but it provides a good basis for the computer to get it's head around.
  • I want something that is open source, so it can be hacked around with endlessly to add in house rules and things. Very important for me ... so that really rules out C&G for my use.
  • I want it to be able to run multi-user, so running it as a web application makes sense. Everyone just bring your laptop, and login to the server to play the game.
  • Being a web application, it would mean that a group of players who are remotely separated could all participate in a game. That is way outside the scope of this specification here, but at least the architecture of using a web server for driving the app leaves that path open for future development.
  • Ability for the application to display video clips / audio snippets as part of the user interface, to provide period chrome. Infantry volleys, cavalry charges ... whatever little video goodies you have on your hard disk should be able to be added in to the video library for the computer to add to the UI during phases of play.
  • I want full debugging details and audit trails for the 'admin user', but really sketchy fog-of-war details for the players. I even want the computer to deliberately make outright lies in it's status reports to players on occasion.

So - The Computer 'application' shall be written as an open source web application that runs on the LAMP stack, and allows for multiple simultaneous players to interact with it as the game is in progress, via a standard web browser.

Keep all the book keeping and calculations at the backend, and provide the players with a really flexible interface to  monitor what is going on, and to give orders to their units. 

Allow the computer to generate some advice to the players, acting as their logistics and operations staff officers.

Maybe later on - adding and AI to the backend for solo play. A lot harder than it sounds !

Keeping it simple, and keeping it open, I will use the following tech for getting this together :
  • Write the back end as a PHP application, using MySQL for data storage.
  • Use an off the shelf framework - probably codeigniter is a good choice. 
  • Distribute access to the code (as it is being developed) on a Git repository to allow for unlimited forking and distributed development.
  • Publish all work under appropriate licensing - LGPL, etc.
  • Maintain a public web page for users to download the latest release (for free).
  • Provide an online space for users to share electronic OOBs in a format that can be imported into the application.

Without further delay ... here is the high level spec document :

1 Initial Setup

  • Player tells the computer what the initial setup / orders is for each top level unit.
  • Player tells the computer what the relative positioning is for each ME within each top level unit.
  • Player defines some objective for each Corps, in terms of geographical features.


 2 Hourly Round

  • Computer generates the ME determination test, and ME morale tests.
  • Computer generates a status report for all units of each side for the umpire. This includes full and true details of every little thing (debugging tool).
  • Computer generates a status report for all units for each player. This includes details of what each Corps intends to do this hour, and some deliberately sketchy details on what state each ME is in, and even sketchier details on the state of individual regiments / battalions. Sometimes the Computer will deliberately lie about the reality on the battlefield in it's reports to the player.
  • Player can click on any unit in the status report to see the full details of the unit, including a history of events (audit trail) that explain how the unit got into its current state of affairs.
  • After seeing status reports and the results of ME determination and morale tests, Player gets to issue orders. Player tells the computer about new orders to be issued to top level units.
  • Computer asks some questions, such as distance from commander to unit HQ, and then does some calculations based on this and the skill of the units involved. Computer calculates how long the order will take to activate (if at all). Computer then adds these orders to the internal queue of order dispatches for each unit. Some may be activated immediately, some may take another hour or more to come into effect. The computer provides the player with an estimate in each case.
  • Player tells the computer about any leaders who attach / detach from units. In each case – select the commander unit ID, and the attached unit ID.
  • Computer determines who has the initiative for any engagements this hour, and calculates the activity level for each ME, should they be engaged.
  • Computer calculates how many bombardment rounds each side gets this hour.
  • Player determines if there are any NEW engagements due to grand tactical movement, and tells the computer. Each engagement has a unique name ie: 'The skirmish at Yarlsberg Farm', and also tells the computer which ME's are involved in which engagement.
  • Computer runs the Tactical Engagement Resolution for each engagement, until all engagements are complete.
  • Computer calculates which units are eligible for rally and/or rest actions. In each case the computer lists the situation, along with the odds for success. The player can either accept (in which case the computer calculates the rally and fatigue recovery results), or cancel … which provides the players with a way of overriding rally attempts due to common sense appreciation of what is happening on the gaming table.
  • Computer calculates any random attrition effects (perfectly good units out of danger may suffer some unlucky events), and also random recovery effects (badly mauled units may get lucky and collect some stragglers to bolster their ranks)

3 Grand Tactical Movement

  • Computer generates a list of which units on each side must make compulsory grand tactical moves. This includes all ME's under break off orders, as well as any ME's where the morale is collapsing.
  • Computer calculates some random movement effects, and then generates a list telling the player what each ME from each side will do for Grand Tactical Movement during this hourly round, and the maximum distance each unit can move, and which units are eligible for forced marches.
  • Players move those units which are eligible for grand tactical movement, sticking to what the computer tells them the general intention and objective of each move is, as well as the maximum move rate for each unit.
  • Player tells the computer if any unit was force marched.

4 Tactical engagement resolution


  • For EACH engagement, the computer will run through each one in an order of it's own choosing. If there are multiple engagements, the computer will randomly select which impulse of which engagement to do in which order. The computer may insist on running a whole engagement to completion before telling the players to resolve an adjacent engagement.
  • For each engagement :
  • Computer starts off the first impulse, with a short report detailing who has the starting initiative.
  • For each impulse round :
  • Computer generates a report for 1st bombardment round. For each bombardment, which the player chooses to execute :
  • Player tells the computer : Unit firing, Target Unit, Range, tactical factors.
  • Computer calculates the effect of the fire – casualties and morale checks, and reports on the effect. Marks the battery as having fired.
  • Computer will generate a list for the player detailing which units from either side MUST perform some compulsory move this impulse (such as retreating to safety), and which units from the initiative side may be operated under player control.
  • Player makes any moves of units as per the computer report.
  • Combat !! For each contact, player enters some data in the computer and the computer calculates the effect.
  • Computer may terminate the impulse if the initiative player suffers an adverse result.
  • Initiative player selects 'end of impulse'.
  • Computer determines the next step, and either repeats the above for the next impulse, or it declares that this engagement is complete for this hourly round. Note that the computer may next jump to another engagement if there are multiple engagements in progress.
  • Once the engagement is complete, the computer produces a Tactical Engagement report, with a summary of the events of the hour, and asks the player if this engagement is to be concluded (ie – due to combat results and movement, both sides have effectively disengaged through mutual agreement). The only effect of closing the engagement is that if in the next hourly round one side attacks again, a new engagement record is created. Its up to the players whether this engagement is a separate event on the unit history, or whether it is part of a larger rolling battle.

4.1 Tactical Engagement Types


4.1.1 Infantry skirmish or semi-skirmish attack


  • Player tells computer : Skirmish or Semi-Skirmish, unit firing, range, number of skirmishers, target, tactical factors.
  • Computer calculates the effect of the skirmish fire.
  • Initiative continues

4.1.2 Infantry volley attack


  • Player tells computer : unit firing, range, target, tactical factors.
  • Computer calculates the effect of the fire for each side.
  • Computer determines if there is a firefight, and if so, calculates the results and issues a firefight report.
  • Computer determines if initiative continues

4.1.3 Infantry bayonet charge


  • Player tells the computer : unit(s) attacking, target unit, tactical factors.
  • Computer lists the defender's options – defending player to select a choice from the list.
  • Computer calculates defensive fire.
  • Computer calculates any elan test, resulting firefight, morale tests, etc.
  • If contact is made, computer calculates the close combat results and issues a close combat report.
  • Computer determines if initiative continues

4.1.4 Cavalry charge


  • Player tells the computer : unit(s) attacking, target, tactical factors
  • Computer asks if defender wishes to form square, and displays the % chance of success. If defender says yes, computer calculates whether it worked or not.
  • Computer calculates defensive fire and elan test / morale results.
  • If contact is made, computer calculates the close combat results and issues a close combat report.
  • Computer determines if initiative continues

5 Force editor

The computer shall provide an editor for defining the forces involved in an order of battle.
These force definition records shall be stored in the computer as a template, and can be cloned at any time to create a new OOB for a given battle.
When a new force is created from a template, or cloned from an another active list of forces already in use … the battle history for the newly cloned force shall be empty.

Information is stored internally in an SQL database within the application.

The application shall define an XML schema for export/import of force structures and battle histories, so that they can be shared between users of the application.

5.1 Database of forces arranged as a tree.

Each node in the unit database tree is one of the following types :
  • Command unit (CHQ, DHQ, BHQ)
  • Infantry unit
  • Cavalry unit
  • Artillery unit
  • Specialist unit

5.2 Attributes common to each unit (initial thoughts - non definitive)

  • Unique ID
  • Parent ID
  • Type (Command / Infantry / Cavalry / Artillery / Specialist)
  • Name
  • Long description
  • Current orders
  • Morale state (Good / Shaken / Retreat / Broken)
  • Initial Strength
  • Total casualties so far (Dead / Severely wounded / Lightly wounded / Demoralised)
  • Number of officers (Initial and Current)
  • Current Effective ACE rating (morale class – minus current fatigue level)
  • Morale / Training class
  • Small arms fire class
  • Current fatigue status
  • Current Ammo level
  • Doctrine – (Napoleonic / Regimental)
  • Battle Honours (being the computer records of the actions of this unit from past games)
  • History (being the detailed action records for each turn of this game so far .. stored by the computer, and available for review)

5.2.1 Command Unit Attributes

  • Current objective
  • Inspirational rating
  • Professional skill rating
  • Command radius
  • Order queue

5.2.2 Infantry unit attributes

  • Skirmisher capability (how many SK)
  • Semi skirmisher capability
  • Shock troops ?
  • Battalion guns ?

5.2.3 Cavalry unit attributes

  • Battle cavalry ?
  • DUB cavalry ?
  • Blown ?
  • Move as (LC / HC)

5.2.4 Artillery unit attributes

  • Gunnery class (OG / I, II, III)
  • Relocation rating
  • Gun Calibre
  • Includes howitzers ?

5.2.5 Specialist unit attributes

  • Supply wagons
  • Engineers
  • Civilian VIPs
  • Vivanderies ?

6 Battle Event History Records

  • Computer will maintain events as an audit trail against each unit.
  • Each order that is issued to a command unit will generate an event.
  • Each combat round that occurs will generate an event for each attacker / defender
  • Each morale test that occurs in the game will generate an event for the affected unit.
  • Any event which results in a change of current status for a unit will be recorded in the audit trail.


  1. Hi Steve.

    I suspect that you've got quite some work on your hands! I don't know much about Empire, it looks an interesting system but a bit over what I've been looking for in a tabletop game. Do you expect to be able to play a game using your system without having the rules btw?

    I'm looking forward to seeing how you develop this idea. Hopefully it'll be something I can tinker with once you release it, although my php skills aren't particularly advanced and I'd never heard of LAMP stacks and codeigniter before. (Of course I'm using a LAMP stack myself for my campaign system, but never heard it called that). I'm hoping that your XML exporter for orbats is fairly simple too as I am in need of something to do a similar function for our games.

    All the best,


    1. Well, this one is for Empire, so it sort of assumes a rough idea of how to play before being able to use it. You do need to know the difference between grand tactical moves and tactical impulses ... but you dont need to know all the fiddly mechanics for combat - thats all in code now (or will be soon).

      I haved defined 3 user interfaces so far, which might explain it a little better :

      1) Login to the system as 'umpire', which lets you create scenarios, and kick off a new game. The Umpire user gets full access to all details, and is the only user who can tell the computer to progress 'the game' to the next phase of play. The Umpire user is also the only one who can create/edit/finish Engagements, which includes defining which MEs have been sucked into which engagements. During the Umpire session, I will try and add enough on-screen help information (about how Empire games roll) to allow the Umpire user to execute a decent game without having to know the rules back to front.

      2) Login to the system as either 'player1' or 'player2'. These logins only provide information on that player's forces. Each player login can access status reports on his forces, issue orders, and enter some details about engaged MEs (like formation changes, etc). Player sessions are interactive, so that as the game progresses, the computer tells the player what is going on, and a players actions are limited by what phase the game is in.

      eg: 'We are now in the orders phase, you have 2 minutes left to complete your order changes ..."
      "We are now running the Engagement involving the skirmish around Yarlsberg farm, your 2nd Division is engaged against an enemy of unknown size. You start with the initiative for this engagement". etc

      3) Login as 'Solo', which is a cross between Umpire and Player. You have Umpire powers for solo gaming (since someone needs to tell the computer to advance the game), but you only get access to reports and setting orders for 1 side. The other side ... maybe some sort of AI to have the system control the opposing forces. Not sure how that aspect will work yet.

      Empire has its own special way of running a game, and other games often run completely differently. For this computer program, I am just concentrating on making it a 100% faithful to Empire as much as I can.

      Once that is all polished up, it is no problem cloning the concept for other game systems.

      Code wise - I should have something available soon. This is my first serious CodeIgniter project, so quite a bit of learning to do there as well. Nice little framework though, and the documentation and online help is top class. Start looking into that if you want to brush up your skills a little before the code is released.

      Also - I will be publishing the code via a git repository. Amazingly powerful distributed source code control system .. nothing beats it, but it also has a bit of a learning curve there. If you just want to grab the latest code release and run, its dead easy (ie - click the download button on the repository, and it does all the work). If you want to contribute code up to the project, requires getting your head around git. Its worth the investment though.

      Cheers ..must get back to coding whilst I still have time :)

    2. Sounds good and I wish you luck. I've played with GIT and SVN before and I'd be very interested in possibly collaborating with you (and any others) in a campaign system and/or your current project although I have to be honest I'm not sure that I can see any time saving in playing my current tabletop rules via computer moderation.

      I'm in the process of collating a list of all the things that I think I can adapt/include in my campaign system to open it up to other players and game systems. Post should be up on my blog later tonight or tomorrow or maybe on TMP for discussion.

  2. You are doing great things for the hobby here! I got the treeline downloaded and the french sample orbat works great...I confess I don't know how to fool around with it yet....

    btw my site is

    pretty crude so far but some links to valuable sources

    1. Thanks, thats good to know. Was a bit worried that the ORBATs might be difficult to get into .. or least find the editor, get it installed, and import my data. But if it works for someone - then YAY !

      The JenaPrussian orbat is a lot more detailed, and it uses Wings instead of Corps - something different. Have a look at that one as well.

      The combination of the 2 cover just about every army in the period though - I dont think I have missed much.

      I will deliberately try to NOT think too hard about campaigns yet, but its definitely next thing on the agenda. Instead, I am locking myself in my shed for a few days of mad coding frenzy, and see if I cant get the bulk of this project done whilst its still fresh in my head.

      What tools are you using to write your campaign system as well ? Interested to know.

      Its very cool to see the application starting to come together - so hopefully soon I can release something.

      In the meantime, can you collate as many random ideas as you can about what details a campaign should cover ... what is worth modelling ... and what just gets in the way from past experience.

      Looking forward to getting into that soon as well.


  3. Sounds like a very ambitious project, Steve. Hope it goes well for you!

  4. BlueHost is ultimately the best website hosting company for any hosting services you require.