Пример #1
0
        public (NPuzzle, double) ApplyAction(NPuzzle state, IProblemAction action)
        {
            var successor = state.Copy();

            successor.Move(action);
            return(successor, 1d);
        }
Пример #2
0
        // 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;
        }
Пример #3
0
        public (FindingDirectionsState, double) ApplyAction(FindingDirectionsState state, IProblemAction action)
        {
            var nextState = (FindingDirectionsState)action;
            var distance  = map.GetEdgeWeight(state, nextState);

            return(nextState, distance);
        }
Пример #4
0
 public T PerformAction <T>(IProblemAction <T> action)
 {
     return(action.Execute(this));
 }