Esempio n. 1
0
 void catchDrop(int id, int simulation, TreeOfDecisions tree, bool found)
 {
     if (found)
     {
         if (tree.Current.positiveOutcomes > 1 || tree.Current.negativeOutcomes > 1)
         {
             Debug.Log("id: " + id + "simulation: " + simulation + "p: " + tree.Current.positiveOutcomes + "n: " + tree.Current.negativeOutcomes);
         }
     }
     foreach (TreeOfDecisions.Node node in tree.Current.Children)
     {
         tree.Current = node;
         if (node.MyType == TreeOfDecisions.Type.Drop)
         {
             if (found)
             {
             }
             catchDrop(id, simulation, tree, true);
         }
         else
         {
             catchDrop(id, simulation, tree, false);
         }
         //showPattern();
     }
 }
Esempio n. 2
0
    // Use this for initialization
    void Start()
    {
        rb   = GetComponent <Rigidbody>();
        nnai = GetComponent <NNAI>();
        //Direction = new Vector3(UnityEngine.Random.Range(-1, 2) * Step, 0.0f, UnityEngine.Random.Range(-1,2) * Step);
        tree     = new TreeOfDecisions(this);
        decision = nnai.GetDecision();
        tree.WalkWith(decision);
        Direction           = nnai.GetDirection();
        deadEndAgentCounter = DeadEndAgentCounterValue;


        //Vector3 j = new Vector3(-0.5f, 0, 0.5f);
        //j = j.normalized;
        //proc(j.x, j.z);
        //j = new Vector3(-0.5f, 0, -0.5f);
        //j = j.normalized;
        //proc(j.x, j.z);
        //j = new Vector3(0.5f, 0, 0.5f);
        //j = j.normalized;
        //proc(j.x, j.z);
        //j = new Vector3(0.5f, 0, -0.5f);
        //j = j.normalized;
        //proc(j.x, j.z);
    }
Esempio n. 3
0
    TreeOfDecisions BuildTree(string input)
    {
        TreeOfDecisions tree = new TreeOfDecisions();

        string trigger = "NEGATIVEOUTCOMES";

        input = input.Remove(0, input.IndexOf(trigger) + trigger.Length + 2);
        //Debug.Log(input);
        string[] ss = input.Split(new char[] { '\n' });
        tree.Root    = new TreeOfDecisions.Node(TreeOfDecisions.Type.Root, 0);
        tree.Current = tree.Root;
        for (int i = 1; i < ss.Length; i++)
        {
            if (String.Compare(ss[i], "") == 0)
            {
                continue;
            }
            //Debug.Log(ss[i]);
            int      id, parent_id, pos, neg;
            string[] words = ss[i].Split(new char[] { ' ' });


            id = Int32.Parse(words[0]);
            //Debug.Log("id "+id);
            parent_id = Int32.Parse(words[1]);
            //Debug.Log(                "parent id " + parent_id);
            pos = Int32.Parse(words[3]);
            //Debug.Log("pos "+pos);
            neg = Int32.Parse(words[4]);
            //Debug.Log("neg "+neg);
            //Debug.Log(GetNodeType(ss[i]));
            TreeOfDecisions.Node node = new TreeOfDecisions.Node(GetNodeType(ss[i]), (ulong)id);
            tree.moveTo(tree.Root);
            TreeOfDecisions.Node parent = tree.Find(parent_id);
            //Debug.Log(parent.id);
            tree.moveTo(parent);
            tree.addNode(node);
            tree.Current.positiveOutcomes = (uint)pos;
            tree.Current.negativeOutcomes = (uint)neg;

            //tree.ShowTree();
        }

        return(tree);
    }