Exemplo n.º 1
0
    //what the hell am I doing here.. f*****g wasting time

    public Node <Carpet> GetNextNodeToRollOut()
    {
        Carpet.RefNode lowestNodeThatNotROlledOut = null;

        int minOrder = int.MaxValue;

        SolutionTree.TraverseWithTermination((sNode) =>
        {
            if (sNode.obj.parentCount == 0)
            {
                return(false);
            }

            bool inCurrentTree = false;

            var refNode = sNode.obj;

            CurrentTree.TraverseWithTermination((cNode) =>
            {
                var carpet = cNode.obj;

                if (carpet.parents.Count == 0)
                {
                    return(false);
                }

                //find the node of the same order
                if (carpet.carpetSO.Order == refNode.carpetSO.Order &&
                    carpet.parents.Count == refNode.parentCount)
                {
                    inCurrentTree = true;

                    return(true);
                }

                return(false);
            });

            if (!inCurrentTree)
            {
                if (refNode.carpetSO.Order < minOrder)
                {
                    minOrder = refNode.carpetSO.Order;

                    lowestNodeThatNotROlledOut = refNode;
                }
            }
            return(false);
        });

        if (lowestNodeThatNotROlledOut != null)
        {
            return(lowestNodeThatNotROlledOut.correctCarpet);
        }
        else
        {
            return(null);
        }
    }
 public bool RequestStopTree()
 {
     if (CurrentTree != null)
     {
         return(CurrentTree.RequestStopNode());
     }
     return(false);
 }
 /// <summary>
 /// Common logic for all MonoBehaviour Update functions
 /// </summary>
 /// <param name="updateType"></param>
 private void UpdateCommon(BehaviourNode.UpdateType updateType)
 {
     if (Paused)
     {
         return;
     }
     // BehaviourNode.UpdateTime(Time.deltaTime);
     BehaviourNode.OverrideElapsedTime(Time.time);
     CurrentTree?.UpdateRecursively(updateType);
 }
Exemplo n.º 4
0
        internal async Task Jump()
        {
            while (edgeReached == false)
            {
                await TxtLog.WriteText($"forestLog{forest.ID}.txt", $"{Name} is looking for closest tree");

                Tree closestTree = forest.GetClosestTree(CurrentTree, VisitedTrees);
                await TxtLog.WriteText($"forestLog{forest.ID}.txt", $"{Name} finds closest tree at x{closestTree.X} y{closestTree.Y}");

                double distance           = CurrentTree.GetDistanceTo(closestTree);
                double forestEdgeDistance = (new List <double>()
                {
                    forest.Width - CurrentTree.X,
                    forest.Height - CurrentTree.Y,
                    CurrentTree.X,
                    CurrentTree.Y
                }).Min() * 2;

                if (distance < forestEdgeDistance)
                {
                    string Logstring = $"{Name} jumps from tree ({CurrentTree.ID}) X: {CurrentTree.X} Y: {CurrentTree.Y} " +
                                       $"to tree ({closestTree.ID}) X: {closestTree.X} Y: {closestTree.Y}";

                    Console.WriteLine(Logstring);

                    await TxtLog.WriteText($"forestLog{forest.ID}.txt", Logstring);

                    await forest.ImageGenerator.drawJump(color, CurrentTree.X, CurrentTree.Y, closestTree.X, closestTree.Y);

                    await DbInsertion.AddDbLog(ID, forest.ID, Logstring);

                    await DbInsertion.AddMonkeyRecord(ID, forest.ID, VisitedTrees.Count(), closestTree.ID, closestTree.X, closestTree.Y);

                    await DbInsertion.AddWoodRecord(forest.ID, closestTree.ID, closestTree.X, closestTree.Y);

                    VisitedTrees.Add(CurrentTree);
                    CurrentTree = closestTree;
                }
                else
                {
                    string Logstring = "End reached by monkey " + Name;
                    Console.WriteLine(Logstring);
                    await TxtLog.WriteText($"forestLog{forest.ID}.txt", Logstring);

                    edgeReached = true;
                }
            }
        }
