⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nfgshow.cc

📁 Gambit 是一个游戏库理论软件
💻 CC
📖 第 1 页 / 共 3 页
字号:
  if (dialog.ShowModal() == wxID_OK) {    m_table->SetDataFont(dialog.GetFontData().GetChosenFont());    m_table->RefreshTable();  }}void NfgShow::OnFormatFontLabels(wxCommandEvent &){  wxFontData data;  wxFontDialog dialog(this, &data);    if (dialog.ShowModal() == wxID_OK) {    m_table->SetLabelFont(dialog.GetFontData().GetChosenFont());    m_table->RefreshTable();  }}//----------------------------------------------------------------------//                 NfgShow: Menu handlers - Tools//----------------------------------------------------------------------void NfgShow::OnToolsDominance(wxCommandEvent &){  gArray<gText> playerNames(m_nfg.NumPlayers());  for (int pl = 1; pl <= playerNames.Length(); pl++) {    playerNames[pl] = m_nfg.Players()[pl]->GetName();  }  dialogElimMixed dialog(this, playerNames);  if (dialog.ShowModal() == wxID_OK) {    NFSupport support(*m_currentSupport);    wxStatus status(this, "Dominance Elimination");    try {      NFSupport newSupport(support);      while (true) {	gNullOutput gnull;	if (dialog.DomMixed()) {	  newSupport = support.MixedUndominated(dialog.DomStrong(),						precRATIONAL,						dialog.Players(),						gnull, status);	}	else {	  newSupport = support.Undominated(dialog.DomStrong(), 					   dialog.Players(),					   gnull, status);	}	if (newSupport == support) {	  break;	}	else {	  newSupport.SetName(UniqueSupportName());	  m_supports.Append(new NFSupport(newSupport));	  support = newSupport;	}	if (!dialog.Iterative()) {	  // Bit of a kludge: short-circuit loop if iterative not requested	  break;	}      }    }    catch (gSignalBreak &) { }    if (*m_currentSupport != support) {      m_currentSupport = m_supports[m_supports.Length()];      if (!m_table->ShowDominance()) {	m_table->ToggleDominance();	GetMenuBar()->Check(NFG_VIEW_DOMINANCE, true);      }      OnSupportsEdited();      UpdateMenus();    }  }}void NfgShow::OnToolsEquilibrium(wxCommandEvent &){   dialogNfgNash dialog(this, *m_currentSupport);  if (dialog.ShowModal() == wxID_OK) {    nfgNashAlgorithm *algorithm = dialog.GetAlgorithm();    if (!algorithm) {      return;    }    try {      wxStatus status(this, algorithm->GetAlgorithm() + "Solve Progress");      gList<MixedSolution> solutions;      solutions = algorithm->Solve(*m_currentSupport, status);      for (int soln = 1; soln <= solutions.Length(); soln++) {	AddProfile(solutions[soln], true);      }      ChangeProfile(m_profiles.Length());         if (solutions.Length() > 0 && !m_table->ShowProbs()) {	m_table->ToggleProbs();	GetMenuBar()->Check(NFG_VIEW_PROBABILITIES, true);      }      if (!m_solutionSashWindow->IsShown()) {	m_profileTable->Show(true);	m_solutionSashWindow->Show(true);	GetMenuBar()->Check(NFG_VIEW_PROFILES, true);	AdjustSizes();      }            UpdateMenus();    }    catch (...) { }    delete algorithm;  }}void NfgShow::OnToolsQre(wxCommandEvent &){  dialogNfgQre dialog(this, *m_currentSupport);  if (dialog.ShowModal() == wxID_OK) {    gList<MixedSolution> solutions;    try {      if (dialog.UseGridSearch()) {	QreNfgGrid algorithm;	algorithm.SetFullGraph(true);	algorithm.SetMinLambda(dialog.StartLambda());	algorithm.SetMaxLambda(dialog.StopLambda());	algorithm.SetDelLambda(dialog.StepLambda());	algorithm.SetPowLambda(1);	algorithm.SetDelP1(dialog.Del1());	algorithm.SetDelP2(dialog.Del2());	algorithm.SetTol1(dialog.Tol1());	algorithm.SetTol2(dialog.Tol2());	wxStatus status(this, "QreGridSolve Progress");	gNullOutput gnull;	algorithm.Solve(*m_currentSupport, gnull, status, solutions);      }      else {	nfgQre algorithm;	algorithm.SetFullGraph(true);	algorithm.SetMaxLambda(10000000);	wxStatus status(this, "QreSolve Progress");	solutions = algorithm.Solve(*m_currentSupport, status);      }    }    catch (gSignalBreak &) { }    catch (...) {      wxMessageDialog message(this,			      "An exception occurred in computing equilibria",			      "Error", wxID_OK);      message.ShowModal();    }    if (solutions.Length() > 0) {      dialogQreFile fileDialog(this, solutions);      if (fileDialog.ShowModal() == wxID_OK) {	      }    }  }}//----------------------------------------------------------------------//                NfgShow: Menu handlers - Help menu//----------------------------------------------------------------------void NfgShow::OnHelpAbout(wxCommandEvent &){  wxGetApp().OnHelpAbout(this);}//----------------------------------------------------------------------//               NfgShow: Menu handlers - Support menu//----------------------------------------------------------------------void NfgShow::OnSupportDuplicate(wxCommandEvent &){  NFSupport *newSupport = new NFSupport(*m_currentSupport);  newSupport->SetName(UniqueSupportName());  m_supports.Append(newSupport);  m_currentSupport = newSupport;  OnSupportsEdited();}void NfgShow::OnSupportDelete(wxCommandEvent &){  delete m_supports.Remove(m_supports.Find(m_currentSupport));  m_currentSupport = m_supports[1];  OnSupportsEdited();}//----------------------------------------------------------------------//              NfgShow: Menu handlers - Profiles menu//----------------------------------------------------------------------void NfgShow::OnProfilesNew(wxCommandEvent &){  MixedSolution profile = MixedProfile<gNumber>(NFSupport(m_nfg));  dialogEditMixed dialog(this, profile);  if (dialog.ShowModal() == wxID_OK) {    AddProfile(dialog.GetProfile(), true);    ChangeProfile(m_profiles.Length());    UpdateMenus();  }}void NfgShow::OnProfilesDuplicate(wxCommandEvent &){  MixedSolution profile(m_profiles[m_currentProfile]);    dialogEditMixed dialog(this, profile);  if (dialog.ShowModal() == wxID_OK) {    AddProfile(dialog.GetProfile(), true);    ChangeProfile(m_profiles.Length());    UpdateMenus();  }}void NfgShow::OnProfilesDelete(wxCommandEvent &){  m_profiles.Remove(m_currentProfile);  if (m_nfg.AssociatedEfg()) {    wxGetApp().GetWindow(m_nfg.AssociatedEfg())->RemoveProfile(m_currentProfile);  }  m_currentProfile = (m_profiles.Length() > 0) ? 1 : 0;  ChangeProfile(m_currentProfile);  UpdateMenus();}void NfgShow::OnProfilesProperties(wxCommandEvent &){  if (m_currentProfile > 0) {    dialogEditMixed dialog(this, m_profiles[m_currentProfile]);    if (dialog.ShowModal() == wxID_OK) {      m_profiles[m_currentProfile] = dialog.GetProfile();      ChangeProfile(m_currentProfile);    }  }}void NfgShow::OnProfilesReport(wxCommandEvent &){  dialogReport dialog(this, m_profileTable->GetReport());  dialog.ShowModal();}//----------------------------------------------------------------------//                  NfgShow: Non-menu event handlers//----------------------------------------------------------------------void NfgShow::OnCloseWindow(wxCloseEvent &p_event){  if (p_event.CanVeto() && GameIsDirty()) {    if (wxMessageBox("Game has been modified.  Close anyway?", "Warning",		     wxOK | wxCANCEL) == wxCANCEL) {      p_event.Veto();      return;    }  }  Show(false);  Destroy();}void NfgShow::AdjustSizes(void){  int width, height;  GetClientSize(&width, &height);  if (m_solutionSashWindow && m_solutionSashWindow->IsShown()) {    m_solutionSashWindow->SetSize(0, height - m_solutionSashWindow->GetRect().height,				  width, m_solutionSashWindow->GetRect().height);    height -= m_solutionSashWindow->GetRect().height;  }  if (m_navigateWindow && m_infoSashWindow->IsShown()) {    if (m_table) {      m_table->SetSize(m_infoSashWindow->GetRect().width, 0,		       width - m_infoSashWindow->GetRect().width, height);    }  }  else if (m_table) {    m_table->SetSize(0, 0, width, height);  }  if (m_navigateWindow && m_infoSashWindow->IsShown()) {    m_infoSashWindow->SetSize(0, 0, m_infoSashWindow->GetRect().width, height);  }  if (m_table) {    m_table->SetFocus();  }}void NfgShow::OnSize(wxSizeEvent &){  AdjustSizes();}void NfgShow::OnSashDrag(wxSashEvent &p_event){  int clientWidth, clientHeight;  GetClientSize(&clientWidth, &clientHeight);  switch (p_event.GetId()) {  case idINFOWINDOW:    m_table->SetSize(p_event.GetDragRect().width,		     m_table->GetRect().y,		     clientWidth - p_event.GetDragRect().width,		     m_table->GetRect().height);    m_infoSashWindow->SetSize(m_infoSashWindow->GetRect().x,			      m_infoSashWindow->GetRect().y,			      p_event.GetDragRect().width,			      m_infoSashWindow->GetRect().height);    break;  case idSOLUTIONWINDOW:    m_table->SetSize(m_table->GetRect().x, m_table->GetRect().y,		     m_table->GetRect().width,		     clientHeight - p_event.GetDragRect().height);    m_infoSashWindow->SetSize(m_infoSashWindow->GetRect().x,			      m_infoSashWindow->GetRect().y,			      m_infoSashWindow->GetRect().width,			      clientHeight - p_event.GetDragRect().height);    m_solutionSashWindow->SetSize(0, clientHeight - p_event.GetDragRect().height,				  clientWidth, p_event.GetDragRect().height);    break;  }}void NfgShow::OnSetFocus(wxFocusEvent &){  m_table->SetFocus();}void NfgShow::OnInfoNotebookPage(wxNotebookEvent &p_event){  GetMenuBar()->Check(NFG_VIEW_NAVIGATION, p_event.GetSelection() == 0);  GetMenuBar()->Check(NFG_VIEW_OUTCOMES, p_event.GetSelection() == 1);  GetMenuBar()->Check(NFG_VIEW_SUPPORTS, p_event.GetSelection() == 2);}//----------------------------------------------------------------------//                   NfgShow: Miscellaneous members//----------------------------------------------------------------------gText NfgShow::UniqueSupportName(void) const{  int number = m_supports.Length() + 1;  while (1) {    int i;    for (i = 1; i <= m_supports.Length(); i++) {      if (m_supports[i]->GetName() == "Support" + ToText(number)) {	break;      }    }    if (i > m_supports.Length())      return "Support" + ToText(number);        number++;  }}void NfgShow::SetFilename(const wxString &p_name){  m_filename = p_name;  if (m_filename != "") {    SetTitle(wxString::Format("Gambit - [%s] %s", m_filename.c_str(), 			      (char *) m_nfg.GetTitle()));  }  else {    SetTitle(wxString::Format("Gambit - %s", (char *) m_nfg.GetTitle()));  }  wxGetApp().SetFilename(this, p_name.c_str());}void NfgShow::SetSupportNumber(int p_number){  if (p_number >= 1 && p_number <= m_supports.Length()) {    m_currentSupport = m_supports[p_number];    OnSupportsEdited();  }}void NfgShow::OnSupportsEdited(void){  m_navigateWindow->SetSupport(*m_currentSupport);  m_table->SetSupport(*m_currentSupport);  m_supportWindow->UpdateValues();}#include "base/glist.imp"template class gList<NFSupport *>;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -