diff --git a/board/board.go b/board/board.go index 53d56e0..fcb23fe 100644 --- a/board/board.go +++ b/board/board.go @@ -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} } diff --git a/color/color.go b/color/color.go index dfce836..a64eb02 100644 --- a/color/color.go +++ b/color/color.go @@ -5,4 +5,5 @@ type Color int const ( White Color = 0 Black Color = 1 + None Color = -1 ) diff --git a/piece/piece.go b/piece/piece.go index aad736b..655bed6 100644 --- a/piece/piece.go +++ b/piece/piece.go @@ -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] } diff --git a/piece/type.go b/piece/type.go index af0a64b..a18417c 100644 --- a/piece/type.go +++ b/piece/type.go @@ -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: " ", +}