void init(
		Singleton* _singleton,
		PlantRules* _rootRules,
		PlantRules* _trunkRules,
		FIVector4* _origin
	) {
		singleton = _singleton;
		rootRules = _rootRules;
		trunkRules = _trunkRules;
		origin.setFXYZRef(_origin);

		trunkVec.setFXYZ(fGenRand()*0.1f,fGenRand()*0.1f,1.0f);
		trunkVec.normalize();
		rootVec.setFXYZRef(&trunkVec);
		rootVec.multXYZ(-1.0f);

		if (trunkNode == NULL) {
			trunkNode = new GamePlantNode();
		}
		if (rootsNode == NULL) {
			rootsNode = new GamePlantNode();
		}


		initBase(rootRules, rootsNode, &rootVec);
		initBase(trunkRules, trunkNode, &trunkVec);

	}
Example #2
0
ParticleSet::ParticleSet(const ParticleSet& p)
  : UseBoundBox(p.UseBoundBox), UseSphereUpdate(p.UseSphereUpdate),IsGrouped(p.IsGrouped)
  , ThreadID(0), mySpecies(p.getSpeciesSet()),SK(0), ParentTag(p.tag())
{
  initBase();
  initParticleSet();
  assign(p); //obly the base is copied, assumes that other properties are not assignable
  //need explicit copy:
  Mass=p.Mass;
  Z=p.Z;
  ostringstream o;
  o<<p.getName()<<ObjectTag;
  this->setName(o.str());
  app_log() << "  Copying a particle set " << p.getName() << " to " << this->getName() << " groups=" << groups() << endl;
  PropertyList.Names=p.PropertyList.Names;
  PropertyList.Values=p.PropertyList.Values;
  PropertyHistory=p.PropertyHistory;
  Collectables=p.Collectables;
  //construct the distance tables with the same order
  //first is always for this-this paier
  for (int i=1; i<p.DistTables.size(); ++i)
    addTable(p.DistTables[i]->origin());
  if(p.SK)
  {
    R.InUnit=p.R.InUnit;
    createSK();
    SK->DoUpdate=p.SK->DoUpdate;
  }
  if (p.Sphere.size())
    resizeSphere(p.Sphere.size());
  add_p_timer(myTimers);
  myTwist=p.myTwist;
}
Example #3
0
void KisNodeViewTest::init()
{
    m_doc = KisPart::instance()->createDocument();

    m_nameServer = new KisNameServer();
    m_shapeController = new KisShapeController(m_doc, m_nameServer);

    initBase();
}
void KisNodeModelTest::init()
{
    m_doc = new KisDoc2();

    m_nameServer = new KisNameServer();
    m_shapeController = new KisShapeController(m_doc, m_nameServer);
    m_nodeModel = new KisNodeModel(0);

    initBase();
}
Example #5
0
void LCOBPMOcta1::init()
{
	initBase();
	
	
	
	//char tmpN[8000];
	//sprintf(tmpN, "Check_%s.txt", Name);
	//fCheck.open(tmpN);
}
Example #6
0
void SkOpSpan::init(SkOpSegment* segment, SkOpSpan* prev, double t, const SkPoint& pt) {
    SkASSERT(t != 1);
    initBase(segment, prev, t, pt);
    fCoincident = this;
    fToAngle = nullptr;
    fWindSum = fOppSum = SK_MinS32;
    fWindValue = 1;
    fOppValue = 0;
    fTopTTry = 0;
    fChased = fDone = false;
    segment->bumpCount();
    fAlreadyAdded = false;
}
Example #7
0
SHMData_A<LogInfoData> * ThreeLogGroupMgr::getLogGroupDataAddr(int iGroupId)
{
	if(iGroupId <= 0 ||iGroupId > m_iMaxGroup)
	{
		Log::log(0,"日志组ID取值为1至%d",m_iMaxGroup);
		return NULL;
	}

	if(m_bAttached == false)
	{
		initBase();
	}
	
	return m_poInfoDataAll[iGroupId];
}
Example #8
0
SHMIntHashIndex_A * ThreeLogGroupMgr::getLogGroupIndexAddr (int iGroupId)

