Contents [Hide]
I know what you're thinking: "Gee, OGame is a well-balanced strategy game. Surely each fleet composition has upsides and downsides, and is not optimal for every situation?"
Wrong. And I'm just as surprised as you.
Don't want to read and study the code below? No problem, have the answer up front: The best fleet composition is 25 Light Fighters : 5 Cruisers : 1 Battlecruiser. The best defense composition is 50 Light Lasers : 11 Heavy Lasers : 1 Plasma Turret.
First off, let's remember that OGame isn't a strategy game. It's a Big-Fish-Eat-Small-Fish game with timing tactics. A player sending 10,000 Destroyers will perfectly defeat any non-DS fleet that is 1/100th of its value. So, up front, we must make some choices of what we mean by "best". Do we want to cause the opponent the most damage? Do we want to maximize the win rate? And what kind of opponents will we face?
The choices I made that are necessary to even begin to calculate this are as follows:
- We seek fleets that maximize the net profit: the value of our opponent's destroyed material minus our own. Defense counts as 0.
- We seek fleets that maximize the net profit against fleets of equal value. This counter-acts making 10,000 Destroyers as above.
- We define a fleet's performance based on its worst net profit: that is, we calculate the net profit against perhaps 100 or 1000 different opposing compositions, and we pick the worst performance from there. This makes us search for fleets that perform well against any opponent.
- We define the value of a fleet as follows: value = max(max(metal, crystal * 2), deut * 3). This formula may surprise you. More on that later.
- When the presence of some factor strongly influences the result, we break down the results using constraints. For example, whether Deathstars are present in a fleet hugely influences the dynamics.
Now, you may disagree with the choices above. For example, you may wish to maximize your win rate instead. You may seek a fleet that defeats fleet of bigger value than your own. You may want the fleet that performs the best in the average case, not the worst case. You may calculate the value of a fleet differently. That's fine. Change the C++ code below to suit your preferences and simulate yourself - you may find a different answer. But I've made these choices to reflect how I think the average OGame player plays the game.
You may think the value formula is weird. For example, you may prefer the naive value = metal + crystal * 2 + deut * 3. This difference is hugely important -- the naive method says a Rocket Launcher is cheaper than a Light Laser, and my method says the opposite! The reason my formula works well is because it estimates the time taken to gather the resources. Under this assumption, a pure Battlecruiser fleet is value-inefficient, because in the time taken to gather 40,000 Crystal, you could also have gathered 80,000 metal -- now you're sitting with 50,000 metal unused! Obviously, if you use the Merchant often, then the naive formula could be better. Your choice.
OGame's combat rules are well-understood, so you may think the rest is just brute-forcing: testing all possible compositions against all possible opposing ones. The problem is, there are zillions and zillions of different combinations! It would be extremely inefficient to just brute-force them when 60 years of optimization theory has given us much better tools: the gradient ascent algorithm (also called hill climbing algorithm).
In the gradient ascent algorithm, we start with an educated guess of a good fleet composition. Then, we compute the partial derivatives with respect to the ship types. This results in rather amusing derivatives like dValue / dLightFighters. The column vector of these partial derivatives points towards a local maximum. Think of it as computing the direction to walk to ascend a hill fastest (the steepest slope). We take a few steps, and then recalculate the partial derivatives. And so on. And so on. Until... the next step we attempt to take would take us downhill again. At this point, we're standing on a local maximum. A hilltop in a huge landscape of mountains.
But gradient ascent isn't good on its own. It tends to get stuck on bad local maxima, e.g. hopeless compositions that can't be saved with a little tweaking. To fix this, we can use multistart gradient ascent. We start in many different places at the same time in the landscape, and gradient ascent them individually. Then, we pick the best one out of our suite of, perhaps, 100 compositions. We study the results, tweak the parameters... and so on.
To generate these starting points, we can use a simple formula. Imagine that you have 10 coins to spend on ships. 1 coin buys you 150 Light Fighters, or 10 Battleships, according to our formula. We now generate every possible combination of coins being spent on ships. With 10 coins this quickly explodes into trillions of compositions, which is no good. But with 2 or 3 coins? Totally doable. So, we can start our gradient ascent with some rough-hewn compositions, normalized to equal value.
Results
The results surprised me. No matter how I tweaked the parameters, the composition 25 Light Fighters : 5 Cruisers : 1 Battlecruiser kept appearing near the top. In fact, the top 5 would often be very close variations of this ratio, found from different starting points and ascended upwards. Curious, I extended the C++ program to compute the canonical defender: what was the best opposing fleet to this magical ratio? That answer also surprised me: it was a very odd combination of Bombers and Heavy Fighters, extreme combinations you would never really find in practice.
Impressed, I played with this ratio manually against many conceivable opposing compositions. Classic ones like 2:1 BS:BC. 1:1 HF:LF. Pure Battlecruiser. Pure Battleship. Pure everything. To my surprise, the magic ratio wiped the floor with all conceivable opposing compositions. It wrecked pure Light Fighters, thanks to the Cruisers. It wrecked capital ship compositions, thanks to the Light Fighter screen and BCs doing nasty Rapid Fire behind them, Cruisers supporting with extra damage, and the Light Fighters spamming the 30% combat explosion roll. Wow! I challenge you to manually find compositions of equal value that can generate net profit against this composition. It ain't as easy as it seems.
I played with this composition in the Wurren universe to great effect. I could confidently crash anyone's fleet of similar Military Points Built without even having to simulate, with positive profit each time. And, for the smaller fish, it was often more efficient to only send part of the fleet. For example, since Battleships can one-shot Cruisers, it's more efficient to send the Battlecruisers alone if they have superior numbers than the entire composition. Similarly, against Destroyers, screening with Light Fighters and excluding the Cruisers was often better. (To be fully honest, I strayed from the optimal ratio a bit and mixed in some Battleships. This helped patch up some unsimulated factors, like fleet speed and cargo holds, and helped make some fights perfect instead of just positive).
I should point out that there was no guarantee there would be a magical ratio. I was prepared that the results would say "there is no optimal fleet", the symptom of which would be a mediocre worst-case score (profit). But no! The top results have impressive profit totals.
Surprisingly, a pure Battlecruiser fleet is actually one of the worst possible compositions (!). (This is due to its high max-max cost and easy countering with Destroyers and Light Fighters)
What about defense?
Worry not! I also simulated and found the best defense. However, different assumptions are appropriate for defense:
- For defense, we want to cause the most damage to discourage attacks.
- We also assume that the opponent will bring a much bigger fleet to overwhelm us, say 5x, 10x, or even 50x.
Under these assumptions, we can calculate an optimal ratio, and from the Profit score of this composition, we can easily calculate how much defense is needed to protect X amount of resources. If the worst-case damage is X against a suite of opposing compositions, then the defense can protect X amount of resources. In theory, a smart player will not attack if they can't get profit out of you!
I assumed an opposing fleet of 5x value. Higher than this results in the canonical defender always being 10,000 Destroyers, against which no defense will kill even a single ship, degenerating the ranking. You can of course play with this. From these assumptions, we get a optimal ratio of 50 Light Lasers : 11 Heavy Lasers : 1 Plasma Turret. I would often sneak in a Deathstar to defend, too, even though simulating showed it was a bad idea.
Can I explore this data?
Sure! Just visit my spreadsheet here. Note the many different Sheets on the bottom simulating different scenarios and constraints. Tips on exploring:
- Profit is in 1000s according to the max-max formula.
- Ascent indicates how much the rough-hewn composition was improved by gradient ascent.
- The second Profit column indicates against which %age of possible defenders results in >0 profit.
- Wipe indicates what %age of compositions in the opposition would be totally destroyed by our fleet.
- Flawless indicates what %age of battles not a single ship was lost.
- The # column indicates the number of different ships in the composition. Notice how the top compositions have 3-4 ship types in them, and the worst ones tend to have 1. Makes sense, right?
I disagree with your findings. Can I simulate with different assumptions?
Sure! Just download the C++ source code here, compile it, and make your own changes to it. The output will be a copypasteable table that you can paste into a spreadsheet.
The code includes basically a full battle simulator, too, so you can make your own tools using this code that does something else using battle simulation.