コード例 #1
0
    public void SetState()
    {
        StateLocation loc = Locations.Find(x => x.state == NewGameState);

        bigfoot.transform.position = loc.transform.position;

        updateObj.ChangeState(NewGameState);

        if (updateObj.CurrentObjective != GameState.FindClothes)
        {
            disguiseManager.PickUpDisguise(DisguiseTypes.Hunter);
        }
        else
        {
            disguiseManager.LoseDisguise();
        }

        if (updateObj.CurrentObjective > GameState.GoToDriverAfterSpeech)
        {
            speechNPC.CanBeInteractedWith = false;
        }
        else
        {
            speechNPC.CanBeInteractedWith = true;
        }
    }
コード例 #2
0
        public int AddOpenNode(TState val, int hash, double g, double h, int parent = kTBDNoNode,
                               StateLocation whichQueue = StateLocation.OpenWaiting)
        {
            // should do lookup here...
            if (_table.ContainsKey(hash))
            {
                throw new InvalidOperationException("Cannot add the same open node twice");
            }
            if (whichQueue == StateLocation.OpenReady)
            {
                _elements.Add(new BDOpenClosedData <TState>(val, g, h, parent,
                                                            _priorityQueues[0].Count, StateLocation.OpenReady));
            }
            else if (whichQueue == StateLocation.OpenWaiting)
            {
                _elements.Add(new BDOpenClosedData <TState>(val, g, h, parent,
                                                            _priorityQueues[1].Count, StateLocation.OpenWaiting));
            }

            if (parent == kTBDNoNode)
            {
                _elements.Last().ParentID = _elements.Count - 1;
            }
            _table[hash] = _elements.Count - 1; // hashing to element list location

            _priorityQueues[(int)whichQueue].Add(_elements.Count - 1);
            HeapifyUp(_priorityQueues[(int)whichQueue].Count - 1, (int)whichQueue);

            return(_elements.Count - 1);
        }
コード例 #3
0
 public StateLocationModel(StateLocation location)
 {
     Building = location.Building;
     Address1 = location.Address_Line_1;
     Address2 = location.Address_Line_2;
     City     = location.City;
     Zipcode  = location.Zipcode.GetValueOrDefault().ToString();
 }
コード例 #4
0
 public BDOpenClosedData(TState theData, double gCost, double hCost, int parent, int openLoc, StateLocation location)
 {
     Data         = theData;
     G            = gCost;
     H            = hCost;
     ParentID     = parent;
     OpenLocation = openLoc;
     Where        = location;
     Reopened     = false;
 }
コード例 #5
0
ファイル: NBS.cs プロジェクト: Treff/NBS
        public double GetNodeBackwardG(TState s)
        {
            StateLocation l = _queue.BackwardQueue.Lookup(_getStateHash(s), out int childID);

            if (l != StateLocation.Unseen)
            {
                return(_queue.BackwardQueue.Lookat(childID).G);
            }
            return(-1);
        }
コード例 #6
0
 public BDOpenClosedData <TState> PeekAt(StateLocation whichQueue)
 {
     if (whichQueue == StateLocation.OpenReady)
     {
         if (OpenReadySize() == 0)
         {
             throw new InvalidOperationException("cannot peek at empty ready queue");
         }
     }
     else if (whichQueue == StateLocation.OpenWaiting)
     {
         if (OpenWaitingSize() == 0)
         {
             throw new InvalidOperationException("cannot peek at empty waiting queue");
         }
     }
     return(_elements[_priorityQueues[(int)whichQueue][0]]);
 }
コード例 #7
0
 public int Peek(StateLocation whichQueue)
 {
     if (whichQueue == StateLocation.OpenReady)
     {
         if (OpenReadySize() == 0)
         {
             throw new InvalidOperationException("cannot peek at empty ready queue");
         }
     }
     else if (whichQueue == StateLocation.OpenWaiting)
     {
         if (OpenWaitingSize() == 0)
         {
             throw new InvalidOperationException("cannot peek at empty waiting queue");
         }
     }
     return(_priorityQueues[(int)whichQueue][0]);
 }
コード例 #8
0
ファイル: NBS.cs プロジェクト: Treff/NBS
        public int GetDoubleExpansions()
        {
            int doubles = 0;

            for (int x = 0; x < _queue.ForwardQueue.Size(); x++)
            {
                int key;
                BDOpenClosedData <TState> data = _queue.ForwardQueue.Lookat(x);
                if (data.Where == StateLocation.Closed)
                {
                    StateLocation loc = _queue.BackwardQueue.Lookup(_getStateHash(data.Data), out key);
                    if (loc == StateLocation.Closed)
                    {
                        doubles++;
                    }
                }
            }
            return(doubles);
        }
