state

package
v0.0.0-...-87e7153 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package state provides a way to visualise an 8x8 board as a 64 bit integer See https://www.chessprogramming.org/8x8_Board for an explanation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitBoard

type BitBoard uint64

func (*BitBoard) ToRunes

func (bb *BitBoard) ToRunes() ([8][8]rune, error)

TODO: maybe move these to utils package?

type Board

type Board struct {
	WhiteRooks   BitBoard
	WhiteKnights BitBoard
	WhiteBishops BitBoard
	WhiteQueens  BitBoard
	WhiteKing    BitBoard
	WhitePawns   BitBoard
	BlackRooks   BitBoard
	BlackKnights BitBoard
	BlackBishops BitBoard
	BlackQueens  BitBoard
	BlackKing    BitBoard
	BlackPawns   BitBoard
}

func (*Board) ToRunes

func (board *Board) ToRunes() ([8][8]rune, error)

Func ToRunes is a testing/debugging method to allow for human readable output from bitboards

type Fen

type Fen string

TODO: maybe change this to xfen for 960? see https://en.wikipedia.org/wiki/X-FEN

func GenerateCMLXFen

func GenerateCMLXFen() (Fen, error)

func GenerateCMLXFen generates a random number between 0 - 959 and maps it to the corresponding position using Scharnagl's table methods see https://en.wikipedia.org/wiki/Fischer_random_chess_numbering_scheme

func (Fen) ToBoard

func (f Fen) ToBoard() (Board, error)

Func ToBoard will create a Board struct, consisting of the 12 bitboards necessary to represent a chessboard, from a given fen string TODO: refactor this to be part of a complete ToState function

type State

type State struct {
	Board Board
}

func NewCMLXGame

func NewCMLXGame() (State, error)

Func NewCMLXGame will create a new State struct with the initial starting parameters of a chess 960 game

func NewCustomPosition

func NewCustomPosition(f Fen) (State, error)

Func NewCustomPosition will create a new State struct with the parameters from a specified FEN string

func NewStandardGame

func NewStandardGame() (State, error)

Func NewStandardGame will create a new State struct with the initial starting parameters of a standard chess game

Jump to

Keyboard shortcuts

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