notnil / chess

chess package for go
MIT License
508 stars 126 forks source link

Chess960 support? #102

Open jusahah opened 2 years ago

jusahah commented 2 years ago

First of all, great work with the library!

One issue (or a missing feature) I encountered: it does not handle Chess960 castling correctly.

E.g.

package main

import (
    "fmt"

    "github.com/notnil/chess"
)

func main() {
    fen, _ := chess.FEN("bnqbnrkr/pppppppp/8/8/8/8/PPPPPPPP/BNQBNRKR w KQkq - 0 1")
    game := chess.NewGame(chess.UseNotation(chess.UCINotation{}), fen)

    game.MoveStr("b1a3")
    game.MoveStr("f7f6")
    game.MoveStr("f2f4")
    game.MoveStr("f6f5")
    game.MoveStr("f1f3")
    game.MoveStr("g7g6")
    game.MoveStr("g1g1") // King-side castling

    // print outcome and game PGN
    fmt.Println(game.Position().Board().Draw())
    fmt.Printf("Game completed. %s by %s.\n", game.Outcome(), game.Method())
    fmt.Println(game.String())
}

The PGN does not have the castling move present: 1. b1a3 f7f6 2. f2f4 f6f5 3. f1f3 g7g6 *

Same with the printed board.

Using X-FEN (here bnqbnrkr/pppppppp/8/8/8/8/PPPPPPPP/BNQBNRKR w HFhf - 0 1) to encode the starting position does not help.

Are there any plans to support Chess960?

pokemonchw commented 1 year ago

This framework does not recognize the characters here, which is a bug Just change bnqbnrkr/pppppppp/8/8/8/8/PPPPPPPP/BNQBNRKR w KQkq - 0 1 to bnqbnrkr/pppppppp/8/8/8/8/PPPPPPPP/BNQBNRKR w - 0 1 Hey, man, you have a bad habit. The err here should not be hidden