The Spatial Partition pattern name comes from the process known as space partitioning, which plays an integral part in computer graphics and is often used in ray-tracing rendering implementations. The process is utilized to organize objects in virtual scenes by storing them in a space-partitioning data structure such as a binary space partitioning (BSP) tree; this makes it faster to perform geometry queries on a large set of three-dimensional (3D) objects. In this chapter, we will use the general concept of spatial partitioning without being faithful to how it's usually implemented in computer graphics.
A very high-level and conceptual way of visualizing spatial partitioning is with the following diagram:
The first example represents the position of enemies on the map without any partitioning. If we want to quickly look up the location of enemies in relation...