- Go 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
The gRPC package did not compile. Two of the three errors were mine to
fix here:
- BoardSquare literals used Rank/File, which are unexported. The
constructor NewBoardSquare already existed and was simply not used.
- string(piece.Role()) and string(piece.Color()) on int-backed enums
produce a single rune, not a name, so GetBoard would have returned
"\x03" instead of "knight". RoleString and ColorString already
existed for exactly this.
The third was dead scaffolding: a naive inline square parser, declared and
never used, with comments conceding it needed replacing. Removed.
go build, go vet, and go test are all clean now. The engine package's 143
tests passed before and still do; the gRPC package now compiles and joins
them.
README covers the parts that are actually non-obvious: pins and skewers,
where a move generator that checks path clearance without checking king
safety produces illegal moves that pass casual testing.
|
||
| chessgo | ||
| chessgrpc | ||
| tui | ||
| AGENTS.md | ||
| ChessGo | ||
| go.mod | ||
| go.sum | ||
| main.go | ||
| README.md | ||
ChessGo
A chess rules engine and gRPC service in Go.
The engine implements legal move generation and terminal-state detection — check, checkmate, stalemate — and the gRPC layer exposes a board and move API over a protobuf service. The terminal TUI drives it locally.
Why this exists
Mostly to get properly into the parts of Go I care about: value semantics on a
board type, exhaustive test coverage of rules that are easy to get subtly
wrong, and a real protocol boundary rather than a main that prints to stdout.
The rules engine is the part worth reading. Chess has a lot of cases where the obvious implementation is wrong:
- Pins. A pinned piece may be able to reach a square and still not be allowed to move there, because moving exposes the king. A generator that checks "does the path clear" without checking "does the king survive" produces illegal moves that pass most casual testing.
- Skewers. The mirror case: a piece is currently pinned but would be captured the moment it moved.
- En passant, which is only legal on the immediately following move, so it depends on state that is not in the current position.
Layout
chessgo/ the engine: board, pieces, rules, game state
Pieces.go piece roles, colours, movement primitives
BoardState.go board storage, square lookup, promotion
RulesEngine.go move legality, check, pin/skewer detection, terminal states
GameState.go turn order, move history, and the rules around a move
*_test.go tests, one file per unit
chessgrpc/ protobuf definitions and the gRPC service
tui/ terminal front end
Status
Builds clean, go vet clean, and the engine package's tests pass.
go build ./...
go test ./...
go vet ./...
The gRPC layer is the thinner of the two: the protocol is defined in
chessgrpc/chess.proto and the service implements GetBoard and MakeMove,
but it has no tests of its own yet. The engine carries the coverage.
Notes
Board squares are stored with unexported fields and reached through
NewBoardSquare and the accessors in Accessors.go, so construction and
inspection stay on one path.
PieceRole and Color are int-backed enums. They expose RoleString() and
ColorString(); converting them directly to string yields a rune, not a name.