Exemplo n.º 1
0
        private string ValidateKings(string error)
        {
            Span <Player> players = stackalloc Player[] { Player.White, Player.Black };

            foreach (var player in players)
            {
                var count = _board.PieceCount(PieceTypes.King, player);
                if (count != 1)
                {
                    error = AddError(error, $"king count for player {player} was {count}");
                }
            }

            if (!(_pos.AttacksTo(_pos.GetKingSquare(~_pos.SideToMove)) & _board.Pieces(_pos.SideToMove)).IsEmpty)
            {
                error = AddError(error, "kings appear to attack each other");
            }

            return(error);
        }