util

package
v0.0.0-...-96e4a8d Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2014 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package util provides utility functions for building gogp models.

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = Options{
	MaxGen:        40,
	PopSize:       500,
	TournSize:     7,
	TargetFitness: 0.9999,
	Threads:       runtime.NumCPU(),
	CrossoverProb: 0.5,
	MutateProb:    0.2,
}

Functions

func CheckErr

func CheckErr(err error)

CheckErr exits with an error if err is not nil

func Mod

func Mod(a, b int) int

positive modulus

func Open

func Open(path string) *bufio.Scanner

Open opens a file for reading and returns line scanner

func ParseFlags

func ParseFlags(opts *Options)

ParseFlags reads command flags and sets no. of threads and random seed.

func Read

func Read(s *bufio.Scanner, args ...interface{}) bool

Read reads a line from the scanner, returns true if line was read

Types

type Options

type Options struct {
	TournSize, MaxGen                        int
	PopSize, Threads                         int
	TargetFitness, CrossoverProb, MutateProb float64
	Plot, Verbose                            bool
	Seed                                     int64
}

Options struct holds global configuration options

type Plot

type Plot struct {
	*svg.SVG
	// contains filtered or unexported fields
}

Plot structure represets a svgo plot

func SVGPlot

func SVGPlot(width, height, cellSize int) *Plot

SVGPlot function creates a new plot with given size

func (*Plot) AddGrid

func (p *Plot) AddGrid(cols, rows, delay int, style func(x, y int) string)

Grid method draws a grid with given size, callback function returns style for each cell

func (*Plot) Animate

func (p *Plot) Animate(id string, path [][2]int, style map[string]string)

Animate method moves the given object leaving a trail

func (*Plot) AnimateMulti

func (p *Plot) AnimateMulti(id string, path [][][4]int, styles []string)

AnimateMulti method moves a set of objects

func (*Plot) Data

func (p *Plot) Data() []byte

Data method returns the SVG data as a byte array

Jump to

Keyboard shortcuts

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