mirror of
https://github.com/maaslalani/gambit.git
synced 2024-11-24 08:22:12 +02:00
progress
This commit is contained in:
parent
4acba83b8b
commit
77948dbbfc
@ -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}
|
||||
}
|
||||
|
@ -5,4 +5,5 @@ type Color int
|
||||
const (
|
||||
White Color = 0
|
||||
Black Color = 1
|
||||
None Color = -1
|
||||
)
|
||||
|
@ -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]
|
||||
}
|
||||
|
@ -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: " ",
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user