{
	if(iGroupId <= 0 ||iGroupId > m_iMaxGroup)
	{
		Log::log(0,"日志组ID取值为1至%d",m_iMaxGroup);
		return NULL;
	}	

	if(m_bAttached == false)
	{
		initBase();
	}
	
   return m_poInfoIndexAll[iGroupId];
}	
Example #9
0
OBMapPair * createMapPair(obj *key, obj *value){

  static const char classname[] = "OBMapPair";
  OBMapPair *new_instance = malloc(sizeof(OBMapPair));
  assert(new_instance != NULL);

  /* initialize base class data */
  initBase((obj *)new_instance, &deallocMapPair, &hashMapPair, NULL, 
           &displayMapPair, classname);

  retain(key);
  new_instance->key = key;
  retain(value);
  new_instance->value = value;

  return new_instance;
}
Example #10
0
OBMap * createDefaultMap(void){

  static const char classname[] = "OBMap";
  OBMap *new_instance = malloc(sizeof(OBMap));
  assert(new_instance != NULL);

  /* initialize base class data */
  initBase((obj *)new_instance, &deallocMap, &hashMap,
           &compareMaps, &displayMap, classname);

  new_instance->hash_table = NULL;
  new_instance->pairs = NULL;
  new_instance->cap_idx = 0;
  new_instance->collisions = 0;

  return new_instance;
}
  void VirtualParticleSet::init_minimum(int nptcl)
  {
    //make R, ID and GroupID available
    initBase();
    Lattice = myPtcl->Lattice;
    PrimitiveLattice = myPtcl->PrimitiveLattice;
    create(nptcl);

    ratios.resize(nptcl);

    if(myPtcl->DistTables.size())
    {
      DistTables.resize(myPtcl->DistTables.size());
      DistTables[0]=createDistanceTable(*myPtcl,*this);
      for(int i=1; i<myPtcl->DistTables.size(); ++i)
        DistTables[i]=createDistanceTable(myPtcl->DistTables[i]->origin(),*this);
      for(int i=0; i<DistTables.size(); ++i)
        DistTables[i]->ID=i;
    }
  }
