spatial-partitioning

Implements uniform grids and spatial hashing for RTS neighbor queries and movement systems.

Updated Jul 13, 2026
One-click install
npx skills add https://github.com/Ohmnia/site-build --skill spatial-partitioning-ohmnia
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: spatial-partitioning
Source: https://github.com/Ohmnia/site-build/tree/main/.opencode/skills/spatial-partitioning
Command: npx skills add https://github.com/Ohmnia/site-build --skill spatial-partitioning-ohmnia

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Real-time strategy games cannot afford all-units vs all-units checks, which scale quadratically and destroy frame rates as unit counts grow. This Skill provides architectural guidance for building scalable spatial partitioning systems that keep neighbor queries, collision avoidance, and targeting fast. ## Core Features & Use Cases - Spatial Grid Architecture: Structures the world as a grid of lightweight, cache-friendly cell buckets supporting incremental updates. - Query Optimization Rules: Enforces buffer reuse, zero allocations during queries, and minimal query counts for deterministic performance. - Use Case: When implementing combat targeting for hundreds of units, use this Skill to design a uniform grid where each unit queries only its neighboring cells instead of scanning the entire unit list. ## Quick Start Use the spatial-partitioning skill to design a uniform grid system for neighbor queries and movement avoidance in my RTS unit simulation.

Frequently Asked Questions about spatial-partitioning

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement neighbor queries for RTS units efficiently?

Use a uniform grid or spatial hash where each unit is assigned to a cell bucket based on position. Neighbor queries then check only the unit's cell and adjacent cells instead of comparing against every unit in the world.

Uniform grid vs quadtree for RTS spatial partitioning?

Uniform grids are preferred for RTS games because units are typically distributed across the map and grid cells are lightweight, cache-friendly, and cheap to update. Trees add recursive overhead and complexity that is rarely justified early on.

How do I avoid allocations during spatial queries?

Reuse pre-allocated query buffers instead of creating new collections per query, and update partitions incrementally as units move between cells. This keeps queries allocation-free and maintains deterministic frame performance.

When should I not use spatial hashing in a game?

Avoid adding spatial partitioning when unit counts are very small, since the overhead of maintaining cells exceeds the cost of direct comparisons. Also avoid complex tree structures prematurely before profiling shows a real bottleneck.

How do I keep spatial grids updated as units move?

Update partitions incrementally by moving units between cell buckets only when they cross a cell boundary, rather than rebuilding the entire grid each frame. This minimizes per-frame work and keeps cells iteration-efficient.