HE

hex-grid-spatial

Provides spatial utilities for managing offset coordinate systems on hex maps.

Install

mkdir -p .claude/skills/hex-grid-spatial && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/5133" && unzip -o skill.zip -d .claude/skills/hex-grid-spatial && rm skill.zip

Installs to .claude/skills/hex-grid-spatial

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Hex grid spatial utilities for offset coordinate systems. Use when working with hexagonal grids, calculating distances, finding neighbors, or spatial queries on hex maps.
170 chars✓ has a “when” trigger
Intermediate

Key capabilities

  • Calculate hex grid distance
  • Find neighbors
  • Perform spatial queries
  • Convert offset coordinates

How it works

It uses cube coordinate conversion to perform distance and neighbor calculations on odd-r offset hexagonal grids.

Inputs & outputs

You give it
Hex coordinates
You get back
Spatial calculation result

When to use hex-grid-spatial

  • Calculate hex grid distance
  • Find neighbors on a hex map
  • Perform spatial queries

About this skill

Hex Grid Spatial Utilities

Utilities for hexagonal grid coordinate systems using odd-r offset coordinates (odd rows shifted right).

Coordinate System

  • Tile 0 is at bottom-left
  • X increases rightward (columns)
  • Y increases upward (rows)
  • Odd rows (y % 2 == 1) are shifted right by half a hex

Direction Indices

     2   1
      \ /
   3 - * - 0
      / \
     4   5

0=East, 1=NE, 2=NW, 3=West, 4=SW, 5=SE

Core Functions

Get Neighbors

def get_neighbors(x: int, y: int) -> List[Tuple[int, int]]:
    """Get all 6 neighboring hex coordinates."""
    if y % 2 == 0:  # even row
        directions = [(1,0), (0,-1), (-1,-1), (-1,0), (-1,1), (0,1)]
    else:  # odd row - shifted right
        directions = [(1,0), (1,-1), (0,-1), (-1,0), (0,1), (1,1)]
    return [(x + dx, y + dy) for dx, dy in directions]

Hex Distance

def hex_distance(x1: int, y1: int, x2: int, y2: int) -> int:
    """Calculate hex distance using cube coordinate conversion."""
    def offset_to_cube(col, row):
        cx = col - (row - (row & 1)) // 2
        cz = row
        cy = -cx - cz
        return cx, cy, cz

    cx1, cy1, cz1 = offset_to_cube(x1, y1)
    cx2, cy2, cz2 = offset_to_cube(x2, y2)
    return (abs(cx1-cx2) + abs(cy1-cy2) + abs(cz1-cz2)) // 2

Tiles in Range

def get_tiles_in_range(x: int, y: int, radius: int) -> List[Tuple[int, int]]:
    """Get all tiles within radius (excluding center)."""
    tiles = []
    for dx in range(-radius, radius + 1):
        for dy in range(-radius, radius + 1):
            nx, ny = x + dx, y + dy
            if (nx, ny) != (x, y) and hex_distance(x, y, nx, ny) <= radius:
                tiles.append((nx, ny))
    return tiles

Usage Examples

# Find neighbors of tile (21, 13)
neighbors = get_neighbors(21, 13)
# For odd row: [(22,13), (22,12), (21,12), (20,13), (21,14), (22,14)]

# Calculate distance
dist = hex_distance(21, 13, 24, 13)  # Returns 3

# Check adjacency
is_adj = hex_distance(21, 13, 21, 14) == 1  # True

# Get all tiles within 3 of city center
workable = get_tiles_in_range(21, 13, 3)

Key Insight: Even vs Odd Row

The critical difference is in directions 1, 2, 4, 5 (the diagonal directions):

DirectionEven Row (y%2==0)Odd Row (y%2==1)
NE (1)(0, -1)(1, -1)
NW (2)(-1, -1)(0, -1)
SW (4)(-1, +1)(0, +1)
SE (5)(0, +1)(1, +1)

East (0) and West (3) are always (1, 0) and (-1, 0).

When not to use it

  • Non-hexagonal grids
  • Simple cartesian grids

Prerequisites

Python environment

Limitations

  • Limited to odd-r offset systems
  • Requires integer coordinates

How it compares

It provides specialized spatial logic for hex grids rather than generic grid math.

Compared to similar skills

hex-grid-spatial side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
hex-grid-spatial (this skill)16moReviewIntermediate
streamlit869moNo flagsIntermediate
jupyter-notebook306moReviewIntermediate
backtesting-frameworks172moNo flagsAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

streamlit

sverzijl

When working with Streamlit web apps, data dashboards, ML/AI app UIs, interactive Python visualizations, or building data science applications with Python

86239

jupyter-notebook

davila7

Use when the user asks to create, scaffold, or edit Jupyter notebooks (`.ipynb`) for experiments, explorations, or tutorials; prefer the bundled templates and run the helper script `new_notebook.py` to generate a clean starting notebook.

30158

backtesting-frameworks

wshobson

Build robust backtesting systems for trading strategies with proper handling of look-ahead bias, survivorship bias, and transaction costs. Use when developing trading algorithms, validating strategies, or building backtesting infrastructure.

17126

pdf-processing-pro

davila7

Production-ready PDF processing with forms, tables, OCR, validation, and batch operations. Use when working with complex PDF workflows in production environments, processing large volumes of PDFs, or requiring robust error handling and validation.

17110

llava

zechenzhangAGI

Large Language and Vision Assistant. Enables visual instruction tuning and image-based conversations. Combines CLIP vision encoder with Vicuna/LLaMA language models. Supports multi-turn image chat, visual question answering, and instruction following. Use for vision-language chatbots or image understanding tasks. Best for conversational image analysis.

7117

cocoindex

cocoindex-io

Comprehensive toolkit for developing with the CocoIndex library. Use when users need to create data transformation pipelines (flows), write custom functions, or operate flows via CLI or API. Covers building ETL workflows for AI data processing, including embedding documents into vector databases, building knowledge graphs, creating search indexes, or processing data streams with incremental updates.

6116

Search skills

Search the agent skills registry