flins.space package¶
Submodules¶
flins.space.grids module¶
Be a spatial divider, not a uniter
Support the calculation of adjacency, distance, and mirroring on hexagonal grids with various shapes.
-
class
flins.space.grids.
Grid
[source]¶ Bases:
flins.base.Base
-
abstract property
all_entries
¶ Return all entries in the grid
-
abstract property
-
class
flins.space.grids.
HexGrid
(n, mirror=True)[source]¶ Bases:
flins.space.grids.Grid
A world that is in a hexagonal shape with a radius of n hexes
Create a hexagonal grid that we’ll use as a model of tracts
- Parameters
n (int) – radius of the world. 0 is a single tract, 1 is seven and so on
mirror (bool (True)) – whether to mirror when calculating neighbors and distances
-
property
all_entries
¶ All entries in the grid
-
mirror
(loc)[source]¶ Return the location, mirrored across the boundary if needed
Use pre-calculated mirrored centers if given, else calculate them. Reference here: https://gamedev.stackexchange.com/questions/137603
-
class
flins.space.grids.
RectGrid
(size, mirror=True)[source]¶ Bases:
flins.space.grids.Grid
A rectangular grid of n-by-m hexs
Create a rectangular grid that we’ll use as a model of tracts
- Parameters
size (tuple (n, m)) – size of the world, n rows and m columns
mirror (bool (True)) – whether to mirror when calculating neighbors and distances
-
property
all_entries
¶ Return all entries in the grid
flins.space.space module¶
Space is the place we store stuff.
A space accounts for the interactions of tracts that are arranged according to some grid layout.
-
class
flins.space.space.
Space
(kind, size, span=None, mirror=True)[source]¶ Bases:
flins.base.Base
A spatial region of filaments/crosslinkers
Each Space is connected to neighbors in a hexagonal grid that gives many of the properties of 3D space but with easier mechanics.
A generic template for :Parameters: * kind (“hex” or “rect”) – overall shape of the space
size (int or tuple) – Radius or x/y size of space
span (None or float) – Length of the tracts in x dimension, optional
tracts (None or list) – List of tracts
-
property
all_tracts
¶ Give all the tracts back
flins.space.tract module¶
Just a slice of the cake^h^h^h^h space.
Tracts are sections of space that extend in a long direction and have adjacent neighboring tracts that also extend in a long direction.
-
class
flins.space.tract.
Tract
(loc, space)[source]¶ Bases:
flins.base.Base
A single tract in a Space
A single tract in a space
-
property
neighbors
¶ Who are your neighbors? We don’t want to calculate this each time, but we can’t populate it on creation as there are neighbors that haven’t yet been created. So we populate this list on the first call and then reference the stored version thereafter.
-
property
reachable
¶ Reachable tracts from here. Neighbors and self.
See neighbors documentation for creation method.
-
property