checkerlution

package module
v0.0.0-...-a536df0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2014 License: Apache-2.0 Imports: 10 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

Build Status

A checkers bot implementation for checkers-bot which uses a neural network to do its thinking. The same essential approach is used as described in Blondie24: Playing at the edge of AI.

The underlying neural network library code is found in neurgo and neurvolve.

Big Picture

architecture png

Install pre-requisites

  • Go 1.1 or later

Install checkerlution

$ go get github.com/tleyden/checkerlution
$ go get github.com/couchbaselabs/go.assert

Validate installation - run tests

$ cd $GOPATH/src/github.com/tleyden/checkerlution
$ go test -v

Install Pre-requisites

Checkers-iOS is not strictly required, but very useful in order to view the game.

Configure checkerlution

There are command line options to tell it which server to use. See main/run.sh for examples.

Run checkerlution

$ cd $GOPATH/github.com/tleyden/checkerlution/main
$ go run main.go

Documentation

Index

Constants

View Source
const (
	RUNNING_MODE = iota
	TRAINING_MODE
)
View Source
const EMPTY_SQUARE = 0.0
View Source
const OPPONENT_KING = -1.0
View Source
const OPPONENT_PIECE = -0.7
View Source
const OUR_KING = 1.0
View Source
const OUR_PIECE = 0.7

Variables

This section is empty.

Functions

func LoadCortex

func LoadCortex(cortexId string, db couch.Database) *ng.Cortex

Types

type Agent

type Agent struct {
	// contains filtered or unexported fields
}

func NewAgent

func NewAgent(cortex *ng.Cortex, parent_id string) *Agent

func (Agent) MarshalJSON

func (agent Agent) MarshalJSON() ([]byte, error)

func (*Agent) UnmarshalJSON

func (agent *Agent) UnmarshalJSON(data []byte) error

type AgentJson

type AgentJson struct {
	Cortex_id string
	Parent_id string
}

type Checkerlution

type Checkerlution struct {
	// contains filtered or unexported fields
}

func (Checkerlution) Cortex

func (c Checkerlution) Cortex() *ng.Cortex

func (*Checkerlution) CreateActuator

func (c *Checkerlution) CreateActuator() *ng.Actuator

func (*Checkerlution) CreateHiddenLayer1Neurons

func (c *Checkerlution) CreateHiddenLayer1Neurons(outputNeuron *ng.Neuron) []*ng.Neuron

func (*Checkerlution) CreateHiddenLayer2Neurons

func (c *Checkerlution) CreateHiddenLayer2Neurons(layer1Neurons []*ng.Neuron, outputNeuron *ng.Neuron) []*ng.Neuron

func (*Checkerlution) CreateNeurgoCortex

func (c *Checkerlution) CreateNeurgoCortex()

func (*Checkerlution) CreateOutputNeuron

func (c *Checkerlution) CreateOutputNeuron() *ng.Neuron

func (*Checkerlution) CreateSensors

func (c *Checkerlution) CreateSensors()

func (*Checkerlution) GameFinished

func (c *Checkerlution) GameFinished(gameState cbot.GameState) (shouldQuit bool)

func (*Checkerlution) LoadNeurgoCortex

func (c *Checkerlution) LoadNeurgoCortex(filename string)

func (*Checkerlution) SetMode

func (c *Checkerlution) SetMode(mode OperationMode)

func (*Checkerlution) Start

func (c *Checkerlution) Start(ourTeamId cbot.TeamType)

func (*Checkerlution) StartWithCortex

func (c *Checkerlution) StartWithCortex(cortex *ng.Cortex, ourTeamId cbot.TeamType)

func (Checkerlution) Stop

func (c Checkerlution) Stop()

func (*Checkerlution) Think

func (c *Checkerlution) Think(gameState cbot.GameState) (bestMove cbot.ValidMove, ok bool)

type CheckerlutionFlags

type CheckerlutionFlags struct {
	CheckersBotFlags cbot.CheckersBotFlags
	PopulationName   string
}

type CheckerlutionRecorder

type CheckerlutionRecorder struct {
	// contains filtered or unexported fields
}

func NewRecorder

func NewRecorder(syncGatewayUrl string, populationName string) *CheckerlutionRecorder

This assumes the population does not already exist in the database and so it will create it

func (*CheckerlutionRecorder) AddFitnessScore

func (r *CheckerlutionRecorder) AddFitnessScore(score float64, cortex *ng.Cortex, opponent *ng.Cortex)

func (*CheckerlutionRecorder) AddGeneration

func (r *CheckerlutionRecorder) AddGeneration(evaldCortexes []nv.EvaluatedCortex)

