A Practical Example for Decision Making with Linear Programming: Part One

A Practical Example for Decision Making with Linear Programming: Part One

Here I give a practical example to help you understand to benefit from linear programming.

Image via Wikipedia

I have been playing this online strategy game Emret for a while. It is a Turkish game with the classical Command & Conquer style, and it is really fun to play.

At the time I am writing this article, I am the 329th most powerful player which is not that bad. Well, I was pretty much sure I had built a strong defense system and was pretty much sure that I could defeat any serious attack.

I couldn’t be more wrong. My whole defense system was based on this foolish idea that my opponents would attack me with tanks and planes; because the infantries were too weak to take into any consideration. But it turns out that the bazooka men become very powerful when 10000 of them are sent. I was caught off guard. I wasn’t really expecting anything like that, so I had no defense system for infantries. As a result, my gaming would almost come to an end, but luckily my alliance made a deal with the guy.

So now, I have to build a new defense system, this time for the infantries so that the bazooka men will not hurt me again. And I have two options for that. I can either build towers or bunkers, or maybe a mixture.

Now, note that my main strategy is not actually about building defense. On the contrary, I am building my own bazooka army to retaliate back in case I receive such attacks again, but yet, I still need some sort of a defense system.

It is important to understand that this method I’m trying to explain does not give you miracle solutions. You should be aware of the basics of linear programming and modeling. I have already written two articles on these topics so perhaps it is better if you read them before you go on. You can find my previous articles at:

Introduction to Linear Models

and

Linear Programming for an Imaginary Strategy Game

My problem with the current situation in my online game is, I have to decide how I should spend my resources so that I get the best defense.

I am going to use a Google Spreadsheet for the task, simply because Google provides an online and free tool for me to use. I am going to use the “Solve Tool” for the job. Most probably you will find a similar tool in OpenOffice, or in other spreadsheet software you have. You will definitely find such a tool in MS Excel, and honestly, it is better than what Google provides, but the thing is MS Excel is not free. and also it is not online which means you can use it only in your own computer. But you can use a Google document in anywhere you have a connection.

So, open a Google Spreadsheet. If you are not sure what I am talking about, having a Google account is enough to open a spreadsheet. Just launch Google Docs and you will see how easy it is to open a new file.

I shared the Google document I created for this particular problem, so that you can access it and examine it freely. I can assure you that, it wouldn’t really take more than 10 minutes for you to understand the whole thing if I were sitting next to you and explaining all the stuff. I am not very sure about my writing talent, and you may feel it is rather complicated, but trust me on this: If you focus, you will get it.

The current situation is:

I have 33857 gold, 10338 iron, and 17210 wheat. The cost for 1 turret is 176 gold, 436 iron and 456 wheat. And the cost of 1 bunker is 158 gold, 248 iron, and 204 wheat. And as you can see from the table, the defense I can get from 1 turret is 587; and the defense I can get from 1 bunker is 322. As you can figure out, these numbers indicate the defense power of the units, but also they have a fire power to eliminate the coming soldiers, and they are 856 and 483 respectively.

Before building any mathematical model, I should decide what I want to achieve very clearly. What do I want? Easy enough, I want to get the best defense I can get with my resources I have in stock.

But wait a minute. I will be getting some defense power anyway, so maybe it would be wiser if I focus on the fire power of my units, so that I make sure that I can eliminate as much enemy soldiers as I can. You see, this is just a choice, and it depends on how you are playing the game. Mathematical models can not make such a decision for you. They can only tell you the most optimistic path to your goal, only after you decide what your goal is.

So ok, I will be getting the defense power anyway, so I will focus on the maximum fire power I can get with the resources at hand.

Before getting into any nerd stuff, let’s do some simple math. The game already tells me the number of maximum units I can get: and they are either 23 turrets or 42 bunkers. At first glance, it pretty much seems like I should forget abut the bunkers and build turrets because their fire power are far bigger than the bunkers. But if you do the math, you will get:

23 * 856 = 19688 fire power for the turrets and

42 * 483 = 20286 fire power for the bunkers. Wow, so it seems like it is better if I build bunkers. But is this really the most optimum choice? Well, if you are not into any nerd stuff, the answer may be a “Yes” for you. Just build the damn bunkers and move along. However, if you want a more scientific approach to find out the real best optimum choice, linear programming may be the cure.

This is already a very long post, so follow me for the next article on this topic and I will tell you how you can use the solve tool. Or maybe, you would just like to view the Google document and try to figure it yourself.

0
Liked it

Leave a Response