✨ Basic implementation of bitboard, board and move
This commit is contained in:
parent
07adc3474a
commit
c21a117a23
7 changed files with 988 additions and 0 deletions
38
pkg/game/game.go
Normal file
38
pkg/game/game.go
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
package game
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"code.c-base.org/gochess/libchess/pkg/board"
|
||||
"code.c-base.org/gochess/libchess/pkg/fen"
|
||||
)
|
||||
|
||||
// Tag serves as data-container for game tags.
|
||||
type Tag struct {
|
||||
Key string
|
||||
Value string
|
||||
}
|
||||
|
||||
// Game represents a game of chess.
|
||||
type Game struct {
|
||||
Tags []Tag
|
||||
Board *board.Board
|
||||
Moves []*board.Move
|
||||
}
|
||||
|
||||
// NewGame returns an initialized game.
|
||||
func NewGame() *Game {
|
||||
b, err := fen.Import(fen.DefaultSetup)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return &Game{
|
||||
Tags: []Tag{},
|
||||
Board: b,
|
||||
Moves: []*board.Move{},
|
||||
}
|
||||
}
|
||||
|
||||
func (g Game) String() string {
|
||||
return fmt.Sprintf("<Game(Tags: %q, Moves: %q)>", g.Tags, g.Moves)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue