maze

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2019 License: BSL-1.0 Imports: 6 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToGif

func ToGif(filename string, w, h, scale, delay int, items [][]int, palette []color.Color)

ToGif :

Types

type Maze

type Maze interface {
	StickDown(seed int64)
	Digging(seed int64)
	Solve()
	ToPng(filename string, scale int, palette []color.Color)
	Data() []int
	Set(data []int)
}

Maze :

Example
// mazeWidth and mazeHeight should odd number.
mazeWidth, mazeHeight := 37, 27
m := NewMaze(mazeHeight, mazeWidth)
seed := time.Now().UnixNano()

// GIF画像生成用素材の格納
var debug [][]int

// 棒倒し法で迷路を生成
m.StickDown(seed)
debug = append(debug, m.Data())
// 迷路の最短経路となる解を導出
m.Solve()
debug = append(debug, m.Data())

// 穴掘り法で迷路を生成
m.Digging(seed)
debug = append(debug, m.Data())
// 迷路の最短経路となる解を導出
m.Solve()
debug = append(debug, m.Data())

// 画像マッピング用の色を格納
palette := []color.Color{
	color.RGBA{184, 134, 11, 255},
	color.RGBA{240, 230, 140, 255},
	color.RGBA{255, 0, 255, 255},
}
// 10倍スケール(270×370)のpng画像を生成(maze.png)
m.ToPng("maze", 10, palette)
// 10倍スケール(270×370)のGIF画像を生成(mazegif.gif)
ToGif("mazegif", mazeWidth, mazeHeight, 10, 100, debug, palette)
Output:

func NewMaze

func NewMaze(row, column int) Maze

NewMaze :

Jump to

Keyboard shortcuts

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