Esempio n. 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);
    }
Esempio n. 2
0
    public IEnumerator BuildLobe()
    {
        DummyBrain Brain     = new DummyBrain();
        var        Location  = new Vector2Int(1, 2);
        var        Dimension = new Vector2Int(3, 4);
        LobeGene   Gene      = new LobeGene(BrainLobeID.Concept, Location, Dimension, null, null, null, 0, 0);
        var        Lobe      = LobeBuilder.BuildFromGene(Gene, 25, 25);

        Assert.AreEqual(BrainLobeID.Concept, Lobe.LobeID);
        Assert.AreEqual(Location, Lobe.Location);
        Assert.AreEqual(Dimension, Lobe.Dimension);
        Assert.AreEqual(Dimension.x * Dimension.y, Lobe.NumNeurons);

        yield return(null);
    }
Esempio n. 3
0
    public static Brain Build(GameObject go, List <LobeGene> genes)
    {
        Brain Brain = go.AddComponent <Brain>();

        foreach (var LobeGene in genes)
        {
            int NumNeurons0 = 0;
            int NumNeurons1 = 0;
            try
            {
                NumNeurons0 = genes[(int)LobeGene.Dendrite0.SourceLobeIndex].NumNeurons;
                NumNeurons1 = genes[(int)LobeGene.Dendrite1.SourceLobeIndex].NumNeurons;
            }
            catch (Exception e)
            {
                // OK - we have no source lobe - probably from a test
            }
            var Lobe = LobeBuilder.BuildFromGene(LobeGene, NumNeurons0, NumNeurons1);
            Brain.AddLobe(Lobe);
        }
        Brain.SetUpLobes();
        return(Brain);
    }