go-chess-cli, v1.2
Posted on

The chess program with a terminal-based interface.
Displaying in the colorful mode pieces and a board.
Change Log
- displaying:
- in the colorful mode:
- pieces (optional);
- board (optional);
- fix displaying a board in the wide mode.
- in the colorful mode:
Features
- displaying a board:
- by symbols (to choose):
- ASCII;
- Unicode;
- by size (to choose):
- terse;
- wide;
- by colors (to choose):
- monochrome;
- colorful;
- misc.:
- marking searching process;
- placing a human side at bottom;
- by symbols (to choose):
- interacting via text commands (moves in pure algebraic coordinate notation);
- options:
- initial position in Forsyth–Edwards notation;
- human color (i.e. a computer can move first):
- support automatic random selecting (optional);
- move searching restrictions:
- maximal size of the transposition table;
- deep of move searching;
- duration of move searching;
- displaying:
- switching between ASCII/Unicode modes;
- switching between terse/wide modes;
- switching between monochrome/colorful modes.
Usage
$ go-chess-cli -h | -help | --help
$ go-chess-cli [options]
Options:
-h,-help,--help— show the help message and exit;-cacheSize ITEMS— maximal cache size (default:1000000, i.e. one million);-colorfulBoard {false|true}— use colors to display the board (default:true; for inverting use-colorfulBoard=false);-colorfulPieces {false|true}— use colors to display pieces (default:true; for inverting use-colorfulPieces=false);-deep INTEGER— search deep (default:5);-duration DURATION— search duration (e.g.72h3m0.5s; default:5s);-fen STRING— board in FEN (default:rnbqk/ppppp/5/PPPPP/RNBQK, i.e. Gardner's minichess);-humanColor {random|black|white}— human color (default:random);-pieceBlackColor INTEGER— SGR parameter for ANSI escape sequences for setting a color of black pieces (default:34; see for details: https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit);-pieceWhiteColor INTEGER— SGR parameter for ANSI escape sequences for setting a color of white pieces (default:31; see for details: https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit);-squareBlackColor INTEGER— SGR parameter for ANSI escape sequences for setting a color of black squares (default:40; see for details: https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit);-squareWhiteColor INTEGER— SGR parameter for ANSI escape sequences for setting a color of white squares (default:47; see for details: https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit);-unicode {false|true}— use Unicode to display pieces (default:true; for inverting use-unicode=false);-wide {false|true}— display the board wide (default:true; for inverting use-wide=false).
Examples
ascii.PieceStorageEncoder.EncodePieceStorage() with colors:
package main
import (
"fmt"
"github.com/thewizardplusplus/go-chess-cli/encoding/ascii"
climodels "github.com/thewizardplusplus/go-chess-cli/models"
models "github.com/thewizardplusplus/go-chess-models"
"github.com/thewizardplusplus/go-chess-models/encoding/uci"
"github.com/thewizardplusplus/go-chess-models/pieces"
)
func main() {
colorizer := func(text string, color climodels.OptionalColor) string {
var colorMark byte
if color.IsSet {
colorMark = ascii.EncodeColor(color.Value)[0]
} else {
colorMark = 'n'
}
return fmt.Sprintf("(%c%s)", colorMark, text)
}
const fen = "r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R"
storage, _ := uci.DecodePieceStorage(fen, pieces.NewPiece, models.NewBoard)
encoder := ascii.NewPieceStorageEncoder(
uci.EncodePiece,
"x",
ascii.Margins{},
colorizer,
models.Black,
1,
)
fmt.Printf("%v\n", encoder.EncodePieceStorage(storage))
// Output:
// (n8)(wr)(bx)(wx)(bx)(wk)(bx)(wx)(br)
// (n7)(bp)(wx)(bp)(wp)(bq)(wp)(bb)(wx)
// (n6)(wb)(bn)(wx)(bx)(wp)(bn)(wp)(bx)
// (n5)(bx)(wx)(bx)(wP)(bN)(wx)(bx)(wx)
// (n4)(wx)(bp)(wx)(bx)(wP)(bx)(wx)(bx)
// (n3)(bx)(wx)(bN)(wx)(bx)(wQ)(bx)(wp)
// (n2)(wP)(bP)(wP)(bB)(wB)(bP)(wP)(bP)
// (n1)(bR)(wx)(bx)(wx)(bK)(wx)(bx)(wR)
// (n )(na)(nb)(nc)(nd)(ne)(nf)(ng)(nh)
}
Repository
Link: https://github.com/thewizardplusplus/go-chess-cli/tree/v1.2.
Content: code.
License: MIT.
Screenshots
With ASCII symbols, colorful pieces and a colorful board in the wide mode

With Unicode symbols and colorful pieces in the wide mode

With ASCII symbols and colorful pieces in the wide mode

With Unicode symbols, colorful pieces and a colorful board in the terse mode

With ASCII symbols, colorful pieces and a colorful board in the terse mode

With Unicode symbols and colorful pieces in the terse mode

With ASCII symbols and colorful pieces in the terse mode
