go-chess-models, v1.6
Posted on

The library that implements checking and generating of chess moves.
Working with Forsyth–Edwards Notation for positions and moves, extending moves checkings and refactoring.
Change Log
- Forsyth–Edwards Notation:
- parsing:
- of a position;
- of a move;
- serialization:
- of a position;
- of a move;
- parsing:
- extending universal moves checkings;
- refactoring.
Features
- representing the board as an associative array of pieces with their positions as keys;
- immutable applicating moves to the board via copying the latter;
- checkings of moves:
- universal;
- individual for all types of pieces;
- generating moves via filtering from all possible ones;
- using an abstraction of a piece;
- Forsyth–Edwards Notation:
- parsing:
- of a position;
- of a move;
- of a piece kind;
- of a piece color;
- of a board;
- serialization:
- of a position;
- of a move;
- of a piece kind;
- of a piece color;
- of a board.
- parsing:
Examples
uci.DecodePosition():
package main
import (
"fmt"
"github.com/thewizardplusplus/go-chess-models/encoding/uci"
)
func main() {
position, _ := uci.DecodePosition("c3")
fmt.Printf("%+v\n", position)
// Output: {File:2 Rank:2}
}
uci.EncodePosition():
package main
import (
"fmt"
models "github.com/thewizardplusplus/go-chess-models"
"github.com/thewizardplusplus/go-chess-models/encoding/uci"
)
func main() {
position := uci.EncodePosition(models.Position{File: 2, Rank: 2})
fmt.Printf("%v\n", position)
// Output: c3
}
uci.DecodeMove():
package main
import (
"fmt"
"github.com/thewizardplusplus/go-chess-models/encoding/uci"
)
func main() {
move, _ := uci.DecodeMove("d4c3")
fmt.Printf("%+v\n", move)
// Output: {Start:{File:3 Rank:3} Finish:{File:2 Rank:2}}
}
uci.EncodeMove():
package main
import (
"fmt"
models "github.com/thewizardplusplus/go-chess-models"
"github.com/thewizardplusplus/go-chess-models/encoding/uci"
)
func main() {
move := uci.EncodeMove(models.Move{
Start: models.Position{File: 3, Rank: 3},
Finish: models.Position{File: 2, Rank: 2},
})
fmt.Printf("%v\n", move)
// Output: d4c3
}
Repository
Link: https://github.com/thewizardplusplus/go-chess-models/tree/v1.6.
Content: code.
License: MIT.