maze

package
v0.0.0-...-e5b420f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2021 License: MIT Imports: 4 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintGraphNode

func PrintGraphNode(n *Node, isPrettyPrint bool) string

String implementation to print node

func PrintMaze

func PrintMaze(m *Map) string

String parsing maze map to text interpretation

Types

type Graph

type Graph struct {
	// Nodes with their relation
	Nodes map[string]*Node `json:"maze_nodes"`
}

Graph with nodes and paths

func DispatchToGraph

func DispatchToGraph(m *Map) *Graph

DispatchToGraph assemble graph to provide it to player

type Map

type Map struct {
	// Container of rows and columns
	Container [][]byte
	// Size of rows and columns
	Size, Height, Width int
	// Walls props
	Walls Walls
	// Key, Entrance, Exit locations
	Key, Entrance, Exit Point
	// KeyCode is unique string for key and exit
	KeyCode string
}

mazeMap by rows

func NewMaze

func NewMaze(rows, cols int) *Map

NewMaze generates a new map

func (*Map) Generate

func (m *Map) Generate()

Generate map

type Node

type Node struct {
	// Visited if node was traversed
	Visited bool `json:"-"`
	// Entity represent an value
	Entity byte `json:"entity,omitempty"`
	// Point holds location
	Point Point `json:"point"`

	// IsLeftNeighbor exist
	IsLeftNeighbor bool `json:"is_left_neighbor"`
	// IsRightNeighbor exist
	IsRightNeighbor bool `json:"is_right_neighbor"`
	// IsTopNeighbor exist
	IsTopNeighbor bool `json:"is_top_neighbor"`
	// IsBottomNeighbor exist
	IsBottomNeighbor bool `json:"is_bottom_neighbor"`

	// LeftNeighbor edged nodes
	LeftNeighbor *Node `json:"-"`
	// RightNeighbor edged nodes
	RightNeighbor *Node `json:"-"`
	// TopNeighbor edged nodes
	TopNeighbor *Node `json:"-"`
	// BottomNeighbor edged nodes
	BottomNeighbor *Node `json:"-"`
}

Node represent single cell

type Point

type Point struct {
	// X location
	X int `json:"x"`
	// Y location
	Y int `json:"y"`
}

Point in maze matrix

func (Point) GetId

func (p Point) GetId() string

GetId creates unique point hash

type Walls

type Walls struct {
	// Horizontal, Vertical wall, ignore first X
	Horizontal, Vertical [][]byte
}

Walls inside maze map

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL