示例#1
0
    void Environment::Step()
    {
      std::vector<Action *> actions(0);
      unsigned int i;
      for(i = 0; i < agents.size(); i++)
	{
	  Percept *percept = GetPercept(agents[i]);
	  Action  *action  = agents[i]->Program(percept);
	  if(action)
	    {
	      actions.push_back(action);
	    }
	  delete percept;
	}
      for(i = 0; i < agents.size(); i++)
	{
	  ApplyAction(agents[i], actions[i]);
	}
      for(i = 0; i < agents.size(); i++)
	{
	  delete actions[i];
	}
      for(i = 0; i < agents.size(); i++)
	{
	  CalculatePerformance(agents[i]);
	}
      UpdateDisplays();
    } 
示例#2
0
    void Environment::Run(const int n_steps)
    {
      int t;
      unsigned int i;
      for(i = 0; i < agents.size(); i++)
	{
	  agents[i]->SetPerformance(0);
	}
      UpdateDisplays();
      if(delay)
	{
	  sleep(delay);
	}
      for(t = 0; t < n_steps; t++)
	{
	  if(IsDone())
	    {
	      return;
	    }
	  Step();
	  if(delay)
	    {
	      sleep(delay);
	    }
	}
    }
示例#3
0
//---------------------------------------------------------------------------------------
QuizCounters::QuizCounters(wxWindow* parent, wxWindowID id, int nNumTeams,
                           ExerciseCtrol* pOwner, ExerciseOptions* pConstrains,
                           QuizManager* pProblemMngr, const wxPoint& pos)
    : DlgCounters(parent, id, pOwner, pConstrains, pos)
      , m_pProblemMngr(pProblemMngr)
      , m_fTwoTeamsMode(nNumTeams == 2)
{
    wxASSERT(nNumTeams == 1 || nNumTeams == 2);

    // Create the controls
    this->SetBackgroundColour(*wxWHITE);
    wxBoxSizer* pMainSizer = new wxBoxSizer(wxVERTICAL);
    m_pProblemMngr->SetNumTeams(nNumTeams);
    for(int i=0; i < nNumTeams; i++)
        CreateCountersGroup(i, pMainSizer);
    add_mode_controls(pMainSizer);

    //load icons
    wxBitmap bmp = wxArtProvider::GetBitmap("button_accept", wxART_TOOLBAR, wxSize(24,24));
    m_pBmpRight->SetBitmap(bmp);
    bmp = wxArtProvider::GetBitmap("button_cancel", wxART_TOOLBAR, wxSize(24,24));
    m_pBmpWrong->SetBitmap(bmp);
    bmp = wxArtProvider::GetBitmap("diploma_cap", wxART_TOOLBAR, wxSize(35,24));
    m_pBmpTotal->SetBitmap(bmp);
    if (m_fTwoTeamsMode)
    {
        m_bmpRed = wxArtProvider::GetBitmap("team_red", wxART_TOOLBAR, wxSize(24,24));
        m_pBmpTeam[0]->SetBitmap(m_bmpRed);
        m_bmpBlue = wxArtProvider::GetBitmap("team_blue", wxART_TOOLBAR, wxSize(24,24));
        m_pBmpTeam[1]->SetBitmap(m_bmpBlue);
        m_bmpGrey = wxArtProvider::GetBitmap("team_grey", wxART_TOOLBAR, wxSize(24,24));
    }

    ////TODO 5.0
    ////'reset counters' link
    //pMainSizer->Add(
    //    new lmUrlAuxCtrol(this, lmID_LINK_RESET_COUNTERS, rScale, _("Reset counters"),
    //                      "link_reset" ),
    //    0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5);

    //set main window sizer
    SetSizer( pMainSizer );                 // use the sizer for window layout
    pMainSizer->SetSizeHints( this );       // set size hints to honour minimum size

    Layout();
    for (int i=0; i < nNumTeams; i++)
        UpdateDisplays(i);
}
示例#4
0
//---------------------------------------------------------------------------------------
void QuizCounters::OnResetCounters(wxCommandEvent& WXUNUSED(event))
{
    m_pProblemMngr->ResetCounters();
    for (int i=0; i < m_pProblemMngr->GetNumTeams(); i++)
        UpdateDisplays(i);
}
示例#5
0
//---------------------------------------------------------------------------------------
void QuizCounters::UpdateDisplay()
{
    UpdateDisplays( m_pProblemMngr->GetCurrentTeam() );
}