public System.Object result(System.Object s, Action a)
            {
                EightPuzzleBoard board = (EightPuzzleBoard)s;

                if (EightPuzzleBoard.UP.Equals(a) &&
                    board.canMoveGap(EightPuzzleBoard.UP))
                {
                    EightPuzzleBoard newBoard = new EightPuzzleBoard(board);
                    newBoard.moveGapUp();
                    return(newBoard);
                }
                else if (EightPuzzleBoard.DOWN.Equals(a) &&
                         board.canMoveGap(EightPuzzleBoard.DOWN))
                {
                    EightPuzzleBoard newBoard = new EightPuzzleBoard(board);
                    newBoard.moveGapDown();
                    return(newBoard);
                }
                else if (EightPuzzleBoard.LEFT.Equals(a) &&
                         board.canMoveGap(EightPuzzleBoard.LEFT))
                {
                    EightPuzzleBoard newBoard = new EightPuzzleBoard(board);
                    newBoard.moveGapLeft();
                    return(newBoard);
                }
                else if (EightPuzzleBoard.RIGHT.Equals(a) &&
                         board.canMoveGap(EightPuzzleBoard.RIGHT))
                {
                    EightPuzzleBoard newBoard = new EightPuzzleBoard(board);
                    newBoard.moveGapRight();
                    return(newBoard);
                }

                // The Action is not understood or is a NoOp
                // the result will be the current state.
                return(s);
            }
            public System.Object result(System.Object s, Action a)
            {
                EightPuzzleBoard board = (EightPuzzleBoard) s;

                if (EightPuzzleBoard.UP.Equals(a)
                && board.canMoveGap(EightPuzzleBoard.UP))
                {
                EightPuzzleBoard newBoard = new EightPuzzleBoard(board);
                newBoard.moveGapUp();
                return newBoard;
                }
                else if (EightPuzzleBoard.DOWN.Equals(a)
                  && board.canMoveGap(EightPuzzleBoard.DOWN))
                {
                EightPuzzleBoard newBoard = new EightPuzzleBoard(board);
                newBoard.moveGapDown();
                return newBoard;
                }
                else if (EightPuzzleBoard.LEFT.Equals(a)
                  && board.canMoveGap(EightPuzzleBoard.LEFT))
                {
                EightPuzzleBoard newBoard = new EightPuzzleBoard(board);
                newBoard.moveGapLeft();
                return newBoard;
                }
                else if (EightPuzzleBoard.RIGHT.Equals(a)
                  && board.canMoveGap(EightPuzzleBoard.RIGHT))
                {
                EightPuzzleBoard newBoard = new EightPuzzleBoard(board);
                newBoard.moveGapRight();
                return newBoard;
                }

                // The Action is not understood or is a NoOp
                // the result will be the current state.
                return s;
            }