Example #12
0
void ThreeLogGroupMgr::showShmInfo()
{
	if(m_bAttached == false)
	{
		initBase();
	}
	
 	printf("*********************************************************\n");
	printf("日志组共享内存信息:\n");
	for(int i=1;i<=m_iMaxGroup;i++)
	{
		printf("GROUP_ID:%d\n",i);
		printf("\n");
		int iDataCnt = GetShmDataCount(i);
		int iDataTotal = GetShmDataTotalCount(i);
		printf("SHM_DATA_USED:%d条\n",iDataCnt);
		printf("SHM_DATA_TOTAL:%d条\n",iDataTotal);
		printf("\n");
		int iIndexCnt = GetShmIndexCount(i);
		int iIndexTotal = GetShmIndexTotalCount(i);
		printf("SHM_INDEX_USED:%d条\n",iIndexCnt);
		printf("SHM_INDEX_TOTAL:%d条\n",iIndexTotal);
		printf("\n");

		int iIndexDataTotal = GetShmIndexDataTotal(i);
		printf("SHM_INDEX_DATA_TOTAL:%d条\n",iIndexDataTotal);

		for(int j=1;j<iIndexTotal;j++)
		{
			int iIndexDataCount = GetShmIndexDataCount(i,j);
			if(iIndexDataCount>0)
				printf("INDEX(%d):COUNT:%d条\n",j,iIndexDataCount);
			}
			printf("-------------------\n");
		}
	printf("*********************************************************\n");
}
Example #13
0
Bonus_3_12::Bonus_3_12(Node*scene,Vec2 pos)
{
	string str = "cloud12.png";


	initBase();
	is_Bonus = true;


	Scene_UI*sce = (Scene_UI*)scene;
	menu = MenuItemSprite::create(Sprite::createWithSpriteFrameName(str), Sprite::createWithSpriteFrameName(str), [=](Ref*)
	{
		is_selected = !is_selected;

		if (is_selected)
		{
			for (int i = 0;i<sce->monster_queue.size();i++)
			{
				;
				{
					((Bonus_UI*)sce->monster_queue[i])->sprite_selected->setVisible(false);
					((Bonus_UI*)sce->monster_queue[i])->is_selected = false;

				}

			}

			is_selected = true;
			sprite_selected->setVisible(true);
			return;
		}
		sprite_selected->setVisible(false);

	});
	menu->setPosition(pos);
	menu;;




	 men = Menu::create(menu, nullptr);
	men->setPosition(0, 0);
	scene->addChild(men);


	sprite = Sprite::createWithSpriteFrameName(str);

	scene->addChild(sprite);
	sprite->setPosition(pos);
	sprite;;



	sprite_selected = Sprite::createWithSpriteFrameName("point01.png");

	{
		auto ani = Animation::create();
		ani->addSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName("point01.png"));
		ani->addSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName("point02.png"));
		ani->setDelayPerUnit(3.0 / 30.0);
		ani->setRestoreOriginalFrame(false);
		ani->setLoops(-1);

		sprite_selected->runAction(Animate::create(ani));
	}
	sprite_selected->setPosition(sprite->getContentSize().width / 2, sprite->getContentSize().height);
	sprite->addChild(sprite_selected);
	sprite_selected->setVisible(false);

	



	hp_sprite_2 = Sprite::createWithSpriteFrameName("MonsterHP02.png");
	hp_sprite_2->setPosition(Vec2(sprite->getContentSize().width / 4, sprite->getContentSize().height - 5));
	sprite->addChild(hp_sprite_2);
	hp_sprite_1 = Sprite::createWithSpriteFrameName("MonsterHP01.png");
	hp_sprite_1->setPosition(Vec2(sprite->getContentSize().width / 4, sprite->getContentSize().height - 5));
	sprite->addChild(hp_sprite_1);
	hp_sprite_1->setAnchorPoint(Vec2(0, 0.5));
	hp_sprite_2->setAnchorPoint(Vec2(0, 0.5));
	hp_sprite_1->setScaleY(0.7);




	sprite_effect_slow = Sprite::createWithSpriteFrameName("PShit-12.png");
	sprite->addChild(sprite_effect_slow);

	auto ani1 = Animation::create();
	ani1->addSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName("PShit-12.png"));
	ani1->addSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName("PShit-11.png"));

	ani1->setDelayPerUnit(0.1);
	ani1->setRestoreOriginalFrame(false);
	ani1->setLoops(-1);
	sprite_effect_slow->runAction(Animate::create(ani1));
	sprite_effect_slow->setPosition(sprite->getContentSize().width / 2, 20);


	sprite_effect_slow->setVisible(false);



	hp_sprite_1->setVisible(false);
	hp_sprite_2->setVisible(false);
















	/*init Õ¼ÓÃλÖÃ*/

	queue_takeplace_pos.push_back(Vec2(PublicFunc::convertToX(pos.x),PublicFunc::convertToY(pos.y)));



	for (int i = 0;i<queue_takeplace_pos.size(); i++)
	{
		sce->data->push_back(queue_takeplace_pos[i]);
	}

}
Example #14
0
ParticleBase<PL>::ParticleBase():Counter(0), LocalNum(0), GlobalNum(0)
{
  initBase();
}
Example #15
0
void Netlog::initPLAY(string filename)
{
	initBase(filename);
	file.open(fileName, ios::in | ios::binary);
}
Example #16
0
void Netlog::initREC(string filename)
{
	initBase(filename);
	file.open(fileName, ios::out | ios::trunc | ios::binary);
}
int LCGWSpinBBHNR1::init()
{	
	initBase();
#ifdef _DEBUG_GW_    
	char fNCheck[512];
    int iRCheck(MT->ifloor(MT->RandUniform(0, 10000.)));
    sprintf(fNCheck,"CheckGWSpinBBHNR1_%d.txt",iRCheck);
    std::cerr << "DEBUG:GW:LCGWSpinBBHNR1 : File = " << fNCheck << Endl;
    DEBUGfCheck = new std::ofstream(fNCheck);
    DEBUGDispAll=true;
#endif
	double t0tcM(9.);
	
	ComputeExtraParam();
    
	if(GWSBHHH == NULL)
		GWSBHHH = new LCGWSpinBBHHHarm1(MT);
	GWSBHHH->setParam(0, Beta);
	GWSBHHH->setParam(1, Lambda);
	GWSBHHH->setParam(4, tc);
	GWSBHHH->setParam(5, DL);
	GWSBHHH->setParam(6, chi1);
	GWSBHHH->setParam(7, chi2);
	GWSBHHH->setParam(8, thBS1);
	GWSBHHH->setParam(9, thBS2);
	GWSBHHH->setParam(10, phBS1);
	GWSBHHH->setParam(11, phBS2);
	GWSBHHH->setParam(12, Phi0);
	GWSBHHH->setParam(13, thBL);
	GWSBHHH->setParam(14, phBL);
	GWSBHHH->setParam(15, Mtot*pow(m1*m2/(M*M), 0.6));
	GWSBHHH->setParam(17, m1*m2/(M*M));
    GWSBHHH->setParam(21, thetaJ);    // added by Sofiane
	GWSBHHH->setParam(22, phiJ);      // added by Sofiane
	GWSBHHH->setSpecialParam(3, omMInit);
	GWSBHHH->setTimeInfo(tInfot0, dt, maxDur, tAskMin, tDOrbMax, tInfotMaxDiff );
	GWSBHHH->init();
	GWSBHHH->DispInfo(" >>> SpinBBH in NR <<< ");
	
	//! *** Copy the informations about the taper from inspiral waveform
	GWSBHHH->getTaperInfo(tTaper,tendTaper,FreqMaxTaper);
   
    
	
	
	Amp =  M / dist;
    
	
	//tShifttc = 5. * t0tcM*t0tcM*t0tcM*t0tcM  / 256. * M / eta;
	
	
	/*! *** Determine the relation between the hybrid time and observation time using the following condition : 
	 *	At the initial data point, the hybrid orbital frequency should match the one based on PN 
	 */
	
	//double LS1, LS2, S1S2, m1M2, m2M2, eta;
	double DomLow, DomHigh, DomMean, tLow(0.), tHigh(tc), tMean, omMin, omMax;
	
	//m1M2 = pow( (1.+1./mrat) ,-2.);
	//m2M2 = pow( (1.+mrat) ,-2.);
	
	//LS1 = LnB.scalar(S1B);
	//LS2 = LnB.scalar(S2B);
	//S1S2 = S1B.scalar(S2B);
	
	
	
	tLow = 0.;
	tHigh = tc - 5. / 256. * M / eta;
	
	omMin = GWSBHHH->ComputeApprOrbFreq(tLow, tc);
	//Cout << "omMin = " << omMin << " vs " << ComputeApprOrbFreq(tLow, tc, chi1, chi2, LS1, LS2, S1S2, m1M2, m2M2, eta) << Endl;
	
	omMax = GWSBHHH->ComputeApprOrbFreq(tHigh, tc);
	//Cout << "omMax = " << omMax << " vs " << ComputeApprOrbFreq(tHigh, tc, chi1, chi2, LS1, LS2, S1S2, m1M2, m2M2, eta) << Endl;
	
	DomLow  = omMin - omMInit/M;
	DomHigh = omMax - omMInit/M;
	
	MT->o->precision(12);
	
	if( DomLow*DomHigh <= 0.0 ){
		Cout << "Looking for the time corresponding to initial omega " << omMInit/M << " in the range [ " << omMin << " , " << omMax << " ] corresponding to the time range [ " << tLow << " , " << tHigh << " ] ... " << Endl;
		do{
			tMean = (tHigh+tLow)/2.0;
			DomMean = GWSBHHH->ComputeApprOrbFreq(tMean, tc) - omMInit/M;
			if(DomLow*DomMean>0){
				tLow = tMean;
				DomLow = DomMean;
			}else{
				tHigh = tMean;
				DomHigh = DomMean;
			}
			//Cout << "DomLow ( " << tLow << " ) = " << DomLow << "   -   DomHigh ( " << tHigh << " ) = " << DomHigh << Endl; 
		}while(fabs(DomMean/(omMInit/M))>1.e-6);
		Cout << "\t ==> Found initial omega " << omMInit/M << " at t = " << tMean << " s ( precision = " << DomMean << " )" << Endl; 
		tInitObs = tMean;
	}else {
		Cout << "WARNING : The required value of omega " << omMInit/M << " is not in the waveform possible value, i.e. in the range [ " << omMin << " , " << omMax << " ] corresponding to the time range [ " << tLow << " , " << tHigh << " ]" << Endl;
		tInitObs = tc - 5. * 9.*9.*9.*9.  / 256. * M / eta ; // Default value corresponding at 9 M
	}
	
	
	
	
	
	tShiftHybObs = tInitObs - toMInitHyb*M;
	
	Cout << "Time relation between hybrid and observation (matching of initial orbital frequency " << omMInit <<  " with PN orb. freq. ) :" << Endl;
	Cout << "\t + Initial hybrid time      = " << toMInitHyb*M << " s = " << toMInitHyb << " M" << Endl;
	Cout << "\t + Initial observation time = " << tInitObs << " s = " << tInitObs/M << " M" << Endl;
	Cout << "\t + Time between initial and merger (observation time) = " << (tc-tInitObs) << " s = " << (tc-tInitObs)/M << " M" << Endl;
	Cout << "\t + Shift between observation and hybrid = " << tShiftHybObs << " s = " << tShiftHybObs/M << " M" << Endl;
    Cout << " NRdatadt*M  =   " << NRdatadt*M << " sec" << Endl;  // added by Sofiane
 	
	
	
	//! ** Find the range of time when the waveform is define
	tStartWave = 0.;
	tEndWave = 0.;
	if(NRdata[0]!=NULL){
		//	tStartWave = tc  + (NRdatat0+10.*NRdatadt)*M;
        tStartWave = tShiftHybObs + (NRdatat0+10.*NRdatadt)*M;
        
        
		//Cout << tc << Endl;
		//Cout << NRdata[0]->getxend() << "  ==>  " << NRdata[0]->getxend()*M <<  Endl;
		//Cout << NRdata[0]->getdx() << "  ==>  " << NRdata[0]->getdx()*M << Endl;
		
		//    tEndWave = tc  + (NRdatatend-10.*NRdatadt)*M;
		tEndWave = tShiftHybObs + (NRdatatend-10.*NRdatadt)*M;
	}
	Cout << "Waveform defined in time range = [ " << tStartWave << " : " << tEndWave << " ] sec" << Endl;
	
	//! ** Compute and store spherical harmonics
  
	for(int iH=0; iH<NHarm; iH++){
		if(NRdata[iH] != NULL)
			SpherHarmVal[iH] = ComputeSpherHarm(lHarm[iH], mHarm[iH], Thd, Phd);
		else
			SpherHarmVal[iH] = 0.;
        
	}
	
	FreqMin = 0.125*pow(0.2*(mrat/((1+mrat)*(1+mrat)))*(tc)/M, -0.375)/(4.*M*M_PI);
	
	if(ApplyTaper){
		FreqMax = FreqMaxTaper;
		Cout << "\t Taper (in LCGWSpinBBHNR1::init) : applied with parameters : tTaper = " << tTaper << " , tend = " << tendTaper <<  " , FreqMax = " << FreqMaxTaper << Endl;
	}else{ 
		FreqMax = FreqMaxM/M;
	}
	
	//FreqMax = 1./(M_PI*M*pow(10.,3./2.));
	
	//Cout << "Mtot = " << M << " s : t = " << tc - pow(10.,4.) * (5.*M)/((mrat/((1+mrat)*(1+mrat)))*256) <<  " ==> FreqMax = " << FreqMax << Endl;
	
	return 0;
}
Example #18
0
Monster_fat_green::Monster_fat_green(int t_hp, Node*scene, Vec2 pos, queue<Vec2> que)
{

	string str = "fat_green01.png";


	initBase();
	hp = t_hp;
	hp_now = hp;

	queue_way = que;
	sprite = Sprite::createWithSpriteFrameName(str);
	scene->addChild(sprite);
	sprite->setPosition(pos);

	sprite;;


	Scene_UI*sce = (Scene_UI*)scene;

	menu = MenuItemSprite::create(Sprite::create("1.png"), Sprite::create("1.png"), [=](Ref*)
	{
		is_selected = !is_selected;

		if (is_selected)
		{
			for (int i = 0; i < sce->monster_queue.size(); i++)
			{
				;
				{
					((Bonus_UI*)sce->monster_queue[i])->sprite_selected->setVisible(false);
					((Bonus_UI*)sce->monster_queue[i])->is_selected = false;

				}

			}

			is_selected = true;
			sprite_selected->setVisible(true);
			return;
		}
		sprite_selected->setVisible(false);

	});
	menu->setPosition(sprite->getContentSize().width / 2, sprite->getContentSize().height / 2);


	men = Menu::create(menu, nullptr);
	men->setPosition(0, 0);
	sprite->addChild(men);


	menu->setScale(sprite->getContentSize().height / 2.0 / 40.0);



	sprite_selected = Sprite::createWithSpriteFrameName("point01.png");

	{
		auto ani = Animation::create();
		ani->addSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName("point01.png"));
		ani->addSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName("point02.png"));
		ani->setDelayPerUnit(3.0 / 30.0);
		ani->setRestoreOriginalFrame(false);
		ani->setLoops(-1);

		sprite_selected->runAction(Animate::create(ani));
	}
	sprite_selected->setPosition(sprite->getContentSize().width / 2, sprite->getContentSize().height);
	sprite->addChild(sprite_selected);
	sprite_selected->setVisible(false);








	hp_sprite_2 = Sprite::createWithSpriteFrameName("MonsterHP02.png");
	hp_sprite_2->setPosition(Vec2(sprite->getContentSize().width / 4, sprite->getContentSize().height - 5));
	sprite->addChild(hp_sprite_2);



	hp_sprite_1 = Sprite::createWithSpriteFrameName("MonsterHP01.png");
	hp_sprite_1->setPosition(Vec2(sprite->getContentSize().width / 4, sprite->getContentSize().height - 5));
	sprite->addChild(hp_sprite_1);



	hp_sprite_1->setAnchorPoint(Vec2(0, 0.5));


	hp_sprite_2->setAnchorPoint(Vec2(0, 0.5));


	hp_sprite_1->setVisible(false);
	hp_sprite_2->setVisible(false);

	hp_sprite_1->setScaleY(0.7);

	resetWay();

	auto ani = Animation::create();
	ani->addSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName("mcm01.png"));
	ani->addSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName("mcm02.png"));
	ani->addSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName("mcm02.png"));


	ani->setDelayPerUnit(0.1);
	ani->setRestoreOriginalFrame(true);
	ani->setLoops(1);
	sprite->runAction(Animate::create(ani));


	/*
		hp_sprite_1;;
		hp_sprite_2;;
		*/





}
Example #19
0
unsigned int FMPWPartTmpl<GainTmpl>::
doPartitionOne4(vector<unsigned char>& part) 
{
  initBase();
  return doPartitionInternal(part);
}
Example #20
0
void updateBase(uint8_t round, uint8_t pos, State *state)
{
	int k;
	Action localActionList[MAX_NUM_ACTIONS];
	uint8_t localActionNum;
	uint8_t holeCards[2];
	struct Node *pt = NULL;
	OppBase *base;

	if (round < MAX_ROUNDS) {
		base = &flopsBase[round];
	}
	else {
		fprintf(stderr, "updateBase: invalid round argument %d\n", round);
		exit(EXIT_FAILURE);
	}
	
	/* extract actions in  stage */
	memcpy(localActionList, state->action[round], state->numActions[round]* sizeof(Action));
	localActionNum = state->numActions[round];
	#if 0
	/* debug */
		printf("Actions this round\n");
		for(k=0; k<localActionNum; k++) printf("%d\t", localActionList[k].type);
		printf("\n");
	#endif

	/* extract holeCards */
	holeCards[0] = state->holeCards[pos][0];
	holeCards[1] = state->holeCards[pos][1];

	if (0 == round) {/* preflop */
		if (pos == 0) { /* non-first hand*/
			pt = (NULL == base->nonDealerRoot ? initBase(base, false): base->nonDealerRoot);
		}
		else if (pos == 1) { /* first hand*/
			pt = (NULL == base->dealerRoot ? initBase(base, true): base->dealerRoot);
		}
		else {
			fprintf(stderr, "updateOppBase: invalid player position\n");
			exit(EXIT_FAILURE);
		}
	}
	else {
		if (pos == 0) { /* first player*/
			pt = (NULL == base->dealerRoot ? initBase(base, true): base->dealerRoot);
		}
		else if (pos == 1) { /* non-first player*/
			pt = (NULL == base->nonDealerRoot ? initBase(base, false): base->nonDealerRoot);
		}
		else {
			fprintf(stderr, "updateOppBase: invalid player position\n");
			exit(EXIT_FAILURE);
		}
	}
	
	for(k=0; k<localActionNum; k++) {
		#if 0
		if (k>0) { 
			pt->actionList[k-1] = localActionList[k-1].type; 
			pt->actionNum ++;
		}
		#endif
		
		if (pt->type == prob) { /* update  prob info */
			switch (localActionList[k].type) {
				case fold:
					pt->data.actionDist.fCnt++;
					if (pt->leftChild == NULL) {
						pt->leftChild = malloc(sizeof(struct Node));
						initNode(pt->leftChild, strength);
#ifdef DEBUG
						memcpy(pt->leftChild->actionList, pt->actionList, sizeof(int) * pt->actionNum);
						pt->leftChild->actionNum = pt->actionNum + 1;
						pt->leftChild->actionList[pt->leftChild->actionNum-1] = localActionList[k].type;
#endif
					}
					pt = pt->leftChild;
					break;
				case call:
					pt->data.actionDist.cCnt++;
					if (pt->midChild == NULL) {
						pt->midChild = malloc(sizeof(struct Node));
						initNode(pt->midChild, strength);
#ifdef DEBUG
						memcpy(pt->midChild->actionList, pt->actionList, sizeof(int) * pt->actionNum);
						pt->midChild->actionNum = pt->actionNum + 1;
						pt->midChild->actionList[pt->midChild->actionNum-1] = localActionList[k].type;
#endif
						}
					pt = pt->midChild;
					break;
				case raise:
					pt->data.actionDist.rCnt++;
					if (pt->rightChild == NULL) {
						pt->rightChild = malloc(sizeof(struct Node));
						initNode(pt->rightChild, strength);
#ifdef DEBUG
						memcpy(pt->rightChild->actionList, pt->actionList, sizeof(int) * pt->actionNum);
						pt->rightChild->actionNum = pt->actionNum + 1;
						pt->rightChild->actionList[pt->rightChild->actionNum-1] = localActionList[k].type;
#endif
						}
					pt = pt->rightChild;
					break;
				default:
					fprintf(stderr, "updateBase: invalid action %d\n", localActionList[k].type);
					exit(EXIT_FAILURE);
				}
		}
		else {
			unsigned idx = calcStrength();
			pt->data.bucket[idx] ++;
			switch (localActionList[k].type) { /* update strength info */
				case fold:
					if (pt->leftChild == NULL) {
						pt->leftChild = malloc(sizeof(struct Node));
						initNode(pt->leftChild, prob);
#ifdef DEBUG
						memcpy(pt->leftChild->actionList, pt->actionList, sizeof(int) * pt->actionNum);
						pt->leftChild->actionNum = pt->actionNum + 1;
						pt->leftChild->actionList[pt->leftChild->actionNum-1] = localActionList[k].type;
#endif
						}
					pt = pt->leftChild;
					break;
				case call:
					if (pt->midChild == NULL) {
						pt->midChild = malloc(sizeof(struct Node));
						initNode(pt->midChild, prob);
#ifdef DEBUG
						memcpy(pt->midChild->actionList, pt->actionList, sizeof(int) * pt->actionNum);
						pt->midChild->actionNum = pt->actionNum + 1;
						pt->midChild->actionList[pt->midChild->actionNum-1] = localActionList[k].type;
#endif
					}
					pt = pt->midChild;
					break;
				case raise:
					if (pt->rightChild == NULL) {
						pt->rightChild = malloc(sizeof(struct Node));
						initNode(pt->rightChild, prob);
#ifdef DEBUG
						memcpy(pt->rightChild->actionList, pt->actionList, sizeof(int) * pt->actionNum);
						pt->rightChild->actionNum = pt->actionNum + 1;
						pt->rightChild->actionList[pt->rightChild->actionNum-1] = localActionList[k].type;
#endif
					}
					pt = pt->rightChild;
					break;
				default:
					fprintf(stderr, "updateBase: invalid action %d\n", localActionList[k].type);
					exit(EXIT_FAILURE);
				}
			}
	}
}
Example #21
0
void updateBase(uint8_t round, uint8_t pos, State *state, bool isFold)
{
	int k;
	int i;
	Action localActionList[MAX_NUM_ACTIONS];
	uint8_t localActionNum;
	struct Node *pt = NULL;
	OppBase *base;

	if (state->numActions[round] == 0) return;
	
	if (round < MAX_ROUNDS) {
		base = &flopsBase[round];
	}
	else {
		fprintf(stderr, "%s:%d\t updateBase: invalid round argument %d\n", __FILE__, __LINE__, round);
		exit(EXIT_FAILURE);
	}
	
	for (i=0; i<state->numActions[round]; i++) {
		localActionList[i].type = state->action[round][i].type;
		localActionList[i].size = 0;
		
		if (localActionList[i].type >= 3) {
			fprintf(stderr, "%s:%d\t updateBase: invalid action %d, #actions %d\n", 
							 __FILE__, __LINE__, localActionList[i].type, state->numActions[round]);
			exit(EXIT_FAILURE);
		}
	}
 	localActionNum = state->numActions[round];

	if (0 == round) {/* preflop */
		if (pos == 0) { /* non-first hand*/
			pt = ((NULL == base->nonDealerRoot) ? initBase(base, false): base->nonDealerRoot);
		}
		else if (pos == 1) { /* first hand*/
			pt = ((NULL == base->dealerRoot) ? initBase(base, true): base->dealerRoot);
		}
		else {
			fprintf(stderr, "%s:%d\t updateBase: invalid player position\n", __FILE__, __LINE__);
			exit(EXIT_FAILURE);
		}
	}
	else {
		if (pos == 0) { /* first player*/
			pt = ((NULL == base->dealerRoot) ? initBase(base, true): base->dealerRoot);
		}
		else if (pos == 1) { /* non-first player*/
			pt = ((NULL == base->nonDealerRoot) ? initBase(base, false): base->nonDealerRoot);
		}
		else {
			fprintf(stderr, "%s:%d\t updateBase: invalid player position\n", __FILE__, __LINE__);
			exit(EXIT_FAILURE);
		}
	}
	
	for(k=0; k<localActionNum; k++) {
		enum ActionType type = localActionList[k].type;
		if (type >= 3) {
			fprintf(stderr, "%s:%d\t type %d abnormal\n", __FILE__, __LINE__, type);
			exit(EXIT_FAILURE);
		}
		else {
			if (pt->type == prob) {(pt->data.actionDist[type])++ ;}
			else {
				if (false == isFold) {
					unsigned idx = computeHandStrength(state, pos);
					assert(idx <= MAX_NUM_BUCKETS);
					(pt->data.bucket[idx-1]) ++;
				}
			}
			if (pt->child[type] == NULL) {
				pt->child[type] = (struct Node*)malloc(sizeof(struct Node));
				assert(NULL != pt->child[type]);
				initNode(pt->child[type], (pt->type == prob)? strength: prob);
				pt->child[type]->parent = pt;
				#ifdef DEBUG
				memcpy(pt->child[type]->actionList, pt->actionList, sizeof(enum ActionType) * (pt->actionNum));
				pt->child[type]->actionNum = pt->actionNum + 1;
				pt->child[type]->actionList[pt->child[type]->actionNum-1] = type;
				#endif
				
				/* in case the last strength node can't get updated since no action is following */
				if((pt->type == prob) && (k == localActionNum-1) && (false == isFold)) {
					unsigned idx = computeHandStrength(state, pos);
					(pt->child[type]->data.bucket[idx-1]) ++;
				}
			}
			pt = pt->child[type];
		}
	}
}
Example #22
0
 ParticleSet::ParticleSet(const ParticleSet& p) {
   initBase();
   initParticleSet();
   assign(p);
 }