コード例 #9
0
 public int GetOpenItem(int which, StateLocation where)
 {
     return(_priorityQueues[(int)where][which]);
 }
コード例 #10
0
ファイル: NBS.cs プロジェクト: Treff/NBS
        private void Expand(int nextID, BDOpenClosed <TState> current,
                            BDOpenClosed <TState> opposite, HCost <TState> heuristic, TState target)
        {
            current.Close();

            //this can happen when we expand a single node instead of a pair
            if (FPUtil.GreaterEq(current.Lookup(nextID).G + current.Lookup(nextID).H, _currentCost))
            {
                return;
            }

            _nodesExpanded++;
            IEnumerable <TState> neighbors = _getSuccessors(current.Lookup(nextID).Data);

            foreach (TState succ in neighbors)
            {
                _nodesTouched++;
                StateLocation loc = current.Lookup(_getStateHash(succ), out int childID);

                // screening
                double edgeCost = _gCost(current.Lookup(nextID).Data, succ);
                if (FPUtil.GreaterEq(current.Lookup(nextID).G + edgeCost, _currentCost))
                {
                    continue;
                }

                switch (loc)
                {
                case StateLocation.Closed:     // ignore
                    break;

                case StateLocation.OpenReady:     // update cost if needed
                case StateLocation.OpenWaiting:
                {
                    if (FPUtil.Less(current.Lookup(nextID).G + edgeCost, current.Lookup(childID).G))
                    {
                        double oldGCost = current.Lookup(childID).G;
                        current.Lookup(childID).ParentID = nextID;
                        current.Lookup(childID).G        = current.Lookup(nextID).G + edgeCost;
                        current.KeyChanged(childID);

                        StateLocation loc2 = opposite.Lookup(_getStateHash(succ), out int reverseLoc);
                        if (loc2 == StateLocation.OpenReady || loc2 == StateLocation.OpenWaiting)
                        {
                            if (FPUtil.Less(current.Lookup(nextID).G + edgeCost + opposite.Lookup(reverseLoc).G, _currentCost))
                            {
                                _currentCost = current.Lookup(nextID).G + edgeCost + opposite.Lookup(reverseLoc).G;
                                _middleNode  = succ;
                            }
                        }
                        else if (loc == StateLocation.Closed)
                        {
                            current.Remove(childID);
                        }
                    }
                }
                break;

                case StateLocation.Unseen:
                {
                    StateLocation locReverse = opposite.Lookup(_getStateHash(succ), out int reverseLoc);
                    if (locReverse != StateLocation.Closed)
                    {
                        double newNodeF = current.Lookup(nextID).G + edgeCost + heuristic(succ, target);
                        if (FPUtil.Less(newNodeF, _currentCost))
                        {
                            if (FPUtil.Less(newNodeF, _queue.GetLowerBound()))
                            {
                                current.AddOpenNode(succ,
                                                    _getStateHash(succ),
                                                    current.Lookup(nextID).G + edgeCost,
                                                    heuristic(succ, target),
                                                    nextID, StateLocation.OpenReady);
                            }
                            else
                            {
                                current.AddOpenNode(succ,
                                                    _getStateHash(succ),
                                                    current.Lookup(nextID).G + edgeCost,
                                                    heuristic(succ, target),
                                                    nextID, StateLocation.OpenWaiting);
                            }

                            if (locReverse == StateLocation.OpenReady || locReverse == StateLocation.OpenWaiting)
                            {
                                if (FPUtil.Less(current.Lookup(nextID).G + edgeCost + opposite.Lookup(reverseLoc).G, _currentCost))
                                {
                                    _currentCost = current.Lookup(nextID).G + edgeCost + opposite.Lookup(reverseLoc).G;
                                    _middleNode  = succ;
                                }
                            }
                        }
                    }
                }
                break;
                }
            }
        }
コード例 #11
0
ファイル: NBS.cs プロジェクト: Treff/NBS
        private void ExtractPathToStart(TState node, List <TState> thePath)
        {
            StateLocation loc = _queue.ForwardQueue.Lookup(_getStateHash(node), out int theID);

            ExtractPathToStartFromID(theID, thePath);
        }