Пример #1
0
    void setUpForModuleRunning(ModulePacket oldModule, ModulePacket newModule)
    {
        if (oldModule.mainScript != null)
        {
            foreach (Rule rule in oldModule.rules)
            {
                Destroy(rule.detector);
            }

            Destroy(oldModule.mainScript);
        }

        moduleRunning = newModule;
        for (int i = 0; i < moduleRunning.rules.Length; i++)
        {
            moduleRunning.rules[i].detector = gameObject.AddComponent(Type.GetType(moduleRunning.rules[i].detectModuleType)) as AIDetectModule;
            foreach (InputVar inputVar in moduleRunning.rules[i].vars)
            {
                moduleRunning.rules[i].detector.vars.Add(inputVar.name, Convert.ChangeType(inputVar.var, Type.GetType(inputVar.varType)));
            }
        }
        moduleRunning.mainScript = gameObject.AddComponent(Type.GetType(moduleRunning.moduleType)) as AIModule;
        foreach (InputVar inputVar in moduleRunning.vars)
        {
            moduleRunning.mainScript.vars.Add(inputVar.name, Convert.ChangeType(inputVar.var, Type.GetType(inputVar.varType)));
        }
    }
Пример #2
0
 public GLWindowProvider(ModulePacket packet) :
     base(GameWindowSettings.Default, new NativeWindowSettings()
 {
     Size = new OpenTK.Mathematics.Vector2i(1600, 900), APIVersion = new Version(4, 6)
 })
 {
     _packet      = packet;
     _taskManager = packet.CreateScoped <ITaskManager>();
     FrameQueue   = new Queue <Action>();
 }
Пример #3
0
        public BindingsManager(ModulePacket packet)
        {
            _configurationManager = packet.GetSingleton <IConfigurationManager>();

            if (_configurationManager.Contains <InputBindingsConfiguration>())
            {
                _bindingsDictionary = _configurationManager.Get <InputBindingsConfiguration>().Bindings;
            }
            else
            {
                _bindingsDictionary = new Dictionary <string, List <Binding> >
                {
                    { "default", Default.ToList() }
                };
            }
        }
Пример #4
0
        public TaskManager(ModulePacket packet)
        {
            _packet = packet;
            _tasks  = _packet.GetInstances().OfType <ITask>();

            // excuse this shit

            _startupTasks    = _tasks.Where((x) => x.Schedule == TaskSchedule.Startup).OrderBy(task => task.Priority).ToArray();
            _backgroundTasks = _tasks.Where((x) => x.Schedule == TaskSchedule.Background).OrderBy(task => task.Priority).ToArray();

            _windowRenderTasks    = _tasks.Where((x) => x.Schedule == TaskSchedule.WindowRender).OrderBy(task => task.Priority).ToArray();
            _windowUpdateTasks    = _tasks.Where((x) => x.Schedule == TaskSchedule.WindowUpdate).OrderBy(task => task.Priority).ToArray();
            _windowResizeTasks    = _tasks.Where((x) => x.Schedule == TaskSchedule.WindowResize).OrderBy(task => task.Priority).ToArray();
            _windowEnterTextTasks = _tasks.Where((x) => x.Schedule == TaskSchedule.WindowEnterText).OrderBy(task => task.Priority).ToArray();
            _windowScrollTasks    = _tasks.Where((x) => x.Schedule == TaskSchedule.WindowMouseScroll).OrderBy(task => task.Priority).ToArray();
            _windowDisposingTasks = _tasks.Where((x) => x.Schedule == TaskSchedule.WindowDisposing).OrderBy(task => task.Priority).ToArray();

            _windowReadyTasks = _tasks.Where((x) => x.Schedule == TaskSchedule.WindowReady).OrderBy(task => task.Priority).ToArray();
        }
Пример #5
0
 public Parser(ModulePacket packet)
 {
     _commands = packet.GetInstances().OfType <ICommand>().ToList();
 }
Пример #6
0
 public SDKTask(ModulePacket packet)
 {
     _packet = packet;
 }
