Esempio n. 1
0
 public NextNNLink(NextNNNode nodeFrom0, NextNNNode nodeTo0, NextNNGlobal global0)
 {
     nodeFrom = nodeFrom0;
     nodeTo   = nodeTo0;
     global   = global0;
     CreateLink();
 }
Esempio n. 2
0
 public NextNNLink DoesLinkAlreadyExist(NextNNNode node)
 {
     for (int n = 0; n < global.linksAll.Count; n++)
     {
         NextNNLink link = global.linksAll[n];
         if (link.nodeFrom == node && link.nodeTo == this)
         {
             return(link);
         }
         if (link.nodeTo == node && link.nodeFrom == this)
         {
             return(link);
         }
     }
     return(null);
 }
Esempio n. 3
0
 public void CreateNodes()
 {
     parentLinks = new GameObject("parentLinks");
     parentNodes = new GameObject("parentNodes");
     nodes       = new List <NextNNNode>();
     linksAll    = new List <NextNNLink>();
     for (int layer = 0; layer < numLayers; layer++)
     {
         int less = layer;
         for (int x = 0; x < numX - less; x++)
         {
             for (int y = 0; y < numY - less; y++)
             {
                 NextNNNode node = new NextNNNode(layer, x, y, this);
             }
         }
     }
 }
Esempio n. 4
0
    public void FeedForward()
    {
//		Debug.Log("FeedForward...\n");
        if (value > 0)
        {
            float sumLinkScales = GetSumLinkScales();
//			Debug.Log("FeedForward value > 0 links:" + links.Count + "\n");
            for (int n = 0; n < links.Count; n++)
            {
                NextNNLink link     = links[n];
                float      fraction = link.go.transform.localScale.x / sumLinkScales;
                fraction = 1f / links.Count;
                NextNNNode node    = links[n].nodeTo;
                float      portion = fraction * value;
                Debug.Log("portion:" + portion + "\n");
                node.value = portion;
                node.UpdateValueColor();
            }
            value = 0;             //value * .85f;
            UpdateValueColor();
        }
    }
Esempio n. 5
0
    public void UpdateLinks()
    {
        if (go.transform.position != posLast || global.distNear != distNearLast)
        {
            ClearLinks();
            ClearNearNodes();
            nearNodes = new List <NextNNNode>();
            links     = new List <NextNNLink>();
            for (int n = 0; n < global.nodes.Count; n++)
            {
                if (n != index)
                {
                    NextNNNode node = global.nodes[n];
                    float      dist = Vector3.Distance(go.transform.position, node.go.transform.position);
                    if (dist < global.distNear)
                    {
                        nearNodes.Add(node);
                        NextNNLink linkExisting = DoesLinkAlreadyExist(node);
                        if (linkExisting != null)
                        {
                            links.Add(linkExisting);
                        }
                        else
                        {
                            NextNNLink link = new NextNNLink(this, node, global);
                            links.Add(link);
                            global.linksAll.Add(link);
                        }
                    }
                }
            }
        }
        //posLast = go.transform.position;
        //distNearLast = global.distNear;
//		FeedForward();
    }