public (NPuzzle, double) ApplyAction(NPuzzle state, IProblemAction action) { var successor = state.Copy(); successor.Move(action); return(successor, 1d); }
// TODO: return the cost of the action with the new state public void Move(IProblemAction action) { Location newBlankLocation = (Location)action; int newBlankOffset = newBlankLocation.Row * valueBits * this.NCols + newBlankLocation.Col * valueBits; int oldBlankOffset = this.blankRow * valueBits * this.NCols + this.blankCol * valueBits; ulong val = (this.board >> newBlankOffset) & 0xFUL; this.board &= ~(0xFUL << newBlankOffset); this.board |= val << oldBlankOffset; this.blankRow = newBlankLocation.Row; this.blankCol = newBlankLocation.Col; }
public (FindingDirectionsState, double) ApplyAction(FindingDirectionsState state, IProblemAction action) { var nextState = (FindingDirectionsState)action; var distance = map.GetEdgeWeight(state, nextState); return(nextState, distance); }
public T PerformAction <T>(IProblemAction <T> action) { return(action.Execute(this)); }