conway

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2025 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Paused  = "Paused"
	Running = "Running"
)

Variables

This section is empty.

Functions

func Draw

func Draw(ap *ansipixels.AnsiPixels, c *Conway)

Types

type Cell

type Cell uint8 // same as bool but can be counted directly.

type Conway

type Conway struct {
	Width   int
	Height  int
	Cells   [2][]Cell
	Current int
}

func NewConway

func NewConway(width, height int) *Conway

func (*Conway) At

func (c *Conway) At(x, y int) Cell

func (*Conway) Clear

func (c *Conway) Clear(x, y int)

func (*Conway) ClearCurrent

func (c *Conway) ClearCurrent(x, y int)

func (*Conway) Copy

func (c *Conway) Copy(x, y int)

func (*Conway) Count

func (c *Conway) Count(x, y int) Cell

func (*Conway) Glider

func (c *Conway) Glider(x, y int)

func (*Conway) Next

func (c *Conway) Next()

func (*Conway) Randomize

func (c *Conway) Randomize(fillFactor float32)

func (*Conway) SafeSet

func (c *Conway) SafeSet(x, y int)

Handles negative and out of bounds coordinates.

func (*Conway) Set

func (c *Conway) Set(x, y int)

func (*Conway) SetCurrent

func (c *Conway) SetCurrent(x, y int)

type Game

type Game struct {
	AP         *ansipixels.AnsiPixels
	C          *Conway
	State      GameState
	ShowInfo   bool
	ShowHelp   bool
	Generation uint64

	Delta int // which 1/2 pixel we're targeting with the mouse.

	HasMouse bool
	Extra    func()
	// contains filtered or unexported fields
}

func (*Game) DrawOne

func (g *Game) DrawOne()

func (*Game) End

func (g *Game) End()

func (*Game) HandleMouse

func (g *Game) HandleMouse()

func (*Game) Next

func (g *Game) Next()

func (*Game) Start

func (g *Game) Start()

Call once after randomize or reset/restart.

type GameState

type GameState string

Jump to

Keyboard shortcuts

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