Exemplo n.º 5
0
        void stopWindow_runEvent(object sender, EventArgs e)
        {
            MainWindow.SequenceIsRunning = -1;
            m_TcpMain.stop();
            chart.Complete();
            CurrentTree.Abort();
            CurrentTree.Render();
            runButton.Visibility   = Visibility.Visible;
            stopButton.Visibility  = System.Windows.Visibility.Collapsed;
            pauseButton.Visibility = System.Windows.Visibility.Collapsed;

            pauseButton.Content = "暂停任务";
            foreach (var item in sts)
            {
                item.CanOrderBy = true;
            }
        }
Exemplo n.º 6
0
        TreeIter FindOrAddPObject(TreeIter iter, string id, PObject item, Dictionary <PObject, PListScheme.SchemaItem> tree)
        {
            TreeIter subIter;

            if (CurrentTree.ContainsKey(item))
            {
                if (iter.Equals(TreeIter.Zero) ? treeStore.IterChildren(out subIter) : treeStore.IterChildren(out subIter, iter))
                {
                    do
                    {
                        if (treeStore.GetValue(subIter, 1) == item)
                        {
                            // If we have modified the value of an existing PObject, such
                            // as changing the value of a PNumber from '1' to '2', we will
                            // need to refresh the value in the treestore.
                            treeStore.SetValue(subIter, 0, id);
                            break;
                        }
                    } while (treeStore.IterNext(ref subIter));
                }
            }
            else
            {
                subIter = treeStore.InsertNodeBefore(FindOrAddNewEntry(iter));
                treeStore.SetValues(subIter, id, item, tree [item]);
                if (CurrentTree.Count > 0)
                {
                    treeview.ExpandToPath(treeStore.GetPath(subIter));
                    this.treeview.Selection.SelectIter(subIter);
                }

                if (item is PArray || item is PDictionary)
                {
                    var newEntryIter = FindOrAddNewEntry(subIter);
                    if (CurrentTree.Count > 0)
                    {
                        treeview.ExpandToPath(treeStore.GetPath(newEntryIter));
                    }
                }
            }

            return(subIter);
        }
        private void BehaviourtreeOnStopped_Listener(bool success)
        {
            if (NextTree != null)
            {
                CurrentTree = NextTree;
                NextTree    = null;
            }

            if (StartingTree)
            {
                StartingTree = false;
                CurrentTree.StartNode(false);
            }
            else if (StartingTreeSilent)
            {
                StartingTreeSilent = false;
                CurrentTree.StartNode(true);
            }
        }
Exemplo n.º 8
0
 public void Stop()
 {
     m_TcpMain.stop();
     CurrentTree.Abort();
     pauseButton.Content = "暂停任务";
 }
Exemplo n.º 9
0
 public void DeletePerson(Person person)
 {
     CurrentTree.DeletePerson(person);
     new TreeDB().DeletePerson(person.ID, _builder);
 }
 /// <summary>
 /// Used for when the Behaviour Tree is mimicking another tree (ex: network peer)
 /// </summary>
 public bool SyncActiveLeaves(string nodeIDs, char seperator = '|', bool silent = true)
 {
     return(CurrentTree.SyncActiveLeaves(nodeIDs, seperator, silent));
 }
 /// <summary>
 /// Used for when the Behaviour Tree is mimicking another tree (ex: network peer)
 /// </summary>
 public bool SyncActiveLeaves(string[] nodeIDs, bool silent = true)
 {
     return(CurrentTree.SyncActiveLeaves(nodeIDs, silent));;
 }
 /// <summary>
 /// Used for when the Behaviour Tree is mimicking another tree (ex: network peer)
 /// </summary>
 public bool SyncActiveLeaves(BehaviourNode[] activeLeaves, bool silent = true)
 {
     return(CurrentTree.SyncActiveLeaves(activeLeaves, silent));
 }