void LCOrbitsAnaOctahedron::init()
{
	initBase();
	
	Lo2 = L0m / 2.;
	Lsq2o2 =  Lo2 * sqrt(2.) ;
	/*
	RxySC[0] = Rgc;
	RxySC[1] = sqrt((Rgc+L0m/2.)*(Rgc+L0m/2.) + L0m*L0m/4.);
	RxySC[2] = sqrt((Rgc+L0m/2.)*(Rgc+L0m/2.) + L0m*L0m/4.);
	RxySC[3] = Rgc;
	RxySC[4] = sqrt((Rgc-L0m/2.)*(Rgc-L0m/2.) + L0m*L0m/4.);
	RxySC[5] = sqrt((Rgc-L0m/2.)*(Rgc-L0m/2.) + L0m*L0m/4.);
	
	phixySC[0] = 0.; 
	phixySC[1] = atan2(-L0m/2, RxySC[1]);
	phixySC[2] = atan2( L0m/2, RxySC[2]);
	phixySC[3] = 0.; 
	phixySC[4] = atan2( L0m/2, RxySC[3]);
	phixySC[5] = atan2(-L0m/2, RxySC[4]);
	 
	 
	MT->o->precision(15);
	for(int i=0; i<6; i++)
		Cout << i << " : RxySC = " << RxySC[i] << " ,  phixySC = " << phixySC[i] << Endl;
	*/
	//! *** Nominal position of spacecrafts
	posRL1[0].x( 0. );
	posRL1[0].y( 0. );
	posRL1[0].z( Lsq2o2 );
	
	posRL1[1].x(  Lo2 );
	posRL1[1].y( -Lo2 );
	posRL1[1].z(  0. );
	
	posRL1[2].x( Lo2 );
	posRL1[2].y( Lo2 );
	posRL1[2].z(  0. );
	
	posRL1[3].x(  0. );
	posRL1[3].y(  0. );
	posRL1[3].z( -Lsq2o2 );
	
	posRL1[4].x( -Lo2 );
	posRL1[4].y(  Lo2 );
	posRL1[4].z(  0. );
	
	posRL1[5].x( -Lo2 );
	posRL1[5].y( -Lo2 );
	posRL1[5].z(  0. );
	
	//! *** Add offset
	for(int iSC=1; iSC<=6; iSC++){
		if((iSC==1)||(iSC==4))
			posRL1[iSC-1] *= (1.+pSCOff[iSC-1]);
		else
			posRL1[iSC-1] *= (1.+pSCOff[iSC-1]/sqrt(2));
	}
	
	
	/*! *** Store the value corresponding at t = 0 */
	
	tStorePos = 0.;
	for(int i=1; i<=NSC; i++)
		SCposStore[i-1] = position(i,0.0);
	
	tStoreArm = 0.;
	int iArm(0);
	for(int iem=1; iem<=NSC; iem++)
		for(int ire=1; ire<=NSC; ire++)
			if(iem!=ire)
				ArmStore[iArm++] = ArmCompute(iem, ire, 0.0);
}