Пример #1
0
    // Use this for initialization
    void Start()
    {
        tutorial_active    = false;
        source             = GetComponent <AudioSource>();
        initial_node       = nodeManager.GetCurrentNode();
        next_node          = nodeManager.GetNextNode();
        evo_controller     = GetComponent <EvolutionController>();
        transform.position = initial_node.transform.position;
        initial_position   = initial_node.transform.position;
        next_position      = next_node.transform.position;

        //Update Arrow direction
        target_controller.SetTarget(next_node.transform);

        //Set camera at the initial position
        camera_go.GetComponent <CameraController>().MoveCamera(transform);

        //Reset HUD
        DisablePowerUpHUD(PoweUpType.METAL);
        DisablePowerUpHUD(PoweUpType.SLOW);
        DisablePowerUpHUD(PoweUpType.STAR);

        script_star.GetComponent <ScrollingUVs_Layers>().enabled = false;
        if (startGame)
        {
            UI_Menu.GetComponent <UI_Game>().PlayGame();
        }
    }
Пример #2
0
        public void TestMethod2()
        {
            var controller = new EvolutionController();
            var response   = controller.GetByID("x", 1, 1, 0, 1, 75);

            Assert.IsTrue(response.result > 0);
        }
Пример #3
0
 void Awake()
 {
     Application.targetFrameRate = 60;
     Time.timeScale   = 1;
     players          = new List <PlayerMode>(11);
     terrains         = new Dictionary <TerrainPosition, TerrainGeneration>();
     particles        = new List <ParticleSystem>(11);
     cam              = Camera.main.GetComponent <CameraFollow>();
     evolutionManager = GetComponent <EvolutionController>();
     tests            = 0;
 }
 /// <summary>
 /// Adds the agent to the team if requested.
 /// </summary>
 private void Start()
 {
     if (m_AddToTeam)
     {
         TeamManager.AddTeamMember(gameObject, m_TeamIndex);
     }
     // Genetic Algorithm initialize
     evolver    = GameObject.Find("Evolution Controller").GetComponent <EvolutionController>();
     playerName = this.gameObject.name;
     phenoType  = evolver.GetPhenoType(playerName);
 }
Пример #5
0
 public void Start()
 {
     if (EvolutionControler == null)
     {
         Debug.Log("EvolutionController not set - trying to get it from this gameObject.");
         EvolutionControler = GetComponent <EvolutionController>(); if (EvolutionControler == null)
         {
             Debug.LogError("EvolutionController still not set! Disableing.");
             enabled = false;
             return;
         }
         return;
     }
 }
Пример #6
0
 // Use this for initialization
 void Start()
 {
     myTimers              = this.GetComponent <Timers>();
     myMovement            = this.GetComponent <Movement>();
     myAnimator            = this.GetComponent <Animator>();
     myImage               = this.GetComponent <Image>();
     myAnimController      = this.GetComponent <AnimationController>();
     myEvolutionController = this.GetComponent <EvolutionController>();
     ExpRequirements       = new int[6] {
         10, 20, 30, 40, 50, 60
     };                                                      //to be defined in json in future
     uiValues = new List <string>()
     {
         m_name, m_hunger.ToString(), m_experience.ToString()
     };
 }
Пример #7
0
    // Use this for initialization
    void Start()
    {
        Screen.SetResolution(80, 80, false);
        Application.targetFrameRate = 15;

        evolver    = GameObject.Find("Evolution Controller").GetComponent <EvolutionController>();
        evoManager = new EvolutionInfoManager();
        evoManager.ReadInfo();
        if (evoManager.Initial())
        {
            // The first game of the first iteration
            evoManager.Population = evolver.InitializeRandomPopulation(evoManager.N);
            evoManager.InitializePopulationQueue();
            evoManager.WritePopulation("population.csv");
        }
        else if (evoManager.SelectBest())
        {
            evoManager.ReadPopulation("population.csv");
            List <PhenoType> best = Selection();
            evoManager.Population = best;
            evoManager.WritePopulation("prev-population.csv");
            evoManager.ChildPopulation = GenerateOffspring();
            evoManager.Population      = evoManager.ChildPopulation;
            evoManager.InitializePopulationQueue();
        }
        else if (evoManager.EvaluateOffspring())
        {
            evoManager.ReadPopulation("population.csv");
            evoManager.WritePopulation("prev-population.csv");
            evoManager.ChildPopulation = GenerateOffspring();
            evoManager.Population      = evoManager.ChildPopulation;
            evoManager.InitializePopulationQueue();
        }
        else
        {
            evoManager.ReadPopulation("population.csv");
            evoManager.ReadPopulationQueue();
        }
        PlayGame();
    }
Пример #8
0
        static void TestGeneticAlgorithm()
        {
            string target = "Be or not to be?";
            IEvolutionController evolutionController = new EvolutionController(target);
            Population           population          = new Population(evolutionController, 300);

            population.MutationChance = 10;

            population.CurrentGeneration.Evaluate();
            while (true)
            {
                ReadKey();


                population.CurrentGeneration.Evaluate();

                IDna db = population.CurrentGeneration.Best;
                WriteLine(new string(db.GetGenes() as char[]) + " ||| " + db.Fitness);

                population.CreateNewGeneration();
            }
        }
Пример #9
0
    bool[] reachedMarker; //if a particular marker has been reached, true. Same order and size as goalmarkers

    // Use this for initialization
    void Start()
    {
        rb         = GetComponent <Rigidbody2D>();
        rand       = new System.Random(Guid.NewGuid().GetHashCode());
        initialPos = transform.position;


        ec = GameObject.Find("EvolutionController").GetComponent <EvolutionController>();

        //initialize square with ec data

        maxSteps     = ec.GetCurrMaxSteps();
        mutationRate = ec.GetMutationRate();

        currStep  = 0;
        currDelay = 0;

        //get initial list of movements
        //if not a square loaded from disk
        if (!loadedSquare)
        {
            InitializeMovements();
        }
    }
Пример #10
0
    void Update()
    {
        if (Input.GetButtonUp("AI_ON"))
        {
            AIEnablied = true;
            brain      = EvolutionController.CreateNeuralNet(evaluator);
            brain.setWeights(new Queue <double>(generateRandomWeights(brain.extractWeights().Count)));
        }

        if (AIEnablied)
        {
            setNeuralInputs();
            List <double> output = brain.calculateOutput();
            for (int i = 0; i < output.Count; ++i)
            {
                float newThrottle = output[i] < 0 ? 0 : (float)output[i];
                if (newThrottle > 1.0f)
                {
                    newThrottle = 1.0f;
                }
                thrusterControllers[i].throttle = newThrottle;
            }
        }
        else
        {
//			if (Input.GetButton("Jump")) {
//				foreach (ThrusterController thrusterController in thrusterControllers) {
//					thrusterController.firing = true;
//				}
//			} else {
//				foreach (ThrusterController thrusterController in thrusterControllers) {
//					thrusterController.firing = false;
//				}
//			}
        }
    }
Пример #11
0
 // Use this for initialization
 void Start()
 {
     ec        = GameObject.Find("EvolutionController").GetComponent <EvolutionController>();
     stepsText = this.GetComponent <Text>();
 }
 // Use this for initialization
 void Start()
 {
     text = transform.GetChild(0).GetComponent <Text>();
     ec   = GameObject.Find("EvolutionController").GetComponent <EvolutionController>();
 }