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

📄 portion.cc

📁 Gambit 是一个游戏库理论软件
💻 CC
📖 第 1 页 / 共 4 页
字号:
  if (_ref) {    ((InfosetPortion *) Original())->SetValue(value);  }  else {    SetGame(value->Game());    *_Value = value;  }}PortionSpec InfosetPortion::Spec(void) const{  return PortionSpec(porINFOSET);}void InfosetPortion::Output(gOutput& s) const{  Portion::Output(s);  s << "(Infoset) " << *_Value;  if(*_Value)    s << " \"" << (*_Value)->GetName() << "\""; }gText InfosetPortion::OutputString(void) const{  return "(Infoset)";}Portion* InfosetPortion::ValCopy(void) const{   return new InfosetPortion(*_Value);}Portion* InfosetPortion::RefCopy(void) const{  Portion* p = new InfosetPortion(*_Value, true);   p->SetOriginal(Original());  return p;}bool InfosetPortion::IsReference(void) const{  return _ref;}//--------// Node//--------gPool NodePortion::pool(sizeof(NodePortion));NodePortion::NodePortion(Node *value)  : _Value(new Node *(value)), _ref(false){  SetGame(value->Game());}NodePortion::NodePortion(Node *&value, bool ref)  : _Value(&value), _ref(ref){  if (!_ref) {    SetGame(value->Game());  }}  NodePortion::~NodePortion(){  if (!_ref)   delete _Value;}Node *NodePortion::Value(void) const{ return *_Value; }void NodePortion::SetValue(Node *value){  if (_ref) {    ((NodePortion *) Original())->SetValue(value);  }  else {    SetGame(value->Game());    *_Value = value;  }}PortionSpec NodePortion::Spec(void) const{ return PortionSpec(porNODE); }void NodePortion::Output(gOutput& s) const{  Portion::Output(s);  s << "(Node) " << *_Value;  if(*_Value)    s << " \"" << (*_Value)->GetName() << "\""; }gText NodePortion::OutputString(void) const{  return "(Node)";}Portion* NodePortion::ValCopy(void) const{  return new NodePortion(*_Value); }Portion* NodePortion::RefCopy(void) const{  Portion* p = new NodePortion(*_Value, true);   p->SetOriginal(Original());  return p;}bool NodePortion::IsReference(void) const{  return _ref;}//----------// Action//----------gPool ActionPortion::pool(sizeof(ActionPortion));ActionPortion::ActionPortion(Action *value)  : _Value(new Action *(value)), _ref(false){  SetGame(value->BelongsTo()->Game());}ActionPortion::ActionPortion(Action *& value, bool ref)  : _Value(&value), _ref(ref){  if (!_ref) {    SetGame(value->BelongsTo()->Game());  }}ActionPortion::~ActionPortion(){  if (!_ref)   delete _Value;}Action *ActionPortion::Value(void) const{ return *_Value; }void ActionPortion::SetValue(Action *value){  if (_ref) {    ((ActionPortion *) Original())->SetValue(value);  }  else {    SetGame(value->BelongsTo()->Game());    *_Value = value;  }}PortionSpec ActionPortion::Spec(void) const{ return PortionSpec(porACTION); }void ActionPortion::Output(gOutput& s) const{  Portion::Output(s);  s << "(Action) " << *_Value;  if(*_Value)    s << " \"" << (*_Value)->GetName() << "\""; }gText ActionPortion::OutputString(void) const{  return "(Action)";}Portion* ActionPortion::ValCopy(void) const{  return new ActionPortion(*_Value); }Portion* ActionPortion::RefCopy(void) const{  Portion* p = new ActionPortion(*_Value, true);   p->SetOriginal(Original());  return p;}bool ActionPortion::IsReference(void) const{  return _ref;}//---------// Mixed//---------gPool MixedPortion::pool(sizeof(MixedPortion));MixedPortion::MixedPortion(MixedSolution *value)  : rep(new struct mixedrep(value)), _ref(false){  SetGame(&rep->value->Game());}MixedPortion::MixedPortion(const MixedPortion *p, bool ref)  : rep(p->rep), _ref(ref){  rep->nref++;  if (!_ref) {    SetGame(&rep->value->Game());  }}MixedPortion::~MixedPortion(){  if (--rep->nref == 0)   delete rep;}MixedSolution *MixedPortion::Value(void) const{ return rep->value; }void MixedPortion::SetValue(MixedSolution *value){  if (_ref)   {    ((MixedPortion *) Original())->SetValue(value);    rep = ((MixedPortion *) Original())->rep;    rep->nref++;  }  else  {    if (--rep->nref == 0)  delete rep;    rep = new mixedrep(value);    SetGame(&value->Game());  }}PortionSpec MixedPortion::Spec(void) const{   return PortionSpec(porMIXED);}void MixedPortion::Output(gOutput& s) const{  Portion::Output(s);  s << "(Mixed) ";  for (int pl = 1; pl <= rep->value->Game().NumPlayers(); pl++)  {    s << "{ ";    NFPlayer *player = rep->value->Game().Players()[pl];    for (int st = 1; st <= player->NumStrats(); st++) {      Strategy *strategy = player->Strategies()[st];      if (_WriteSolutionLabels == triTRUE) {	if ((*rep->value)(strategy) > gNumber(0)) {	  s << strategy->Name() << '=';	  s << (*rep->value)(strategy) << ' ';	}      }      else	s << (*rep->value)(strategy) << ' ';      }    s << "}";  }  if (_WriteSolutionInfo == triTRUE)    rep->value->DumpInfo(s);}gText MixedPortion::OutputString(void) const{  return "(Mixed)";}Portion* MixedPortion::ValCopy(void) const{   return new MixedPortion(this, false);}Portion* MixedPortion::RefCopy(void) const{   Portion* p = new MixedPortion(this, true);  p->SetOriginal(this);  return p;}bool MixedPortion::IsReference(void) const{  return _ref;}//---------// Behav//---------gPool BehavPortion::pool(sizeof(BehavPortion));BehavPortion::BehavPortion(BehavSolution *value)  : rep(new struct behavrep(value)), _ref(false){  SetGame((efgGame *) &rep->value->GetGame());}BehavPortion::BehavPortion(const BehavPortion *p, bool ref)  : rep(p->rep), _ref(ref){  rep->nref++;  if (!_ref) {    SetGame((efgGame *) &rep->value->GetGame());  }}BehavPortion::~BehavPortion(){  if (--rep->nref == 0)   delete rep;}BehavSolution *BehavPortion::Value(void) const{ return rep->value; }void BehavPortion::SetValue(BehavSolution *value){  if (_ref)   {    ((BehavPortion *) Original())->SetValue(value);    rep = ((BehavPortion *) Original())->rep;    rep->nref++;  }  else  {    if (--rep->nref == 0)  delete rep;    rep = new behavrep(value);    SetGame((efgGame *) &value->GetGame());  }}PortionSpec BehavPortion::Spec(void) const{   return PortionSpec(porBEHAV);}void BehavPortion::Output(gOutput& s) const{  Portion::Output(s);  s << "(Behav) ";  for (int pl = 1; pl <= rep->value->GetGame().NumPlayers(); pl++)  {    s << "{ ";    EFPlayer *player = rep->value->GetGame().Players()[pl];    for (int iset = 1; iset <= player->NumInfosets(); iset++)  {      s << "{ ";      Infoset *infoset = player->Infosets()[iset];      for (int act = 1; act <= infoset->NumActions(); act++) {	if (_WriteSolutionLabels == triTRUE) {	  if ((*rep->value)(infoset->Actions()[act]) > gNumber(0)) {	    s << infoset->Actions()[act]->GetName() << '=';	    s << (*rep->value)(infoset->Actions()[act]) << ' ';	  }	}	else	  s << (*rep->value)(infoset->Actions()[act]) << ' ';      }      s << "}";    }    s << " }";  }  if (_WriteSolutionInfo == triTRUE)    rep->value->DumpInfo(s);}gText BehavPortion::OutputString(void) const{  return "(Behav)";}Portion* BehavPortion::ValCopy(void) const{   return new BehavPortion(this, false);}Portion* BehavPortion::RefCopy(void) const{   Portion* p = new BehavPortion(this, true);   p->SetOriginal(this);  return p;}bool BehavPortion::IsReference(void) const{ return _ref; }//-------// Nfg//-------gPool NfgPortion::pool(sizeof(NfgPortion));NfgPortion::NfgPortion(Nfg *value)  : _Value(new Nfg *(value)), _ref(false){  SetGame(*_Value);}NfgPortion::NfgPortion(Nfg *&value, bool ref)  : _Value(&value), _ref(ref){   // for games, only call SetGame for ValPortions, not RefPortions!  if( !_ref )    SetGame(*_Value);}NfgPortion::~NfgPortion(){   // for games, only call SetGame for ValPortions, not RefPortions!  if (!_ref) {    delete _Value;   }}Nfg *NfgPortion::Value(void) const{ return *_Value; }void NfgPortion::SetValue(Nfg *value){  // for games, only call SetGame for ValPortions, not RefPortions!  ((NfgPortion*) Original())->SetGame( value );  *_Value = value;}PortionSpec NfgPortion::Spec(void) const{   return PortionSpec(porNFG);}void NfgPortion::Output(gOutput& s) const{  Portion::Output(s);  s << "(Nfg) \"" << (*_Value)->GetTitle() << "\"";}gText NfgPortion::OutputString(void) const{  return "(Nfg)";}Portion* NfgPortion::ValCopy(void) const{   return new NfgPortion(*_Value);}Portion* NfgPortion::RefCopy(void) const{   Portion* p = new NfgPortion(*_Value, true);  p->SetOriginal(Original());  return p;}bool NfgPortion::IsReference(void) const{ return _ref; }//-------// Efg//-------gPool EfgPortion::pool(sizeof(EfgPortion));EfgPortion::EfgPortion(efgGame *value)  : _Value(new efgGame *(value)), _ref(false){  SetGame(*_Value);}EfgPortion::EfgPortion(efgGame *&value, bool ref)  : _Value(&value), _ref(ref){   // for games, only call SetGame for ValPortions, not RefPortions!  if( !_ref )    SetGame(*_Value);}EfgPortion::~EfgPortion(){   if (!_ref) {    delete _Value;   }}efgGame *EfgPortion::Value(void) const{ return *_Value; }void EfgPortion::SetValue(efgGame *value){  // for games, only call SetGame for ValPortions, not RefPortions!  ((EfgPortion*) Original())->SetGame( value );  *_Value = value;}PortionSpec EfgPortion::Spec(void) const{  return PortionSpec(porEFG);}void EfgPortion::Output(gOutput& s) const{  Portion::Output(s);  s << "(Efg) \"" << (*_Value)->GetTitle() << "\""; }gText EfgPortion::OutputString(void) const{  return "(Efg)";}Portion* EfgPortion::ValCopy(void) const{   return new EfgPortion(*_Value);}Portion* EfgPortion::RefCopy(void) const{   Portion* p = new EfgPortion(*_Value, true);   p->SetOriginal(Original());  return p;}bool EfgPortion::IsReference(void) const{  return _ref;}//----------// Output//----------gPool OutputPortion::pool(sizeof(OutputPortion));OutputPortion::OutputPortion(gOutput& value)  : rep(new struct outputrep(&value)), _ref(false){ }OutputPortion::OutputPortion(const OutputPortion *p, bool ref)  : rep(p->rep), _ref(ref){  rep->nref++;}OutputPortion::~OutputPortion(){  if (--rep->nref == 0)   delete rep;}gOutput& OutputPortion::Value(void) const{ return *rep->value; }PortionSpec OutputPortion::Spec(void) const{ return PortionSpec(porOUTPUT); }void OutputPortion::Output(gOutput& s) const{  Portion::Output(s);  s << "(Output)"; }gText OutputPortion::OutputString(void) const{  return "(Output)";}Portion* OutputPortion::ValCopy(void) const{   return new OutputPortion(this, false);}Portion* OutputPortion::RefCopy(void) const{   Portion* p = new OutputPortion(this, true);   p->SetOriginal(Original());  return p;

⌨️ 快捷键说明

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