AIMA.Core.Environment.EightPuzzle.EightPuzzleBoard.canMoveGap C# (CSharp) Method

canMoveGap() public method

public canMoveGap ( System.Action where ) : bool
where System.Action
return bool
	public bool canMoveGap(Action where) {
		bool retVal = true;
		int absPos = getPositionOf(0);
		if (where.Equals(LEFT))
			retVal = (getYCoord(absPos) != 0);
		else if (where.Equals(RIGHT))
			retVal = (getYCoord(absPos) != 2);
		else if (where.Equals(UP))
			retVal = (getXCoord(absPos) != 0);
		else if (where.Equals(DOWN))
			retVal = (getXCoord(absPos) != 2);
		return retVal;
	}

Usage Example

            public HashSet <Action> actions(Object state)
            {
                EightPuzzleBoard board = (EightPuzzleBoard)state;

                HashSet <Action> actions = new LinkedHashSet <Action>();

                if (board.canMoveGap(EightPuzzleBoard.UP))
                {
                    actions.Add(EightPuzzleBoard.UP);
                }
                if (board.canMoveGap(EightPuzzleBoard.DOWN))
                {
                    actions.Add(EightPuzzleBoard.DOWN);
                }
                if (board.canMoveGap(EightPuzzleBoard.LEFT))
                {
                    actions.Add(EightPuzzleBoard.LEFT);
                }
                if (board.canMoveGap(EightPuzzleBoard.RIGHT))
                {
                    actions.Add(EightPuzzleBoard.RIGHT);
                }

                return(actions);
            }
All Usage Examples Of AIMA.Core.Environment.EightPuzzle.EightPuzzleBoard::canMoveGap