The Knapsack Problem, Explained Through a Tower Defense Game

By Andrew Reed· October 25, 2026

You have a limited budget, limited time, and more good options than you can afford. That is the situation a recent research demonstration used a tower defense game to illustrate, and by the end of this article you will know the simple idea behind it and how to use it on your own choices.

What the researcher did

Per a report from Phys, a researcher used the tower defense game "Bloons TD" to show how mathematical optimization can solve real-world resource allocation problems. The researcher modeled the game as a knapsack problem and developed strategies that beat the game. According to the report, those strategies sometimes outperformed human players.

The point, as reported, is that abstract math applies to concrete decisions. A game just happens to be an approachable place to see it.

I can only vouch for what that report says. It does not give details such as which game version was used, the exact strategies, or how often the math beat people. So treat the specifics below as a general explanation of the concept, not a description of the study's method.

The knapsack problem in plain language

Imagine packing a backpack that can only hold so much. Each item has a value to you and a cost in space. You want the most total value without overfilling the bag.

Tower defense games have the same structure:

  • Your bag is the money you have to spend.
  • Your items are the towers or upgrades you can buy.
  • Your value is how much each purchase helps you stop the enemies.

You cannot buy everything, so the question becomes which combination gives the best result for the money. That is the knapsack problem. Mathematical optimization is the toolkit for answering it systematically instead of by gut feeling.

Why a game is a good test bed

A game gives you clear rules, a clear goal, and a clear score. You win or you lose. That makes it easy to check whether a mathematical strategy really works, which is harder with a messy real-world problem. It also lets nonspecialists see the logic at work.

Phys notes this kind of research bridges gaming and practical applications, including areas like facility placement and security deployment, where organizations also face tight constraints.

How to use the same thinking on your own decisions

You do not need software to borrow the mindset. Try this on any limited-resource choice, such as a monthly tech budget, storage space on your phone, or a free afternoon.

Step 1: Name your limit

Write down the one number you cannot exceed. Example: $200 for gadgets this quarter, or 10 GB of free space on your phone.

Step 2: List your options with a cost

Put each candidate beside what it costs. Photos app backup might cost 4 GB, an offline map 2 GB, a game 3 GB. Use real numbers from your device's storage settings.

Step 3: Give each option a value score

Rate each from 1 to 10 for how much it helps you. Be honest. This step is subjective, and that is fine; the method still forces you to compare.

Step 4: Compare value per cost, then check combinations

Divide each score by its cost to see which items give the most for the least. Start by picking the best ratios. Then look at whether a different mix fills your limit better. The ratio shortcut is a handy rule of thumb, but it does not always find the best answer, which is exactly why the knapsack problem is interesting and why formal optimization methods exist.

Step 5: Revisit when conditions change

In a game, the best purchase changes as the situation changes. Your real choices do too. Recheck when your budget or needs shift.

Where this thinking shows up outside games

The Phys report points to settings like facility placement and security deployment, where decision-makers must spread limited resources across many needs. Operations research is the field that studies such problems. The report frames AI-driven optimization as increasingly relevant for organizations facing complex constraints.

That does not mean a math model replaces judgment. The model is only as good as the values and limits you feed it. It does, though, make your tradeoffs visible, which is often half the battle.

A fair caution about the human-versus-math result

The report says the strategies sometimes outperformed human players, not always. That is a sensible reminder. Optimization can beat instinct when the problem is well defined, but real life has fuzzy values and surprises. Use the method to sharpen your thinking, not to switch it off.

Try it on one decision this week

Pick one limited resource you are juggling right now, write the limit, list the options with costs, score them, and compare value per cost. Ten minutes with a notes app will show you the knapsack problem is something you already face every day.