Esempio n. 1
0
 public void AddLogEvent(LogEvent le)
 {
     if (listBox1.InvokeRequired)
     {
         ALE ale = new ALE(AddLogEvent);
         listBox1.Invoke(ale, le);
     }
     else
     {
         listBox1.Items.Insert(0, le);
         while (listBox1.Items.Count > 5)
         {
             listBox1.Items.RemoveAt(5);
         }
         hideTime = DateTime.Now.AddSeconds(10);
         ShowMe();
     }
 }
Esempio n. 2
0
 public void AddLogEvent(LogEvent le)
 {
     if (listBox1.InvokeRequired)
     {
         ALE ale = new ALE(AddLogEvent);
         listBox1.Invoke(ale, le);
     }
     else
     {
         listBox1.Items.Insert(0, le);
         while (listBox1.Items.Count > 5)
         {
             listBox1.Items.RemoveAt(5);
         }
         hideTime = DateTime.Now.AddSeconds(10);
         ShowMe();
     }
 }
Esempio n. 3
0
        private void process(object arg)
        {
            string strRom = (string)arg;
            IALE   ale    = new ALE();

            try
            {
                ale.Initialize();
                ale.EnableDisplayScreen       = m_bShowDisplay;
                ale.EnableSound               = m_bShowDisplay;
                ale.EnableColorData           = true;
                ale.EnableRestrictedActionSet = true;
                ale.EnableColorAveraging      = true;
                ale.EnableTerminateOnRallyEnd = m_bTerminateOnRallyEnd;
                ale.AllowNegativeRewards      = m_bAllowNegativeRewards;
                ale.RandomSeed = 123;
                ale.RepeatActionProbability = 0.25f;
                ale.Load(strRom);
                ACTION[] rgActions = ale.ActionSpace;
                Random   rand      = new Random();
                int      nEpisode  = 0;
                float    fWid;
                float    fHt;
                float    fTotalReward = 0;

                ale.GetScreenDimensions(out fWid, out fHt);

                while (nEpisode < 10 && !m_evtAbort.WaitOne(0))
                {
                    if (m_action == ACTION.ACT_RESET)
                    {
                        ale.ResetGame();
                        fTotalReward = 0;
                    }
                    else
                    {
                        ACTION action = ACTION.ACT_PLAYER_A_NOOP;

                        if (rgActions.Contains(m_action))
                        {
                            action = m_action;
                        }

                        float fReward = ale.Act(action);
                        fTotalReward += fReward;

                        byte[] rgScreen = ale.GetScreenData(m_ct);

                        Invoke(new fnUpdate(update), m_ct, rgScreen, (int)fWid, (int)fHt, fTotalReward);

                        if (ale.GameOver)
                        {
                            ale.ResetGame();
                            nEpisode++;
                            fTotalReward = 0;
                        }
                    }
                }
            }
            catch (Exception excpt)
            {
                m_strError = "ERROR: " + excpt.Message;
            }

            ale.Shutdown();
            m_evtDone.Set();
        }