private void MoveCellAccordingToRules(CellIndices indices) { if (board.CellIsAdjacentToEmpty(indices)) { var moveToPos = board.GetEmptyCellPos(); board.SwapCells(indices, moveToPos); view.NotifyOnCellMoved(indices, moveToPos); } }
public CellIndices GetMove() { var displacement = GetRandomNonDiagonalIndexDisplacement(); var adjacentCell = board.GetEmptyCellPos(); adjacentCell.column += displacement.column; adjacentCell.row += displacement.row; return(EnforceBoardBoundariesByMirroringMove(adjacentCell)); }
private Node[] GetSuccessorStates(Node state) { var generator = new MoveGenerator(state.board); var moves = generator.GetMoves(); var successors = new Node[moves.Length]; for (int i = 0; i < moves.Length; ++i) { var board = new SquareBoard(state.board); board.SwapCells(board.GetEmptyCellPos(), moves[i]); var successorCost = state.Cost() + 1; successors[i] = new Node ( board, successorCost, board.GetManhattanDistFromCompletion() + successorCost, state, moves[i] ); } return(successors); }
private bool IsNotLowerRightCell(CellIndices indices) { return(board.GetEmptyCellPos() != indices); }