Пример #7
0
        static public ModularNetwork DecodeToModularNetwork(NeatGenome.NeatGenome g)
        {
            int inputCount  = g.InputNeuronCount;
            int outputCount = g.OutputNeuronCount;
            int neuronCount = g.NeuronGeneList.Count;

            IActivationFunction[] activationFunctions = new IActivationFunction[neuronCount];
            float[] biasList = new float[neuronCount];

            Dictionary <long, int> neuronLookup = new Dictionary <long, int>(neuronCount);

            // Create an array of the activation functions for each non-module node node in the genome.
            // Start with a bias node if there is one in the genome.
            // The genome's neuron list is assumed to be ordered by type, with the bias node appearing first.
            int neuronGeneIndex = 0;

            for (; neuronGeneIndex < neuronCount; neuronGeneIndex++)
            {
                if (g.NeuronGeneList[neuronGeneIndex].NeuronType != NeuronType.Bias)
                {
                    break;
                }
                activationFunctions[neuronGeneIndex] = g.NeuronGeneList[neuronGeneIndex].ActivationFunction;
                neuronLookup.Add(g.NeuronGeneList[neuronGeneIndex].InnovationId, neuronGeneIndex);
            }
            int biasCount = neuronGeneIndex;

            for (; neuronGeneIndex < neuronCount; neuronGeneIndex++)
            {
                activationFunctions[neuronGeneIndex] = g.NeuronGeneList[neuronGeneIndex].ActivationFunction;
                neuronLookup.Add(g.NeuronGeneList[neuronGeneIndex].InnovationId, neuronGeneIndex);
                biasList[neuronGeneIndex] = g.NeuronGeneList[neuronGeneIndex].Bias;
            }

            // Create an array of the activation functions, inputs, and outputs for each module in the genome.
            ModulePacket[] modules = new ModulePacket[g.ModuleGeneList.Count];
            for (int i = g.ModuleGeneList.Count - 1; i >= 0; i--)
            {
                modules[i].function = g.ModuleGeneList[i].Function;
                // Must translate input and output IDs to array locations.
                modules[i].inputLocations = new int[g.ModuleGeneList[i].InputIds.Count];
                for (int j = g.ModuleGeneList[i].InputIds.Count - 1; j >= 0; j--)
                {
                    modules[i].inputLocations[j] = neuronLookup[g.ModuleGeneList[i].InputIds[j]];
                }
                modules[i].outputLocations = new int[g.ModuleGeneList[i].OutputIds.Count];
                for (int j = g.ModuleGeneList[i].OutputIds.Count - 1; j >= 0; j--)
                {
                    modules[i].outputLocations[j] = neuronLookup[g.ModuleGeneList[i].OutputIds[j]];
                }
            }

            // ConnectionGenes point to a neuron's innovation ID. Translate this ID to the neuron's index in the neuron array.
            FloatFastConnection[] connections = new FloatFastConnection[g.ConnectionGeneList.Count];
            for (int connectionGeneIndex = g.ConnectionGeneList.Count - 1; connectionGeneIndex >= 0; connectionGeneIndex--)
            {
                ConnectionGene connectionGene = g.ConnectionGeneList[connectionGeneIndex];
                connections[connectionGeneIndex].sourceNeuronIdx = neuronLookup[connectionGene.SourceNeuronId];
                connections[connectionGeneIndex].targetNeuronIdx = neuronLookup[connectionGene.TargetNeuronId];
                connections[connectionGeneIndex].weight          = (float)connectionGene.Weight;

                connections[connectionGeneIndex].learningRate  = connectionGene.learningRate;
                connections[connectionGeneIndex].A             = connectionGene.A;
                connections[connectionGeneIndex].B             = connectionGene.B;
                connections[connectionGeneIndex].C             = connectionGene.C;
                connections[connectionGeneIndex].D             = connectionGene.D;
                connections[connectionGeneIndex].modConnection = connectionGene.modConnection;
            }

            ModularNetwork mn = new ModularNetwork(biasCount, inputCount, outputCount, neuronCount, connections, biasList, activationFunctions, modules);

            if (g.networkAdaptable)
            {
                mn.adaptable = true;
            }
            if (g.networkModulatory)
            {
                mn.modulatory = true;
            }

            mn.genome = g;
            return(mn);
        }
Пример #8
0
 public AssimpImporter(ModulePacket packet)
 {
     _packet = packet;
 }
Пример #9
0
 public MainWindowTask(ModulePacket packet)
 {
     _packet = packet;
 }
Пример #10
0
 public SDKBase(ModulePacket packet)
 {
     _parser = packet.CreateScoped <IParser>();
 }
