Polyhex Shapes Generator

A "polyhex" is a real combinatorial-geometry term: a shape made of N edge-connected hexagons, the hex analogue of a polyomino. This tool procedurally grows one valid connected polyhex of a given size using a simple random growth algorithm and renders it as ASCII art on an offset hex grid. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-26

Overview

Introduction

Polyhexes are a genuinely studied object in combinatorial geometry, shapes built from hexagons joined edge to edge, the same family of ideas as the more famous polyomino (Tetris-piece shapes made of squares).

This tool procedurally grows one example connected polyhex of whatever size you request and renders it as simple ASCII art on an offset hex grid, useful for a quick visual sense of what a shape of that size can look like.

What Is Polyhex Shapes Generator?

A polyhex of order N is any connected shape made of exactly N regular hexagons joined edge to edge on a hexagonal grid; "connected" means every hexagon in the shape touches at least one other hexagon in the shape along a full edge.

This generator produces a single valid example of such a shape for your requested N, using axial hex-grid coordinates and a random growth process, then renders the result as labeled ASCII cells.

How Polyhex Shapes Generator Works

Growth starts with one hexagon at the origin. On each step, the algorithm collects every currently-unoccupied neighboring coordinate around all hexagons placed so far (each hexagon has up to 6 neighbors), picks one of those open slots at random, and occupies it, labeling it with the next sequential index.

This repeats until the shape contains the requested number of hexagons; because every new cell is chosen from the current shape's open neighbors, the result is always a single connected piece, never two separate clusters.

The final set of hexagon coordinates is rendered as an offset-row ASCII grid: each occupied cell shows its placement order as a 2-digit hex index in brackets, and alternating rows are shifted to suggest the visual offset of a real hex tiling.

When To Use Polyhex Shapes Generator

Use it to get a quick, concrete example of what a connected shape of N hexagons can look like, for a puzzle, game board layout idea, or recreational-math illustration.

It's a lightweight way to explore polyhex shapes without needing a full enumeration algorithm; regenerate a few times to see different valid arrangements of the same size.

Often used alongside Hex Grid Generator and Hex Spiral Generator.

Features

Advantages

  • Always produces a genuinely valid, connected polyhex, guaranteed by the growth algorithm's neighbor-attachment rule.
  • Works for any requested size within the tool's cap, growing incrementally rather than requiring a precomputed shape library.
  • Simple monospace ASCII rendering that's easy to read and copy.

Limitations

  • Generates only one example shape per request, not an enumeration of all distinct polyhexes of that order; the true count of distinct shapes grows very quickly with N.
  • The growth algorithm's random neighbor-attachment process doesn't sample shapes uniformly across all possible polyhexes of a given size, some shapes are more likely to be grown than others.
  • Capped at 200 hexagons to keep the ASCII rendering a reasonable size.

Examples

A single hexagon

Input

1

Output

[00]

The simplest possible polyhex is just one hexagon on its own.

A small connected shape

Input

4 (with a fixed pick-the-first-candidate rule for reproducibility)

Output

[03][02]
  [00][01]

Starting from [00], each subsequent hexagon (01, 02, 03) attaches to an open neighbor of the shape built so far, and the offset second row reflects the hex grid's row-shift rendering.

Best Practices & Notes

Best Practices

  • Use the Regenerate button to see multiple different valid shapes at the same size, since each generation is independently random.
  • Remember this tool shows one example, not the full set of possible shapes, if you need every distinct polyhex of a given order for research purposes, this isn't an enumeration tool.
  • Keep the count modest (under a few dozen) if you want the shape to stay easy to read at a glance.

Developer Notes

Cells are tracked in axial hex coordinates (q, r) with the standard 6-direction neighbor offsets; growth collects every open neighbor slot across all placed cells (deduplicated so a slot adjacent to multiple cells is only a single candidate), picks one uniformly at random, and adds it. Rendering converts the axial coordinate bounding box into an offset-row ASCII grid, with odd rows (relative to the topmost row) indented by two spaces to visually suggest a real hex tiling's row offset.

Polyhex Shapes Generator Use Cases

  • Generating example hexagon-based board layouts for a game or puzzle prototype
  • Illustrating the polyhex/polyomino family of shapes for a math or puzzle write-up
  • Quickly visualizing what a connected shape of a given hexagon count can look like

Common Mistakes

  • Expecting the same shape every time for a given count; the growth process is random, use Regenerate for a new one.
  • Assuming this enumerates or counts all distinct polyhexes of a size; it generates a single example only.
  • Treating the rendering as a precise geometric hex-tiling diagram rather than a simplified offset-row ASCII approximation.

Tips

  • Regenerate a few times at the same count to get a feel for the variety of shapes the growth algorithm can produce.
  • Start with a small count (4-10) to see the growth pattern clearly before trying larger shapes.

References

Frequently Asked Questions