viva_aion/grid

Grid - 2D spatial structure

The fabric of reality. A discrete 2D space where consciousness can exist and move.

Types

A 2D grid of tiles

pub type Grid {
  Grid(width: Int, height: Int, tiles: dict.Dict(Int, tile.Tile))
}

Constructors

Values

pub fn center(grid: Grid) -> position.Position

Get center position

pub fn count(grid: Grid, target: tile.Tile) -> Int

Count tiles of a specific type

pub fn find_all(
  grid: Grid,
  target: tile.Tile,
) -> List(position.Position)

Get all positions of a specific tile type

pub fn get(grid: Grid, pos: position.Position) -> tile.Tile

Get tile at position

pub fn is_core(grid: Grid, pos: position.Position) -> Bool

Check if position is the core

pub fn is_passable(grid: Grid, pos: position.Position) -> Bool

Check if position is passable

pub fn new(width: Int, height: Int, fill: tile.Tile) -> Grid

Create a new grid filled with a tile

pub fn new_walls(width: Int, height: Int) -> Grid

Create a grid filled with walls

pub fn passable_neighbors(
  grid: Grid,
  pos: position.Position,
) -> List(position.Position)

Get passable neighbors

pub fn passable_positions(grid: Grid) -> List(position.Position)

Get all passable positions

pub fn set(
  grid: Grid,
  pos: position.Position,
  t: tile.Tile,
) -> Grid

Set tile at position

pub fn to_string(grid: Grid) -> String

Convert grid to string visualization

pub fn to_string_with_marker(
  grid: Grid,
  marker_pos: position.Position,
) -> String

Convert grid to string with position marker

Search Document