Пример #11
0
        static public ModularNetwork DecodeToModularNetwork(NeatGenome.NeatGenome g)
        {
            int inputCount  = g.InputNeuronCount;
            int outputCount = g.OutputNeuronCount;
            int neuronCount = g.NeuronGeneList.Count;

            IActivationFunction[] activationFunctions = new IActivationFunction[neuronCount];
            float[] biasList = new float[neuronCount];

            Dictionary <uint, int> neuronLookup = new Dictionary <uint, int>(neuronCount);

            // Schrum: In case there are output neurons out of order
            g.NeuronGeneList.NeuronSortCheck();

            // Create an array of the activation functions for each non-module node node in the genome.
            // Start with a bias node if there is one in the genome.
            // The genome's neuron list is assumed to be ordered by type, with the bias node appearing first.
            int neuronGeneIndex = 0;

            for (; neuronGeneIndex < neuronCount; neuronGeneIndex++)
            {
                if (g.NeuronGeneList[neuronGeneIndex].NeuronType != NeuronType.Bias)
                {
                    break;
                }
                activationFunctions[neuronGeneIndex] = g.NeuronGeneList[neuronGeneIndex].ActivationFunction;
                neuronLookup.Add(g.NeuronGeneList[neuronGeneIndex].InnovationId, neuronGeneIndex);
            }
            int biasCount = neuronGeneIndex;

            // Schrum: debug
            //Console.WriteLine("start (after bias): " + g.GenomeId);

            // Schrum: Debugging
            //NeuronType expectedType = NeuronType.Input;

            for (; neuronGeneIndex < neuronCount; neuronGeneIndex++)
            {
                activationFunctions[neuronGeneIndex] = g.NeuronGeneList[neuronGeneIndex].ActivationFunction;
                // Schrum: Debug

                /*
                 * if (expectedType != g.NeuronGeneList[neuronGeneIndex].NeuronType)
                 * {
                 *  if (expectedType == NeuronType.Input && g.NeuronGeneList[neuronGeneIndex].NeuronType == NeuronType.Output)
                 *  {
                 *      expectedType = NeuronType.Output;
                 *  }
                 *  else if (expectedType == NeuronType.Output && g.NeuronGeneList[neuronGeneIndex].NeuronType == NeuronType.Hidden)
                 *  {
                 *      expectedType = NeuronType.Hidden;
                 *  }
                 *  else
                 *  {
                 *      // Error condition:
                 *      Console.WriteLine("Error with genome: " + g.GenomeId);
                 *
                 *      XmlDocument doc = new XmlDocument();
                 *      XmlGenomeWriterStatic.Write(doc, (SharpNeatLib.NeatGenome.NeatGenome)g);
                 *      FileInfo oFileInfo = new FileInfo("ProblemGenome.xml");
                 *      doc.Save(oFileInfo.FullName);
                 *
                 *      Environment.Exit(1);
                 *  }
                 * }
                 */
                neuronLookup.Add(g.NeuronGeneList[neuronGeneIndex].InnovationId, neuronGeneIndex);
                biasList[neuronGeneIndex] = g.NeuronGeneList[neuronGeneIndex].Bias;
            }

            // Create an array of the activation functions, inputs, and outputs for each module in the genome.
            ModulePacket[] modules = new ModulePacket[g.ModuleGeneList.Count];
            for (int i = g.ModuleGeneList.Count - 1; i >= 0; i--)
            {
                modules[i].function = g.ModuleGeneList[i].Function;
                // Must translate input and output IDs to array locations.
                modules[i].inputLocations = new int[g.ModuleGeneList[i].InputIds.Count];
                for (int j = g.ModuleGeneList[i].InputIds.Count - 1; j >= 0; j--)
                {
                    modules[i].inputLocations[j] = neuronLookup[g.ModuleGeneList[i].InputIds[j]];
                }
                modules[i].outputLocations = new int[g.ModuleGeneList[i].OutputIds.Count];
                for (int j = g.ModuleGeneList[i].OutputIds.Count - 1; j >= 0; j--)
                {
                    modules[i].outputLocations[j] = neuronLookup[g.ModuleGeneList[i].OutputIds[j]];
                }
            }

            // ConnectionGenes point to a neuron's innovation ID. Translate this ID to the neuron's index in the neuron array.
            FloatFastConnection[] connections = new FloatFastConnection[g.ConnectionGeneList.Count];
            for (int connectionGeneIndex = g.ConnectionGeneList.Count - 1; connectionGeneIndex >= 0; connectionGeneIndex--)
            {
                ConnectionGene connectionGene = g.ConnectionGeneList[connectionGeneIndex];
                connections[connectionGeneIndex].sourceNeuronIdx = neuronLookup[connectionGene.SourceNeuronId];
                connections[connectionGeneIndex].targetNeuronIdx = neuronLookup[connectionGene.TargetNeuronId];
                connections[connectionGeneIndex].weight          = (float)connectionGene.Weight;

                connections[connectionGeneIndex].learningRate  = connectionGene.learningRate;
                connections[connectionGeneIndex].A             = connectionGene.A;
                connections[connectionGeneIndex].B             = connectionGene.B;
                connections[connectionGeneIndex].C             = connectionGene.C;
                connections[connectionGeneIndex].D             = connectionGene.D;
                connections[connectionGeneIndex].modConnection = connectionGene.modConnection;
            }

            ModularNetwork mn = new ModularNetwork(biasCount, inputCount, outputCount, g.OutputsPerPolicy, neuronCount, connections, biasList, activationFunctions, modules);

            if (g.networkAdaptable)
            {
                mn.adaptable = true;
            }
            if (g.networkModulatory)
            {
                mn.modulatory = true;
            }

            mn.genome = g;
            return(mn);
        }
Пример #12
0
 public IOManager(ModulePacket packet)
 {
     _packet    = packet;
     _exporters = (List <IExporter>)_packet.GetInstances().OfType <IExporter>();
     _importers = (List <IImporter>)_packet.GetInstances().OfType <IImporter>();
 }
Пример #13
0
 public FluincyTask(ModulePacket packet)
 {
     _configurationManager = packet.GetSingleton <IConfigurationManager>();
 }
Пример #14
0
 public MainWindow(ModulePacket packet)
 {
     _packet  = packet;
     Controls = new List <IGuiComponent>();
     _ghosts  = new List <IGhost>();
 }
Пример #15
0
 public VSync(ModulePacket packet)
 {
     _packet = packet;
 }