func (CheckerlutionRecorder) GetLatestGenerationCortexes

func (r CheckerlutionRecorder) GetLatestGenerationCortexes() []*ng.Cortex

func (*CheckerlutionRecorder) InitDbConnection

func (r *CheckerlutionRecorder) InitDbConnection()

func (*CheckerlutionRecorder) Save

func (r *CheckerlutionRecorder) Save()

func (*CheckerlutionRecorder) SaveCortex

func (r *CheckerlutionRecorder) SaveCortex(cortex *ng.Cortex)

type CheckerlutionScape

type CheckerlutionScape struct {
	// contains filtered or unexported fields
}

func (*CheckerlutionScape) Fitness

func (scape *CheckerlutionScape) Fitness(cortex *ng.Cortex) (fitness float64)

func (*CheckerlutionScape) FitnessAgainst

func (scape *CheckerlutionScape) FitnessAgainst(cortex *ng.Cortex, opponentCortex *ng.Cortex) (fitness float64)

func (*CheckerlutionScape) SetFeedType

func (scape *CheckerlutionScape) SetFeedType(feedType cbot.FeedType)

func (*CheckerlutionScape) SetRandomDelayBeforeMove

func (scape *CheckerlutionScape) SetRandomDelayBeforeMove(delay int)

func (*CheckerlutionScape) SetSyncGatewayUrl

func (scape *CheckerlutionScape) SetSyncGatewayUrl(syncGatewayUrl string)

func (*CheckerlutionScape) SetTeam

func (scape *CheckerlutionScape) SetTeam(team cbot.TeamType)

type CheckerlutionTrainer

type CheckerlutionTrainer struct{}

func (*CheckerlutionTrainer) RunPopulationTrainer

func (trainer *CheckerlutionTrainer) RunPopulationTrainer(checkerlutionFlags CheckerlutionFlags)

func (*CheckerlutionTrainer) RunTopologyMutatingTrainer

func (trainer *CheckerlutionTrainer) RunTopologyMutatingTrainer(checkersBotFlags cbot.CheckersBotFlags)

type Game

type Game struct {
	// contains filtered or unexported fields
}

func (Game) MarshalJSON

func (game Game) MarshalJSON() ([]byte, error)

func (*Game) UnmarshalJSON

func (game *Game) UnmarshalJSON(data []byte) error

type GameJson

type GameJson struct {
	Red_player_id  string
	Blue_player_id string
	Winner_id      string
}

type GameStateVector

type GameStateVector []float64

game state array with 32 elements, possible values: OPPONENT_KING OPPONENT_PIECE EMPTY_SQUARE OUR_PIECE OUR_KING

func NewGameStateVector

func NewGameStateVector() GameStateVector

type Generation

type Generation struct {
	// contains filtered or unexported fields
}

func NewGeneration

func NewGeneration(number int, agents []Agent) *Generation

func (*Generation) AddGame

func (generation *Generation) AddGame(game Game)

func (Generation) MarshalJSON

func (generation Generation) MarshalJSON() ([]byte, error)

func (*Generation) UnmarshalJSON

func (generation *Generation) UnmarshalJSON(data []byte) error

type GenerationJson

type GenerationJson struct {
	Start_time string
	Number     int
	State      string
	Agents     []Agent
	Games      []Game
}

type OperationMode

type OperationMode int

type Population

type Population struct {
	// contains filtered or unexported fields
}

func (*Population) AddGeneration

func (population *Population) AddGeneration(generation Generation)

func (Population) CurrentGeneration

func (population Population) CurrentGeneration() *Generation

func (Population) CurrentGenerationNumber

func (population Population) CurrentGenerationNumber() int

func (Population) MarshalJSON

func (population Population) MarshalJSON() ([]byte, error)

func (Population) NextGenerationNumber

func (population Population) NextGenerationNumber() int

func (*Population) UnmarshalJSON

func (population *Population) UnmarshalJSON(data []byte) error

type PopulationJson

type PopulationJson struct {
	Name        string
	Rev         string `json:"_rev"`
	Generations []Generation
}

hack to be able to go back and forth from json

type ValidMoveCortexInput

type ValidMoveCortexInput struct {
	// contains filtered or unexported fields
}

func NewValidMoveCortexInput

func NewValidMoveCortexInput(validMove cbot.ValidMove, piece cbot.Piece) ValidMoveCortexInput

func (ValidMoveCortexInput) Equals

func (move ValidMoveCortexInput) Equals(other ValidMoveCortexInput) bool

func (ValidMoveCortexInput) VectorRepresentation

func (move ValidMoveCortexInput) VectorRepresentation() []float64

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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