From d14bbfbb41879173726dbdc574ba84d1763133c0 Mon Sep 17 00:00:00 2001 From: Jeremy Hertel Date: Sun, 26 Nov 2023 11:54:20 -0600 Subject: [PATCH] chess: add null move constant --- internal/chess/move.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/chess/move.go b/internal/chess/move.go index 576235c..f095302 100644 --- a/internal/chess/move.go +++ b/internal/chess/move.go @@ -11,6 +11,7 @@ const ( NormalMove MoveType = iota CastleMove EnPassantMove + Null ) func (t MoveType) String() string { @@ -21,6 +22,8 @@ func (t MoveType) String() string { return "Castle" case EnPassantMove: return "En Passant" + case Null: + return "Null" } return "" @@ -47,6 +50,8 @@ type Move struct { capturePiece Piece } +var NullMove = NewMove(A1, A1, Null, NoMoveFlag) + // NewMove creates a new move with the given from and to. func NewMove(from, to Square, moveType MoveType, flags MoveFlag) Move { return Move{ @@ -121,6 +126,10 @@ func (m Move) IsIrreversible() bool { } func (m Move) String() string { + if m.Type() == Null { + return "0000" + } + str := m.From.ToAlgebraic() + m.To.ToAlgebraic() if m.promotionPiece != EmptyPiece {