opening

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

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

Go to latest
Published: Jul 27, 2016 License: MIT Imports: 7 Imported by: 1 module, 1 package

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

opening

GoDoc Build Status Go Report Card

Datasource

The Encyclopaedia of Chess Openings (ECO) functions as the datasource for this package. A consise list of openings with PGNs can be found here.

Visual

Advance Variation subtree of the French Defense:

subtree

Example

package main

import (
    "fmt"

    "github.com/notnil/chess"
    "github.com/notnil/opening"
)

func main(){
    g := chess.NewGame()
    g.MoveStr("e4")
    g.MoveStr("e6")
    
    o := opening.Find(g.Moves())
    fmt.Println(o.Title()) // French Defense
}

Documentation

Overview

Package opening implements chess opening determination and exploration.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Opening

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

A Opening represents a specific sequence of moves from the staring position.

func Find

func Find(moves []*chess.Move) *Opening

Find returns the most specific opening for the list of moves. If no opening is found, Find returns nil.

Example
package main

import (
	"fmt"

	"github.com/notnil/chess"
	"github.com/notnil/opening"
)

func main() {
	g := chess.NewGame()
	g.MoveStr("e4")
	g.MoveStr("e6")

	// print French Defense
	o := opening.Find(g.Moves())
	fmt.Println(o.Title())
}

func Possible

func Possible(moves []*chess.Move) []*Opening

Possible returns the possible openings after the moves given. If moves is empty or nil all openings are returned.

Example
package main

import (
	"fmt"

	"github.com/notnil/chess"
	"github.com/notnil/opening"
)

func main() {
	g := chess.NewGame()
	g.MoveStr("e4")
	g.MoveStr("d5")

	// print all variantions of the Scandinavian Defense
	for _, o := range opening.Possible(g.Moves()) {
		fmt.Println(o.Title())
	}
}

func (*Opening) Code

func (o *Opening) Code() string

Code returns the Encyclopaedia of Chess Openings (ECO) code.

func (*Opening) Game

func (o *Opening) Game() *chess.Game

Game returns the opening as a game.

func (*Opening) PGN

func (o *Opening) PGN() string

PGN returns the opening in PGN format.

func (*Opening) Title

func (o *Opening) Title() string

Title returns the Encyclopaedia of Chess Openings (ECO) title of the opening.

Jump to

Keyboard shortcuts

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