automata

package module
v0.0.0-...-8d87b16 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2020 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Simple Cell Automata

GitHub contributors GitHub forks GitHub stars GitHub issues Go Report Card

Demo Gif

Table of Contents

Introduction

Installation

go get github.com/jtheiss19/Simple-Cell-Automata

Setup

Navigate to the top folder and run the main package

$ cd $GOPATH/src/github.com/jtheiss19/Simple-Cell-Automata
$ go run .

Features

License

MIT license

Documentation

Overview

Package automata is a simple package for adding a felxable cellular automata simulations to go!

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cell

type Cell struct {
	Type     string
	XPos     int
	YPos     int
	Value    float64
	Grid     *Grid
	SimFunc  func(*Cell)
	DrawFunc func(*gg.Context, *Cell)
}

Cell remain mostly unchanged, they carry the Value Type which can carry type such as "air" or "wood" for tree simulation

type Grid

type Grid struct {
	ColSize  int
	RowSize  int
	CellList []*Cell
}

Grid carrys a reference to and overidable function called simFunction. This is so the user can define a function and pass it to the specific Grid. That way they can run parrell simulations

func NewGrid

func NewGrid(xSize, ySize int) *Grid

NewGrid is the constructor function for the Grid object

func (*Grid) CopyGrid

func (g *Grid) CopyGrid() *Grid

CopyGrid preforms a deep copy of the Grid to create new references in memory

func (*Grid) GetCell

func (g *Grid) GetCell(x, y int) *Cell

GetCell is used to grab a specific cell

func (*Grid) PrettyPrint

func (g *Grid) PrettyPrint()

PrettyPrint prints the Grid to terminal, if it isn't pretty your Grid is wider then your terminal

func (*Grid) PrintPNG

func (g *Grid) PrintPNG(fileType string)

PrintPNG prints a png of the current Grid to the folder the program is ran in

func (*Grid) RunSimulation

func (g *Grid) RunSimulation(steps int, interupt func(*Grid, int))

RunSimulation calls the Grids simulate function multiple times

func (*Grid) SetupGrid

func (g *Grid) SetupGrid(SetupFunc func(*Grid, int, int))

func (*Grid) Simulate

func (g *Grid) Simulate()

Simulate calls the Grids simulate function, defined here explicitly for potential pre-flight checks

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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