Esempio n. 1
0
        private new void Update()
        {
            if (_currentlyUpdating)
            {
                return;
            }

            _currentlyUpdating = true;

            //Save State Path
            _currentFrame++;
            string path = @"C:\Users\ericm\source\repos\MachineGaming\BizHawk\SNES\State\YoshisIsland1.State";

            if ((_currentFrame % 5) == 0)
            {
                //Refesh Inputs
                _inputCollector.RefreshInputs(_inputs);
                _engine.populateInputs(_inputs);

                _engine.activateCurrent();

                //Collect Output
                _engine.retrieveOutputs(_outputs);
            }

            //Update Controller
            ClearController();
            Joypad.Set("P1 Right", true);

            //Update Game Run Tracking
            if (_inputCollector.CharX > _maxX)
            {
                _maxX    = _inputCollector.CharX;
                _timeout = TIMEOUT;
            }
            _timeout--;

            if (_timeout <= 0 || _inputCollector.LevelStatus == 9)
            {
                if (_engine.nextGenome()) //Load game and run next genome
                {
                    Debug.Print(_engine.getGenomeDetail());
                    SaveStateApi.Load(path);
                    _inputCollector.RefreshInputs(_inputs);
                    _timeout      = TIMEOUT;
                    _currentFrame = 0;
                    _maxX         = 0;
                }
                else //Population has been fully explored.
                {
                }
            }

            _currentlyUpdating = false;
        }
Esempio n. 2
0
        private void ClearController()
        {
            var controls = Emulator.ControllerDefinition.ControlsOrdered.GetEnumerator();

            controls.MoveNext(); //Skip Console Controls
            controls.MoveNext(); //Move to player 1 buttons.

            foreach (string button in controls.Current)
            {
                Joypad.Set(button, false);
            }
        }
Esempio n. 3
0
 private void PressButton(string button, bool value)
 {
     Joypad.Set(button, value, 1);
 }