pcn

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: 3 Imported by: 0

Documentation

Overview

Package pcn implements encoding and decoding of pure coordinate notation (PCN).

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(s string) (core.Move, error)

Decode decodes a PCN string and returns the move it represents.

func Encode

func Encode(m core.Move) string

Encode encodes a move as a PCN string.

Example
moves := []core.Move{
	// Double pawn push.
	{From: core.B2, To: core.B4},
	// Queen promotion.
	{From: core.F2, To: core.F1, Promotion: core.Queen},
	// White short castle.
	{From: core.E1, To: core.G1},
}
for _, m := range moves {
	fmt.Println(Encode(m))
}
Output:

b2b4
f2f1q
e1g1

func MustDecode

func MustDecode(s string) core.Move

MustDecode is like Decode but panics if the PCN is invalid.

Types

This section is empty.

Jump to

Keyboard shortcuts

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