예제 #1
0
    public IEnumerator GetValue()
    {
        var          DynamicsGene = new DendriteDynamicsGene(1, 0, 0, null, 0, null, 0, null, null, 0);
        DendriteGene DendriteGene = new DendriteGene(0, 0, DendriteGene.SpreadType.Flat, 0, new Vector2Int(0, 0), new Vector2Int(5, 5), new Vector2Int(1, 1), DynamicsGene);
        TestDendrite Dendrite     = new TestDendrite(0, 0, DendriteGene);
        NeuronGene   NeuronGene   = new NeuronGene(0, 0, 0, null);
        Lobe         lobe         = new Lobe(0, null, new Vector2Int(0, 0), new Vector2Int(5, 5), Enumerable.Range(0, 25).Select(n => new Neuron(n, NeuronGene)).ToList(), false, false);

        lobe.FireNeuron(0);
        Dendrite.SetSourceLobe(lobe);
        Dendrite.MockSTW(1);
        var DendriteValue = Dendrite.GetValue();

        Assert.AreEqual(1, DendriteValue);

        Dendrite.MockSTW(255);
        DendriteValue = Dendrite.GetValue();
        Assert.AreEqual(255, DendriteValue);

        yield return(null);
    }
예제 #2
0
    public IEnumerator LTWZeroToOne()
    {
        var          LTWGainRate  = 16;
        var          DynamicsGene = new DendriteDynamicsGene(LTWGainRate, 0, 0, null, 0, null, 0, null, null, 0);
        DendriteGene DendriteGene = new DendriteGene(0, 0, DendriteGene.SpreadType.Flat, 0, new Vector2Int(0, 0), new Vector2Int(0, 0), new Vector2Int(1, 1), DynamicsGene);
        TestDendrite Dendrite     = new TestDendrite(0, 0, DendriteGene);

        Dendrite.MockSTW(1);
        // Process assumes it is being called in FixedUpdate
        // i.e. 10 times a second
        foreach (var i in Enumerable.Range(0, 5))
        {
            Dendrite.Process(null, false, false);
        }
        Assert.AreEqual(1, Mathf.RoundToInt(Dendrite.LTW));

        yield return(null);
    }