コード例 #1
0
    // Start is called before the first frame update
    void Start()
    {
        maximumPos = Camera.main.ScreenToWorldPoint(new Vector2(Screen.width, Screen.height));

        //Create the Network Object
        network = new Network10_4(maximumPos.x / 2, maximumPos.y / 2);

        //Create a bunch of neurons
        Neuron10_4 a = new Neuron10_4(-23, 0);
        Neuron10_4 b = new Neuron10_4(-15, 0);
        Neuron10_4 c = new Neuron10_4(0, 7);
        Neuron10_4 d = new Neuron10_4(0, -7);
        Neuron10_4 e = new Neuron10_4(15, 0);
        Neuron10_4 f = new Neuron10_4(23, 0);

        //Connect them
        network.connect(a, b, 1f);
        network.connect(b, c, Random.Range(0f, 1f));
        network.connect(b, d, Random.Range(0f, 1f));
        network.connect(c, e, Random.Range(0f, 1f));
        network.connect(d, e, Random.Range(0f, 1f));
        network.connect(e, f, 1f);


        //Add them to the network
        network.addNeuron(a);
        network.addNeuron(b);
        network.addNeuron(c);
        network.addNeuron(d);
        network.addNeuron(e);
        network.addNeuron(f);

        //Create the network visualization
        network.display();
    }
コード例 #2
0
    //We can connect the two Neurons
    public void connect(Neuron10_4 a, Neuron10_4 b, float w)
    {
        Connection10_4 c = new Connection10_4(a, b, w);

        a.addConnection(c);
        //Also add the connection
        connections.Add(c);
    }
コード例 #3
0
    public Connection10_4(Neuron10_4 from, Neuron10_4 to, float w)
    {
        weight = w;
        a      = from;
        b      = to;

        //Create the cognate Game Object that will signify thinking
        cognateGO = GameObject.CreatePrimitive(PrimitiveType.Sphere);
        Renderer r = cognateGO.GetComponent <Renderer>();

        r.material                   = new Material(Shader.Find("Diffuse"));
        r.material.color             = Color.red;
        cognateGO.transform.position = from.position;
    }
コード例 #4
0
    public void feedforward(float input)
    {
        Neuron10_4 start = neurons[0];

        start.feedforward(input);
    }
コード例 #5
0
 //We can add a Neuron
 public void addNeuron(Neuron10_4 n)
 {
     neurons.Add(n);
 }