movegen

package
v0.0.0-...-786fda4 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Divide

func Divide(p core.Position, depth int) map[core.Move]int

Divide returns a map from legal moves to Perft node counts at a decremented depth.

Divide returns nil if depth is not positive.

Example
var (
	p = core.NewPosition()
	m = pcn.MustDecode("e2e4")
)

// How many leaf nodes at depth 3 start with e2e4?
fmt.Println("e2e4:", Divide(p, 3)[m])
// After e2e4, how many leaf nodes are at depth 2?
p.Make(m)
fmt.Println("e2e4:", Perft(p, 2))
Output:

e2e4: 600
e2e4: 600

func LegalMoves

func LegalMoves(p core.Position) []core.Move

LegalMoves returns all legal moves in a position.

func Perft

func Perft(p core.Position, depth int) int

Perft returns the number of leaf nodes at the selected depth in a position's move tree.

Perft returns zero if depth is negative.

Example
p := core.NewPosition()

// Count the number of leaf nodes at each depth in the move tree.
for i := range 4 {
	fmt.Printf("Perft(%d) = %d\n", i, Perft(p, i))
}
Output:

Perft(0) = 1
Perft(1) = 20
Perft(2) = 400
Perft(3) = 8902

Types

This section is empty.

Directories

Path Synopsis
internal
reference
Package reference is a reference move generator implementation.
Package reference is a reference move generator implementation.

Jump to

Keyboard shortcuts

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