Documentation
¶
Overview ¶
Copyright © 2021 Brian Longmore brianl.ext@gmail.com
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- func ClearAndSpawnCells(gameConfig GameConfig, frameCells FrameCells)
- func GetConfigListString(gameConfig GameConfig) string
- func IsCoordOutOfFrame(gameConfig GameConfig, x, y int) bool
- func RunGame(gameConfig GameConfig, initPattern Pattern)
- type Cell
- type CellNeighbors
- type FrameCells
- type GameConfig
- type Pattern
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearAndSpawnCells ¶
func ClearAndSpawnCells(gameConfig GameConfig, frameCells FrameCells)
ClearAndSpawnCells updates the cell string that is printed to the command line.
func GetConfigListString ¶ added in v1.2.0
func GetConfigListString(gameConfig GameConfig) string
GetConfigListString returns config list string from gameConfig.
func IsCoordOutOfFrame ¶
func IsCoordOutOfFrame(gameConfig GameConfig, x, y int) bool
IsCoordOutOfFrame returns whether or not the cell at (x,y) is out of the frame.
func RunGame ¶
func RunGame(gameConfig GameConfig, initPattern Pattern)
RunGame runs the game based on the passed args.
Types ¶
type Cell ¶
type Cell struct { X int Y int IsAlive bool LivingNeighbors CellNeighbors }
func GetCellByCoord ¶
func GetCellByCoord(gameConfig GameConfig, frameCells FrameCells, x, y int) Cell
GetCellByCoord returns the cell that is at (x,y).
func GetNewCell ¶ added in v1.1.0
func GetNewCell(gameConfig GameConfig, frameCells FrameCells, cell Cell) Cell
GetNewCell returns a new cell from the passed cell according to the life conditions.
type CellNeighbors ¶
type CellNeighbors []Cell
func GetLivingNeighborsByCoord ¶
func GetLivingNeighborsByCoord(gameConfig GameConfig, frameCells FrameCells, x, y int) CellNeighbors
GetLivingNeighborsByCoord returns a slice of cells that neighbor the cell at (x,y).
type FrameCells ¶
type FrameCells []Cell
func GetFrameCellsByPattern ¶
func GetFrameCellsByPattern(gameConfig GameConfig, pattern Pattern) FrameCells
GetFrameCellsByPattern converts a pattern string to frame cells.
func UpdateCells ¶
func UpdateCells(gameConfig GameConfig, frameCells FrameCells) FrameCells
UpdateCells returns new frame cells after evaluating the living state of frameCells.