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

📄 efgshow.cc

📁 Gambit 是一个游戏库理论软件
💻 CC
📖 第 1 页 / 共 4 页
字号:
    m_treeWindow->RefreshLayout();    m_treeWindow->Refresh();  }}void EfgShow::OnFormatDisplayLegend(wxCommandEvent &){  dialogLegend dialog(this, m_treeWindow->DrawSettings());  if (dialog.ShowModal() == wxID_OK) {    m_treeWindow->DrawSettings().SetNodeAboveLabel(dialog.GetNodeAbove());    m_treeWindow->DrawSettings().SetNodeBelowLabel(dialog.GetNodeBelow());    m_treeWindow->DrawSettings().SetNodeRightLabel(dialog.GetNodeAfter());    m_treeWindow->DrawSettings().SetBranchAboveLabel(dialog.GetBranchAbove());    m_treeWindow->DrawSettings().SetBranchBelowLabel(dialog.GetBranchBelow());    m_treeWindow->DrawSettings().SaveOptions();    m_treeWindow->RefreshLabels();  }}void EfgShow::OnFormatDisplayColors(wxCommandEvent &){  dialogEfgColor dialog(this, m_treeWindow->DrawSettings());  if (dialog.ShowModal() == wxID_OK) {    m_treeWindow->DrawSettings().SetChanceColor(dialog.GetChanceColor());    m_treeWindow->DrawSettings().SetTerminalColor(dialog.GetTerminalColor());    for (int pl = 1; pl <= 8; pl++) {      m_treeWindow->DrawSettings().SetPlayerColor(pl,						  dialog.GetPlayerColor(pl));    }    m_treeWindow->DrawSettings().SaveOptions();    m_treeWindow->RefreshTree();  }}void EfgShow::OnFormatDisplayDecimals(wxCommandEvent &){  dialogSpinCtrl dialog(this, "Decimal places", 0, 25,			m_treeWindow->DrawSettings().NumDecimals());  if (dialog.ShowModal() == wxID_OK) {    m_treeWindow->DrawSettings().SetNumDecimals(dialog.GetValue());    m_treeWindow->DrawSettings().SaveOptions();    m_treeWindow->Refresh();  }}//----------------------------------------------------------------------//             EfgShow: Menu handler - Tools->Dominance//----------------------------------------------------------------------void EfgShow::OnToolsDominance(wxCommandEvent &){  gArray<gText> playerNames(m_efg.NumPlayers());  for (int pl = 1; pl <= playerNames.Length(); pl++) {    playerNames[pl] = m_efg.Players()[pl]->GetName();  }  dialogElimBehav dialog(this, playerNames);  if (dialog.ShowModal() == wxID_OK) {    EFSupport support(*m_currentSupport);    wxStatus status(this, "Dominance Elimination");    try {      EFSupport newSupport(support);      while (true) {	gNullOutput gnull;	newSupport = support.Undominated(dialog.DomStrong(),					 dialog.DomConditional(),					 dialog.Players(), gnull, status);	if (newSupport == support) {	  break;	}	else {	  newSupport.SetName(UniqueSupportName());	  m_supports.Append(new EFSupport(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()];       OnSupportsEdited();      UpdateMenus();    }  }}//----------------------------------------------------------------------//            EfgShow: Menu handlers - Tools->Equilibrium//----------------------------------------------------------------------void EfgShow::OnToolsEquilibrium(wxCommandEvent &){  dialogEfgNash dialog(this, *m_currentSupport);  if (dialog.ShowModal() == wxID_OK) {    efgNashAlgorithm *algorithm = dialog.GetAlgorithm();    if (!algorithm) {      return;    }    try {      wxStatus status(this, algorithm->GetAlgorithm() + "Solve Progress");      gList<BehavSolution> solutions;      solutions = algorithm->Solve(*m_currentSupport, status);      for (int soln = 1; soln <= solutions.Length(); soln++) {	AddProfile(solutions[soln], true);      }      ChangeProfile(m_profiles.Length());         if (!m_solutionSashWindow->IsShown()) {	m_profileTable->Show(true);	m_solutionSashWindow->Show(true);	GetMenuBar()->Check(efgmenuVIEW_PROFILES, true);	AdjustSizes();      }            UpdateMenus();    }    catch (gException &ex) {      wxMessageDialog msgDialog(this, (char *) ex.Description(),				"Gambit exception", wxOK);      msgDialog.ShowModal();    }    catch (...) {      wxMessageDialog msgDialog(this,				"An internal exception occurred while solving",				"Gambit exception", wxOK);      msgDialog.ShowModal();    }    delete algorithm;  }}void EfgShow::OnToolsQre(wxCommandEvent &){  try {    efgQre algorithm;    algorithm.SetFullGraph(true);    algorithm.SetMaxLambda(10000000);    wxStatus status(this, "QreSolve Progress");    gList<BehavSolution> solutions = algorithm.Solve(*m_currentSupport,						     status);    if (solutions.Length() > 0) {      dialogQreFile fileDialog(this, solutions);      if (fileDialog.ShowModal() == wxID_OK) {      }    }  }  catch (...) {  }}void EfgShow::OnToolsNormalReduced(wxCommandEvent &){  // check that the game is perfect recall, if not give a warning  if (!IsPerfectRecall(m_efg)) {    if (wxMessageBox("This game is not perfect recall\n"		     "Do you wish to continue?", 		     "Reduced normal form", 		     wxOK | wxCANCEL | wxCENTRE, this) != wxOK) {      return;    }  }      if (m_efg.AssociatedNfg() != 0) {    return;  }  Nfg *nfg = MakeReducedNfg(*m_currentSupport);  if (nfg) {    NfgShow *nfgShow = new NfgShow(*nfg, m_parent);    nfgShow->SetFilename("");    wxGetApp().AddGame(&m_efg, nfg, nfgShow);    for (int i = 1; i <= m_profiles.Length(); i++) {      BehavProfile<gNumber> profile(*m_profiles[i].Profile());      MixedProfile<gNumber> mixed(profile);      nfgShow->AddProfile(MixedSolution(mixed, m_profiles[i].Creator()), false);    }    if (m_profiles.Length() > 0) {      nfgShow->ChangeProfile(m_currentProfile);    }  }  else {    wxMessageBox("Could not create normal form game.\n",		 "Reduced normal form", wxOK);  }}void EfgShow::OnToolsNormalAgent(wxCommandEvent &){  // check that the game is perfect recall, if not give a warning  if (!IsPerfectRecall(m_efg)) {    if (wxMessageBox("This game is not perfect recall\n"		     "Do you wish to continue?", 		     "Agent normal form", 		     wxOK | wxCANCEL | wxCENTRE, this) != wxOK) {      return;    }  }      Nfg *N = MakeAfg(m_efg);  if (N) {    (void) new NfgShow(*N, m_parent);  }}//----------------------------------------------------------------------//                 EfgShow: Menu handlers - Help menu//----------------------------------------------------------------------void EfgShow::OnHelpAbout(wxCommandEvent &){  wxGetApp().OnHelpAbout(this);}//----------------------------------------------------------------------//               EfgShow: Menu handlers - Support menu//----------------------------------------------------------------------void EfgShow::OnSupportDuplicate(wxCommandEvent &){  EFSupport *newSupport = new EFSupport(*m_currentSupport);  newSupport->SetName(UniqueSupportName());  m_supports.Append(newSupport);  m_currentSupport = newSupport;  OnSupportsEdited();}void EfgShow::OnSupportDelete(wxCommandEvent &){  delete m_supports.Remove(m_supports.Find(m_currentSupport));  m_currentSupport = m_supports[1];  OnSupportsEdited();}//----------------------------------------------------------------------//              EfgShow: Menu handlers - Profiles menu//----------------------------------------------------------------------void EfgShow::OnProfilesNew(wxCommandEvent &){  BehavSolution profile = BehavProfile<gNumber>(EFSupport(m_efg));  dialogEditBehav dialog(this, profile);  if (dialog.ShowModal() == wxID_OK) {    AddProfile(dialog.GetProfile(), true);    ChangeProfile(m_profiles.Length());  }}void EfgShow::OnProfilesDuplicate(wxCommandEvent &){  BehavSolution profile(m_profiles[m_currentProfile]);  dialogEditBehav dialog(this, profile);  if (dialog.ShowModal() == wxID_OK) {    AddProfile(dialog.GetProfile(), true);    ChangeProfile(m_profiles.Length());  }}void EfgShow::OnProfilesDelete(wxCommandEvent &){  m_profiles.Remove(m_currentProfile);  if (m_efg.AssociatedNfg()) {    wxGetApp().GetWindow(m_efg.AssociatedNfg())->RemoveProfile(m_currentProfile);  }  m_currentProfile = (m_profiles.Length() > 0) ? 1 : 0;  ChangeProfile(m_currentProfile);}void EfgShow::OnProfilesProperties(wxCommandEvent &){  if (m_currentProfile > 0) {    dialogEditBehav dialog(this, m_profiles[m_currentProfile]);    if (dialog.ShowModal() == wxID_OK) {      m_profiles[m_currentProfile] = dialog.GetProfile();      ChangeProfile(m_currentProfile);    }  }}void EfgShow::OnProfilesReport(wxCommandEvent &){  dialogReport dialog(this, m_profileTable->GetReport());  dialog.ShowModal();}void EfgShow::OnProfileSelected(wxListEvent &p_event){  m_currentProfile = p_event.GetIndex() + 1;  m_treeWindow->RefreshLabels();  if (m_navigateWindow) {    m_navigateWindow->Set(m_cursor);  }}//----------------------------------------------------------------------//                  EfgShow: Non-menu event handlers//----------------------------------------------------------------------void EfgShow::OnInfoNotebookPage(wxNotebookEvent &p_event){  if (!m_nodeSashWindow->IsShown()) {    return;  }  GetMenuBar()->Check(efgmenuVIEW_OUTCOMES, false);  GetMenuBar()->Check(efgmenuVIEW_NAVIGATION, false);  GetMenuBar()->Check(efgmenuVIEW_SUPPORTS, false);  switch (p_event.GetSelection()) {  case 0:    GetMenuBar()->Check(efgmenuVIEW_NAVIGATION, true);    break;  case 1:    GetMenuBar()->Check(efgmenuVIEW_OUTCOMES, true);    break;  case 2:    GetMenuBar()->Check(efgmenuVIEW_SUPPORTS, true);    break;  default:    break;  }}void EfgShow::OnCloseWindow(wxCloseEvent &p_event){  if (p_event.CanVeto() && m_efg.IsDirty()) {    if (wxMessageBox("Game has been modified.  Close anyway?", "Warning",		     wxOK | wxCANCEL) == wxCANCEL) {      p_event.Veto();      return;    }  }  Show(false);  Destroy();}void EfgShow::OnFocus(wxFocusEvent &){  m_treeWindow->SetFocus();}void EfgShow::OnSize(wxSizeEvent &){  AdjustSizes();}void EfgShow::OnSashDrag(wxSashEvent &p_event){  int clientWidth, clientHeight;  GetClientSize(&clientWidth, &clientHeight);  switch (p_event.GetId()) {  case idNODEWINDOW:    m_treeWindow->SetSize(p_event.GetDragRect().width,			  m_treeWindow->wxWindowBase::GetRect().y,			  clientWidth - p_event.GetDragRect().width,			  m_treeWindow->wxWindowBase::GetRect().height);    m_nodeSashWindow->SetSize(m_nodeSashWindow->GetRect().x,			      m_nodeSashWindow->GetRect().y,			      p_event.GetDragRect().width,			      m_nodeSashWindow->GetRect().height);    break;  case idSOLUTIONWINDOW:    m_treeWindow->SetSize(m_treeWindow->wxWindowBase::GetRect().x,			  m_treeWindow->wxWindowBase::GetRect().y,			  m_treeWindow->wxWindowBase::GetRect().width,			  clientHeight - p_event.GetDragRect().height);    m_nodeSashWindow->SetSize(m_nodeSashWindow->GetRect().x,			      m_nodeSashWindow->GetRect().y,			      m_nodeSashWindow->GetRect().width,			      clientHeight - p_event.GetDragRect().height);    m_solutionSashWindow->SetSize(0, clientHeight - p_event.GetDragRect().height,				  clientWidth, p_event.GetDragRect().height);    break;  }}void EfgShow::AdjustSizes(void){  int width, height;  GetClientSize(&width, &height);  if (m_profileTable && 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_nodeSashWindow->IsShown())) {    if (m_treeWindow) {      m_treeWindow->SetSize(m_nodeSashWindow->GetRect().width, 0,			    width - m_nodeSashWindow->GetRect().width, height);    }  }  else if (m_treeWindow) {    m_treeWindow->SetSize(0, 0, width, height);  }  if (m_navigateWindow && m_nodeSashWindow->IsShown()) {    m_nodeSashWindow->SetSize(0, 0, m_nodeSashWindow->GetRect().width, height);  }  if (m_treeWindow) {    m_treeWindow->SetFocus();  }}#include "base/glist.imp"template class gList<EFSupport *>;

⌨️ 快捷键说明

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