Skip to content

High level classes created for working with hexagonal grids in python easier.

License

Notifications You must be signed in to change notification settings

elisgrahn/hexpy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hexpy

The purpose of hexpy is a hobby project that eases working with hexagonal grids in python, focusing on readable code which should be easy to use.

hexpy logo

Note: This work has been heavily inspired by the beautiful work of redblobgames, who provide a fantastic post about ways to represent hexagonal grids with both illustrations and code examples.

Usage

Work in progress

  • Creation

  • Navigation

Since I personally found it quite challenging to wrap my head around navigating in hexagonal grids using the cube coordinate system, i wrote code and created visualizations that should make it somewhat easier.

For instance the clock- and angle-system by Hex Chogi featured in Hexagonal chess was the inspiration for the visualizations below.

Pointy Hexclock Regular Clock Flat Hexclock
Pointy Hexclock Regular Clock Flat Hexclock

These systems can be accessed once a layout has been defined (if a custom one is used it defaults to pointy).

>>> from hexpy import Hex

>>> Hex.pointy_layout(10)

>>> # Direct neighbor
>>> Hex.hexclock(1)
Hex(q=2, r=-1, s=-1)

>>> # Diagonal neighbor
>>> Hex.o_clock(2)
Hex(q=1, r=0, s=-1)

>>> # Also for instances:
>>> h = Hex(1, 0)
>>> h.hexclock

About

High level classes created for working with hexagonal grids in python easier.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages