TL’DR: Defining the goal is one of the most crucial tasks in a project. This is also true for creating a RESTwars client, even more so since RESTwars does not have a ranking- or score-system. We take a look at what a “Hierarchy of Objectives” is and think about strategies and tactics. Spoiler: Scroll to the bottom of the page to see the result.
As I wrote some weeks ago, I intend to create a bot for RESTwars using as many optimization techniques as possible (and reasonable). But before I crack my knuckles and start hacking, it seems sensible to draft a rough course of action and architecture. In order to do so, we should spend some thoughts on our goal and therefore also on the goal of the game.
While this might sound a little boring, I assure you that it is interesting and also quite rewarding.
So: First things first.
Hierarchy of Objectives
Systems Engineering theory teaches us to define a hierarchy of objectives1. So what does that mean?
Basically, it means that if we want to find the goal of an action, we should act like a little child and keep asking “why?” until we cannot come up with a better answer. In the end we will have our strategic (ultimate) goal.
Of course, it takes a little practice to find the strategic goal without ending up with something pretty silly (“just because”) or correct but hardly expedient (“because we would starve otherwise”). Depending on the problem’s context, there are different ultimate strategic goals. For a business manager, the ultimate strategic goal might be “to maximize profits”, while a political economist could prefer “to maximize public welfare”.
Still, a strategic goal like “to maximize profits” is not going to get us very far on its own. We also need to know the right means of reaching it. If we do not, we might find that insider trading is a very efficient way of reaching our goal and end up in jail.
So while finding our strategic goal comes down to repeatedly abstracting our goal, the next step in creating a Hierarchy of Objectives is to specify our goal a little more. This is done by finding the right means of reaching the strategic goal. The military terminology for the means to implement a strategy is tactic.
Now read carefully: Because every tactic can be specified further, every tactic also poses as a strategy of its own. Therefore this is called Hierarchy of Objectives.
- We win the battle (tactic) in order to win the war (strategy).
- We attack at dawn (tactic) in order to win the battle (strategy).
- We get up early (tactic) in order to attack at dawn (strategy).
- We set an alarm (tactic) in order to get up early (strategy).
- We bring an alarm clock to war (tactic) in order to set an alarm (strategy).
By following down the hierarchy, we found out that bringing an alarm clock to war might provide us with an advantage over the enemy and might even result in us winning the war! Genius!
Finding Our Strategic Goal
So coming back to RESTwars, let us think about our strategic goal for a moment. That one seems quite straight-forward: win the game. But this is where our problems start, because RESTwars does not have a score- or ranking-system yet. At the moment, it is merely a sandbox which offers some fundamental game mechanics. Does that mean that we cannot win the game? Let us hold that thought for a moment and try a different approach.
Let us assume that we are not playing RESTwars. Instead, we are trying to win an intergalactic war. A popular anti-war slogan says: “War doesn’t determine who’s right, only who is left.” (Kathleen Sayre)
While this describes war in a nutshell, it gives us also a pretty clear definition of what it means to win a war: Being the only one who is left. So being the only one who is left seems to be a pretty good strategy to win a war.
While there might be countless means of reaching this goal in real intergalactic warfare, a game - and therefore also RESTwars - has a decisive characteristic which simplifies matters a lot:
Rules and restrictions apply to everyone involved.
- Everyone starts with the same resources
- Everyone has the same military equipment
- Everyone has the same tech-tree
- The number of colonizable planets in a galaxy is finite
- Colonized planets cannot be annexed or destroyed (yet)
The last restriction makes it somewhat hard to be the only one who is left. While this restriction could be dropped in a future version of the game, it certainly introduces the need for specifying our strategy a little more:
Being the only one left who is capable of acting.
That means that we restrict every other player in the game to a spectator role by:
- Destroying all his ships
- Steal all his resources every round (so he cannot build new ships/buildings)
If that state has been reached, we have effectively won the game. So reaching this state shall pose as our goal for the time being.
Please note: If the possibility of destroying or conquering enemy planets is introduced, it will be possible to actually be the only one who is left. Still, our current goal will remain a valid strategy to win the game, since nothing can keep us from conquering or destroying every other player once they are rendered incapable of acting.
Choosing Our Tactic
So how do we reach our strategic goal? Well, science fiction author (and physicist) Joe Haldeman wrote in his award winning masterpiece “The Forever War”: “[…] Conduct of war divides neatly into two categories, tactics and logistics”2. Although this quote originates from a work of fiction, it is nonetheless a very accurate observation. As a matter of fact, this statement also applies to most business operations. Grosvenor Plowman’s Five Rights of Logistics-Rule — which is less dull than the name suggests — states that the ultimate goal of logistics is having
- the right product,
- at the right time,
- in the right place,
- in the right quality,
- at the right cost.
In German logistics text books, these five rights are often completed by a sixth one: in the right quantity.
Now imagine what kind of impact it has on our operation if we implement those items better than the other players. Granted we could achieve this - having the right ships, buildings, resources and research at the right time, on the right planet, in a better condition and higher quantity than our opponents’, and we were able to achieve all that at a lower total cost - it would take some serious effort to find a tactical decision bad enough to screw things up.
Which means that if we actually manage to optimize our logistics to a degree where we outperform all competing bots, we have a decent chance of winning.
In WWII, the British Royal Navy tried to gain an advantage over the German Marine by optimizing their logistics with the help of mathematical methods. American and Soviet military work groups started doing the same thing shortly afterwards. This was the birth of a science called Operations Research3. Because Operations Research is also widely used in todays businesses (which is another indication of the thesis that business and war are essentially the same thing), it offers a wide variety of tool for optimizing logistics operations.
Optimizing our logistics is therefore a promising tactic and Operations Research might be the right direction to take when looking for solutions.
War Never Changes - Or Does It?
OK, we got it. Optimizing our logistics is all we have to do, right? Right?
Well — we do not know that yet. This is something we have to find out. We play a game which is constantly evolving, against a large variety of different bots. Some might utilize machine learning to find a better approach. Others might just manage to do the same things we do better. We might have a good idea of how to win the game and it might even give us a head start. But there is simply no way of finding the one tactic to rule them all, most of all not at the first try.
Solving a problem correctly at the first try is called First Time Right in Systems Engineering. Usually, this is something which can only be achieved if you solve a lot of similar problems. Since we cannot expect to have a First Time Right, we should put that knowledge to use and derive another tactical goal from this conclusion: We need to be flexible.
There will obviously be a lot of prototyping and simulation. We must be able to use our learnings faster than our opposition. So our bot must be extensible and able to quickly change its approach.
Here we are. Our own little Hierarchy of Objectives:
This might look like a lot of effort for little information, but having a clear understanding of the goal and how we intend to achieve it really pays off.
Keep in mind that your tactics can change over time. We might find a better approach while prototyping. If we kept our Hierarchy of Objectives up-to-date, we can easily identify modules which are rendered deprecated by new tactics.
But most importantly, we now have enough knowledge of what we want to do. It is time to start thinking about a procedure model and architecture.