Optimal Realm Defense

A mathematics professor introduced me to an interesting optimization problem in a video game setting. It goes like this:

"You are a warrior defending a region from a monster invasion! The region is represented by a square map, and you can select any starting position on the map. After you select your starting position, monsters will randomly spawn on the map, but you must choose where to start before they spawn. Once they appear, you must travel to each one and defeat them. Where should you start to minimize travel time on average?"
A purple spearman A red monster

Understanding the Problem

To tackle this problem, we need to make a few assumptions and lay some groundwork:

  • Monster Spawn: Monsters spawn with uniform random probability. That is, they are equally likely to spawn at any point on the map.
  • Map Width: The map width is set to one for ease of future calculations.
  • Travel Time: We assume travel speed is constant and terrain has no impact on travel time. Thus, a straight line is the fastest route between any two points.

Simplification and Approach

This problem is complex and can be approached from several directions. When faced with an open question like this, it’s a good idea to simplify it in stages until reaching the simplest unsolved version you can think of. That done, you can work through the problems from least to most complex, letting findings from each step inform the next. Use the interactive portion of the document below by clicking on highlighted text to see how we can simplify this problem into something approachable.

Interactive Exploration

When you see a word or phrase highlighted, it means you can click on it to make some changes, usually to the map on the left. Let's get started!