public override bool Equals(object o) { if (this == o) { return(true); } if (o != null && GetType() == o.GetType()) { EightPuzzleBoard aBoard = (EightPuzzleBoard)o; for (int i = 0; i < 8; i++) { if (this.getPositionOf(i) != aBoard.getPositionOf(i)) { return(false); } } return(true); } return(false); }
public static EightPuzzleBoard getResult(EightPuzzleBoard state, IAction action) { EightPuzzleBoard result = new EightPuzzleBoard(state); if (EightPuzzleBoard.UP.Equals(action) && state.canMoveGap(EightPuzzleBoard.UP)) { result.moveGapUp(); } else if (EightPuzzleBoard.DOWN.Equals(action) && state.canMoveGap(EightPuzzleBoard.DOWN)) { result.moveGapDown(); } else if (EightPuzzleBoard.LEFT.Equals(action) && state.canMoveGap(EightPuzzleBoard.LEFT)) { result.moveGapLeft(); } else if (EightPuzzleBoard.RIGHT.Equals(action) && state.canMoveGap(EightPuzzleBoard.RIGHT)) { result.moveGapRight(); } return(result); }
public static ICollection <IAction> getActions(EightPuzzleBoard state) { ICollection <IAction> actions = CollectionFactory.CreateQueue <IAction>(); if (state.canMoveGap(EightPuzzleBoard.UP)) { actions.Add(EightPuzzleBoard.UP); } if (state.canMoveGap(EightPuzzleBoard.DOWN)) { actions.Add(EightPuzzleBoard.DOWN); } if (state.canMoveGap(EightPuzzleBoard.LEFT)) { actions.Add(EightPuzzleBoard.LEFT); } if (state.canMoveGap(EightPuzzleBoard.RIGHT)) { actions.Add(EightPuzzleBoard.RIGHT); } return(actions); }
public EightPuzzleBoard(EightPuzzleBoard copyBoard) : this(copyBoard.getState()) { }