https://github.com/dev-siri/chess
Attempted rewrite of chess.js to Go.
https://github.com/dev-siri/chess
chess golang
Last synced: 2 months ago
JSON representation
Attempted rewrite of chess.js to Go.
- Host: GitHub
- URL: https://github.com/dev-siri/chess
- Owner: Dev-Siri
- License: mit
- Created: 2024-08-22T14:50:50.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-08-22T15:07:51.000Z (10 months ago)
- Last Synced: 2025-02-14T08:28:07.207Z (4 months ago)
- Topics: chess, golang
- Language: Go
- Homepage:
- Size: 35.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: history.go
- License: LICENSE
Awesome Lists containing this project
README
# Chess
Library for analysing and playing chess games programmatically. Direct translation of [chess.js](https://github.com/jhlywa/chess.js) to Go.
Represents a game with the 0x88 chess board representation.
## Why?
I know there's a library called `notnil/chess` for Go too, but I found one function not available in that package, the `.Moves()` function (That is available in chess.js) to count for mobility for one side.
So I directly translated the Chess.js library to Go. Also provides function for validating FENs and prettier move representation.
## holy hell
En passant still doesn't work properly (look at test "TestPositionsPgn") The captured pawn is still not taken off the board. (Wrong square set to nil & I tried for a while but didn't see a change)
## Usage
- Get the package
```sh
go get github.com/Dev-Siri/chess
```- Start using it ¯\\\_(ツ)\_/¯
```go
package mainimport (
"log"
"fmt""github.com/Dev-Siri/chess"
)func main() {
game, err := chess.NewGame()if err != nil {
log.Fatalf(err)
}game2, err := chess.NewGameFromFen("Or start from a FEN position")
if err != nil {
log.Fatalf(err)
}// Make a move
move, _ := game.Move("e4")// Print position
fmt.Println(move.Pgn())
fmt.Println(move.Fen())
}
```## License
This project is MIT Licensed, see [LICENSE](LICENSE)