1
0
mirror of https://github.com/maaslalani/gambit.git synced 2024-11-24 08:22:12 +02:00
This commit is contained in:
Maas Lalani 2021-12-21 22:33:54 -05:00
parent 4acba83b8b
commit 77948dbbfc
No known key found for this signature in database
GPG Key ID: 5A6ED5CBF1A0A000
4 changed files with 40 additions and 3 deletions

View File

@ -1,9 +1,26 @@
package board
import "github.com/maaslalani/gambit/piece"
import (
"github.com/maaslalani/gambit/piece"
)
type Board struct {
// The board is represented as a 2D array of cells.
// The first index is the row, the second is the column.
grid [8][8]*piece.Piece
grid [8][8]piece.Piece
reversed bool
}
func NewBoard() Board {
grid := [8][8]piece.Piece{
{piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty()},
{piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty()},
{piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty()},
{piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty()},
{piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty()},
{piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty()},
{piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty()},
{piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty(), piece.Empty()},
}
return Board{grid: grid}
}

View File

@ -5,4 +5,5 @@ type Color int
const (
White Color = 0
Black Color = 1
None Color = -1
)

View File

@ -5,6 +5,14 @@ import (
)
type Piece struct {
Color color.Color
Type Type
Color color.Color
}
func Empty() Piece {
return Piece{None, color.None}
}
func (p Piece) String() string {
return Display[p.Type]
}

View File

@ -9,4 +9,15 @@ const (
Rook Type = "R"
Queen Type = "Q"
King Type = "K"
None Type = " "
)
var Display = map[Type]string{
Bishop: "♝",
King: "♚",
Knight: "♞",
Pawn: "♟",
Queen: "♛",
Rook: "♜",
None: " ",
}