fischerchess

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

README

fischerchess - Fischer Random Chess engine

A small Go library that provides Fischer Random (Chess960) starting positions and helpers to create valid chess boards from those positions. It builds on the github.com/elaxer/standardchess and github.com/elaxer/chess packages.

Features

  • Provides the full list of 960 valid starting piece placements in Variants.
  • Convenience function NewBoard() that returns a random Chess board arranged according to one of the 960 valid starting positions.
  • Test coverage validating position symmetry, bishop coloring, and castling availability.

Quick start

Install:

go get github.com/elaxer/fischerchess

Basic usage:

package main

import (
	"fmt"
	"github.com/elaxer/fischerchess"
	"github.com/elaxer/standardchess/encoding/fen"
)

func main() {
	board := fischerchess.NewBoard()
	fmt.Println(fen.Encode(board).String()) // example: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
}

Decode a known variant (from Variants):

import "github.com/elaxer/standardchess/encoding/fen"

board, err := fen.Decode(fischerchess.Variants[0])
if err != nil {
	panic(err)
}

API

  • func NewBoard() chess.Board — returns a new board with a randomly selected Fischer Random starting layout.
  • var Variants []string — array containing 960 valid starting piece placement FENs (piece placement only, without side-to-move, castling, etc.).

Testing

Run tests:

go test ./...

The test suite checks that each starting variant decodes correctly, pieces are mirrored between White and Black ranks, bishops are on opposite-colored squares, and castling rights are available.

Contributing

Bug reports and contributions are welcome. Please open issues or pull requests against this repository. Keep changes small and add tests for new behavior.

License

The GNU General Public License

Documentation

Overview

Package fischerchess implements Fischer Random Chess (Chess960) specific functionality on top of the standard chess library.

Index

Constants

This section is empty.

Variables

View Source
var Variants = [960]string{}/* 960 elements not displayed */

Variants contains the 960 valid starting positions for Fischer Random Chess in FEN notation (without the side to move, castling rights, en passant target square, halfmove clock, and fullmove number).

Functions

func NewBoard added in v0.1.1

func NewBoard() chess.Board

NewBoard creates a new Fischer Random Chess board with pieces arranged according to one of the 960 valid starting positions, selected randomly.

Types

This section is empty.

Jump to

Keyboard shortcuts

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