Ejemplo n.º 1
0
        private List <MoveSet> FindPossibleMoves(GridCell cell)
        {
            List <MoveSet> moveSets = new List <MoveSet>();

            for (int y = 1; y <= 8; y++)
            {
                for (int x = 1; x <= 8; x++)
                {
                    if (_moveChecker.ValidMove(_grid, cell.Piece.Id, y, x))
                    {
                        _grid.MovePiece(cell.Piece.Id, x, y);
                        var piece = _grid.GetByCoords(x, y).Piece;
                        var king  = _grid.GetKingByColor(piece.Color);
                        if (!_checkChecker.CheckForCheck(_grid, king.Piece.Id, king.XCoord, king.YCoord))
                        {
                            MoveSet move = new MoveSet()
                            {
                                XCoord = x,
                                YCoord = y,
                                Piece  = piece,
                                Score  = 16
                            };
                            moveSets.Add(move);
                        }
                        _grid.RevertHistory();
                    }
                }
            }
            return(moveSets);
        }
Ejemplo n.º 2
0
        private bool CheckForCheck(string currentColorsTurn)
        {
            var king = Grid.GetKingByColor(currentColorsTurn);

            return(_checkChecker.CheckForCheck(Grid, king.Piece.Id, king.XCoord, king.YCoord));
        }