Tuesday, August 27, 2013

Well its been more than a year since I last posted.  This isn't because I've stopped developing the game, its because I found I was spending too much time posting and too little time coding!

Anyway, I've made major progress since the last post.

I have started implementing my AI opponent.  Actually, I'm on my 3rd try.

The first two attempts taught me a lot but in both cases it was clear that they would not work for large scenarios.  The key realization was that the problems I was trying to solve were NP-Hard problems and any attempt to use purely deterministic methods would be pointless because of the time required.

I did extensive study of stochastic local search techniques and developed a resource allocation solver that is used both for strategic deployment and managing fronts at the tactical level.

So far I have been pretty pleased with the results.

Basically, I divide the territory into regions based on cities. So each region is a collection of cells closest to a city. This is done once at scenario creation time and is automatic. So if I change the scenario in the editor, I hit a function that recalculates these regions.

My basic turn consists of the following:

Before I do anything, I go through all my units and identify any that are 'unfit for combat' (low morale, strength, lack of ammo, supplies, etc) and reserve them to move to a supply chain and or HQ.

I also identify any units that are fatigued and rest them. Both of these are taken out of the general unit availability list for the rest of the turn.

Then I identify what I call 'regions of interest'. These are all the regions on the border between me and the enemy that are contested.

Once I've done that, I then try to allocate my forces to each region based on a scoring system that takes into account the victory points for each region (based on their city) and the relative troop strength that I would have if I moved my forces there. I use a stochastic local search solver to try to find the best allocation of units because I found that a brute force system was just taking way too long.

Once that is done, I use strategic movement (land and rail) to move my units to the regions where they have been assigned.

That completes what I call the strategic stage.

The next stage is to go through each region and assign an operational plan to the region based on who controls it, relative troop strength and some other factors like whether it is connected to my supply system. I currently have identified 12 distinct operational plans. Some are attacking, some are defending and some are administrative (consolidate, secure supply lines, etc.)

That completes the operational stage.

Finally, I go through each region and using its designated operational plan, I execute my tactical movement which consists of moving units, invading enemy cells, attacking, withdrawing, and a few other things. The movement is particularly complex as I need to identify a front and then find the best way to allocate my available units in the front. I use the same stochastic local search solver for that.

I keep looping through my tactical turns until there are no more units that can do anything useful.

After all of that, I make one more trip through all my units and do things like entrench, upgrade equipment, train, rest, etc. I'm working on a pecking order scheme based on the global situation.

As far as where I'm at:
I'm mostly done with the strategic movement although it still needs some tweaking.
I've implemented most of about 5 of the simplest operational plans.
I've completed movement, withdraw, invade and combat on the tactical level but at a very primitive stage. I have a lot of complex decisions that need to be made about where and how to attack that are still being worked out.

I also have future plans for a learning system that will evaluate games and try to use them to improve play.

1 comment: