コード例 #1
0
ファイル: NPuzzle.cs プロジェクト: hugodahl/fast
        public (NPuzzle, double) ApplyAction(NPuzzle state, IProblemAction action)
        {
            var successor = state.Copy();

            successor.Move(action);
            return(successor, 1d);
        }
コード例 #2
0
ファイル: NPuzzle.cs プロジェクト: hugodahl/fast
        // 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
ファイル: FindingDirections.cs プロジェクト: hugodahl/fast
        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));
 }