Пример #1
0
        public void Initialize(Track track, MLPNeuralNetwork controller)
        {
            var carAi = new CarAI(random, controller);

            // Load the simulation
            simulation = appService.Kernel.Get <RacingSimulationLogic>();
            simulation.SetTrack(track);

            // Add the 1:1 trained AI to the list of cars
            var cars = new List <ICarController>()
            {
                carAi
            };

            // Spawn 100 mutated versions of our AI
            for (int i = 0; i < 100; i++)
            {
                var car = carAi.Clone();
                car.Mutate();
                cars.Add((CarAI)car);
            }

            // Initialize the simulation
            simulation.SetCars(cars);
            simulation.ResetCars();

            // If the visualization is turned on, create it, set the track and add the cars.
            simulationVisualization = appService.Kernel.Get <RacingSimulationVisualization>();
            simulationVisualization.SetTrack(track);
            simulationVisualization.InitializeCars(simulation.GetCars());
        }