예제 #1
0
        private void Validate()
        {
            var validationResult = BoardValidator.Validate(this);

            if (validationResult != BoardExceptionType.None)
            {
                switch (validationResult)
                {
                case BoardExceptionType.Checkmate:
                    GameState = GameState.Checkmate;
                    break;

                case BoardExceptionType.MaterialDraw:
                    GameState = GameState.Drawn;
                    break;

                case BoardExceptionType.Stalemate:
                    GameState = GameState.StaleMate;
                    break;

                default:
                    throw new BoardException(validationResult, $"{Fen} : Invalid board setup.");
                }
            }
        }
예제 #2
0
파일: Sudoku.cs 프로젝트: TaraDelari/Sudoku
        public Result <int[]> Solve(SudokuBoard board)
        {
            Result <int[]> result           = new Result <int[]>();
            Result         validationResult = _boardValidator.Validate(board);

            if (!validationResult.IsSuccess)
            {
                result.Error = validationResult.Error;
                return(result);
            }
            return(_solver.Solve(board));
        }