Beispiel #1
0
    public void MakeBrain()
    {
        var OpCodes = new List <OpCode.IOpCode>
        {
            new OpCode.Type0()
        };
        var Type0SVRule = new SVRule(OpCodes);
        var StateSVRule = new SVRule(new List <OpCode.IOpCode>
        {
            new OpCode.State()
        });
        var          Type0NeuronGene         = new NeuronGene(0, 0, 255, Type0SVRule);
        var          StateNeuronGene         = new NeuronGene(0, 0, 255, StateSVRule);
        var          DendriteDynamics        = new DendriteDynamicsGene(0, 0, 0, StateSVRule, 0, null, 0, null, null, 0);
        DendriteGene DendriteGene            = new DendriteGene(0, BrainLobeType.Drive, DendriteGene.SpreadType.Flat, 0, new Vector2Int(1, 1), new Vector2Int(255, 255), new Vector2Int(255, 255), DendriteDynamics);
        DendriteGene DendriteGeneNoDendrites = new DendriteGene(0, BrainLobeType.Perception, DendriteGene.SpreadType.Flat, 0, new Vector2Int(0, 0), new Vector2Int(1, 1), new Vector2Int(1, 1), DendriteDynamics);
        // Destination lobe
        var LobeGene1 = new LobeGene(BrainLobeID.Perception, new Vector2Int(1, 1), new Vector2Int(1, 1), DendriteGene, DendriteGene, Type0NeuronGene, 0, 0);
        // Source lobe
        var LobeGene2 = new LobeGene(BrainLobeID.Drive, new Vector2Int(1, 1), new Vector2Int(1, 1), DendriteGeneNoDendrites, DendriteGeneNoDendrites, StateNeuronGene, 0, 0);

        Brain      = new Brain();
        DestLobe   = LobeBuilder.BuildFromGene(LobeGene1, 1, 1);
        SourceLobe = LobeBuilder.BuildFromGene(LobeGene2, 1, 1);
        Brain.AddLobe(DestLobe);
        Brain.AddLobe(SourceLobe);

        DestLobe.SetUpDendrites(Brain);
    }
Beispiel #2
0
 public NeuronGene(int threshold, int restState, int leakage, SVRule svRule)
 {
     Threshold = threshold;
     RestState = restState;
     Leakage   = leakage;
     SVRule    = svRule;
 }
Beispiel #3
0
    public IEnumerator MixedOperandLengths()
    {
        var SV = new SVRule(new List <IOpCode> {
            new ThirtyTwo(), new Decr(), new Plus(), new Zero()
        });

        Assert.AreEqual(31, SV.Evaluate(new SVDataPacket()));

        yield return(null);
    }
Beispiel #4
0
    public IEnumerator BasicTest()
    {
        var SV = new SVRule(new List <IOpCode> {
            new ThirtyTwo(), new Plus(), new Zero()
        });

        Assert.AreEqual(32, SV.Evaluate(new SVDataPacket()));

        yield return(null);
    }
Beispiel #5
0
    public void CreateNeuron()
    {
        var OpCodes = new List <OpCode.IOpCode>
        {
            new OpCode.State()
        };
        var SVRule     = new SVRule(OpCodes);
        var NeuronGene = new NeuronGene(100, 0, 255, SVRule);

        Neuron = new Neuron(0, NeuronGene);
    }
Beispiel #6
0
 public DendriteDynamicsGene(int lTWGainRate, int stwGainRate, int susceptibilityRelaxRate, SVRule susceptibilitySVRule, int strengthGain, SVRule strengthGainSVRule, int strengthLoss, SVRule strengthLossSVRule, SVRule reinforcementRule, int migrateWhen)
 {
     LTWGainRate             = lTWGainRate;
     STWGainRate             = stwGainRate;
     SusceptibilityRelaxRate = susceptibilityRelaxRate;
     SusceptibilitySVRule    = susceptibilitySVRule;
     StrengthGain            = strengthGain;
     StrengthGainSVRule      = strengthGainSVRule;
     StrengthLoss            = strengthLoss;
     StrengthLossSVRule      = strengthLossSVRule;
     ReinforcementRule       = reinforcementRule;
     MigrateWhen             = migrateWhen;
 }
Beispiel #7
0
    public IEnumerator FailTrue()
    {
        var SV = new SVRule(new List <IOpCode>
        {
            new Output(),
            new True(),
            new Suscept(),
            new MoveTowards(),
            new TwoFiveFive(),
            new SixtyFour()
        });
        var DataPacket = new SVDataPacket
        {
            NeuronOutput   = 0,
            Susceptibility = 1
        };
        var Result = SV.Evaluate(DataPacket);

        Assert.AreEqual(0, Mathf.RoundToInt(Result));

        yield return(null);
    }