chess

package
v0.0.0-...-79bf6db Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const BOARD_SIZE int = 8

BOARD_SIZE size of the board to attempt to solve

Variables

View Source
var SENTINEL = struct{}{}

Functions

func GetScore

func GetScore(piece Piece) (int, error)

Types

type Board

type Board [BOARD_SIZE][BOARD_SIZE]*cell

Board a fully inflated board to be worked on

func (*Board) GetCoverageLevel

func (b *Board) GetCoverageLevel() (result int)

GetCoverageLevel reports how many of the cells on the board are covered

func (*Board) ProposeBoards

func (b *Board) ProposeBoards(heuristic func(board *Board) (float32, error)) (MinimalBoardSet, error)

ProposeBoards is used to calculate all the potential boards that could be reached from a given board. It is where the algorithm spends most of its time, and any additional early pruning techniques would benefit it greatly

func (*Board) Score

func (b *Board) Score() (int, error)

Score reports the piece based score for a board

func (*Board) String

func (b *Board) String(heuristic func(board *Board) (float32, error)) string

String this draws the board in negative x, y space

type MinimalBoard

type MinimalBoard struct {
	Heuristic float32
	IsSolved  bool
	Score     int
	Coverage  int
	// contains filtered or unexported fields
}

MinimalBoard the representation used to store boards that are not actively being worked on

func (MinimalBoard) RebuildBoard

func (m MinimalBoard) RebuildBoard() (*Board, error)

RebuildBoard re-inflates a MinimalBoard, and rebuilds the support graph

func (MinimalBoard) String

func (m MinimalBoard) String() string

type MinimalBoardSet

type MinimalBoardSet map[MinimalBoard]struct{}

MinimalBoardSet a map wrapper for tracking sets of boards

func (MinimalBoardSet) Contains

func (m MinimalBoardSet) Contains(board MinimalBoard) bool

func (MinimalBoardSet) Put

func (m MinimalBoardSet) Put(board MinimalBoard)

type Piece

type Piece byte
const (
	NONE Piece = iota
	PAWN
	KNIGHT
	BISHOP
	ROOK
	QUEEN
)

names for all the pieces

func (Piece) GetRune

func (p Piece) GetRune() rune

Jump to

Keyboard shortcuts

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