예제 #1
0
    void SwitchWeapons()
    {
        switch ( GetPhase() )
        {
        case 1: // Phase 1 (Default)
			SetDisplayWeaponIds( 5192, 0 );
			_unit->SetUInt32Value( UNIT_FIELD_BASEATTACKTIME, _unit->GetUInt32Value( UNIT_FIELD_BASEATTACKTIME ) );	// 1483 is taken from NCDB creature_proto
			break;
        case 2: // Phase 2
			SetDisplayWeaponIds( 5196, 5196 );
			_unit->SetUInt32Value( UNIT_FIELD_BASEATTACKTIME, _unit->GetUInt32Value( UNIT_FIELD_BASEATTACKTIME ) / 2 );
			break;
        case 4: // Phase 4
			// Is base attack time change needed if we use aura ?
			SetDisplayWeaponIds( 7230, 0 );
			_unit->SetUInt32Value( UNIT_FIELD_BASEATTACKTIME, _unit->GetUInt32Value( UNIT_FIELD_BASEATTACKTIME ) * 2 );
			ApplyAura( SMITES_HAMMER );
			break;
        };

		// Wait at the chest for 4.5seconds -- Still needs work
		_unit->setAttackTimer( 4500, false );
		mWaitAtChest = AddTimer( 4500 );
		SetPhase( GetPhase() + 1 );
    };
예제 #2
0
	/*
		At <= 50% He will spawn 2 Defias Blackguards
		ToDo: Make them despawn WHEN he dies, also make them unlootable
	*/
	void AIUpdate()
	{
		if(GetHealthPercent() <= 75 && GetPhase() == 1)
		{
			Emote("Lap dogs, all of you.", Text_Yell, 5782);
			SetPhase(2);
		}
		else if(GetHealthPercent() <= 50 && GetPhase() == 2)
		{
			Emote("Fools! Our cause is righteous.", Text_Yell, 5783);
			// Defias Blackguard x 2
			MoonScriptCreatureAI* Guard = NULL;
			for(int x=0; x<2; x++)
			{
				Guard = SpawnCreature(636);
				if(Guard == NULL)
					continue;
				Guard->SetDespawnWhenInactive(true);
				Guard->GetUnit()->m_noRespawn = true;
				Guard = NULL;
			}
			SetPhase(3);
		}
		else if(GetHealthPercent() <= 25 && GetPhase() == 3)
		{
			Emote("The brotherhood shall remain.", Text_Yell, 5784);
			SetPhase(4);
		}
		ParentClass::AIUpdate();
	}
예제 #3
0
        void AIUpdate()
        {
            if (GetHealthPercent() <= 66 && GetPhase() == 1)
            {
                Emote("You landlubbers are tougher than I thought. I'll have to improvise!", Text_Yell, 5778);
                SetPhase(2, mStomp);
            }
            else if (GetHealthPercent() <= 33 && GetPhase() == 3)
            {
                Emote("D'ah! Now you're making me angry!", Text_Yell, 5779);
                SetPhase(4, mStomp);
            }

            if (GetPhase() == 2 || GetPhase() == 4)
            {
                if (NearChest())
                    SwitchWeapons();
                else if (_unit->GetAIInterface()->getAIState() != STATE_SCRIPTMOVE)
                {
                    MoveToChest();
                }
            }

            if (IsTimerFinished(mWaitAtChest))
                MoveToPlayer();

            ParentClass::AIUpdate();
        }
예제 #4
0
	void AIUpdate()
	{
		if(SpawnTimer && IsTimerFinished(SpawnTimer))
		{
			switch(GetPhase())
			{
				case 2: Moccasin(); ResetTimer(SpawnTimer,100000); SetPhase(3); break;
				case 3: Ectoplasm(); ResetTimer(SpawnTimer,100000); SetPhase(4); break;
				case 4: BMutanus(); ResetTimer(SpawnTimer,100000); SetPhase(5); break;
			}
		}
		if(GetPhase() == 5 && (!Mutanus || !Mutanus->GetUnit()->isAlive()))
		{
			MoonScriptCreatureAI* Naralex = GetNearestCreature(3679);
			if(Naralex && Naralex->IsAlive())
			{
				SetDisplayId(17089);
				Naralex->SetDisplayId(17089);
				Naralex->Emote("I am awake... at last", Text_Say, 5789);
				Naralex->GetUnit()->SetStandState(STANDSTATE_STAND);
				SetFlyMode(true);
				Naralex->SetFlyMode(true);
				MoveTo(-6.704030f, 200.308838f, -26.938824f);
				Naralex->MoveTo(-6.704030f, 200.308838f, -26.938824f);
			}
			SetPhase(6);
		}
		ParentClass::AIUpdate();
	}
bool FilterThreeWordsPhase::Filter(vector<NameProfile>& nameprofiles)
{
	bool isok = false;
	vector<NameProfile> Outnameprofiles;
    try{
		vector<NameProfile>::iterator iter = nameprofiles.begin();
		for(iter = nameprofiles.begin(); iter != nameprofiles.end() ; ++iter){
			bool bNeedAdd = false;
			int nsky = 1 + iter->Get_lastname_num();
			int npeople = iter->Get_lastname_num() + iter->Get_name1_num();
			int nearth = iter->Get_name1_num() + iter->Get_name2_num();			
			
			int phasesky = GetPhase((nsky%10));
			int phasepeople = GetPhase((npeople%10));
			int phaseearth = GetPhase((nearth%10));

			bool bsky_people = IsAdjacent(phasesky,phasepeople);
			bool bpeople_earth = IsAdjacent(phasepeople,phaseearth);

			if(true==bsky_people && true==bpeople_earth){							
				// Add to new vector
				Outnameprofiles.push_back(*iter);				
			}						
		}
		nameprofiles.clear();
		nameprofiles = Outnameprofiles;
        isok = true;
    }
    catch(...){
    }
    return isok;
}
예제 #6
0
    void AIUpdate()
    {
        if (GetHealthPercent() <= 75 && GetPhase() == 1)
        {
            _unit->SendScriptTextChatMessage(7723);     // Lapdogs, all of you!
            SetPhase(2);
        }
        else if (GetHealthPercent() <= 50 && GetPhase() == 2)
        {
            _unit->SendScriptTextChatMessage(7725);     // Fools! Our cause is righteous!

            for (int x = 0; x < 2; x++)
            {
                MoonScriptCreatureAI* Guard = SpawnCreature(636);
                if (Guard != NULL)
                {
                    Guard->SetDespawnWhenInactive(true);
                    Guard->GetUnit()->m_noRespawn = true;
                }
            }

            SetPhase(3);

        }
        else if (GetHealthPercent() <= 25 && GetPhase() == 3)
        {
            _unit->SendScriptTextChatMessage(7727);     // The Brotherhood shall prevail!
            SetPhase(4);
        }
        ParentClass::AIUpdate();
    }
예제 #7
0
	void AIUpdate()
	{
        ParentClass::AIUpdate();

		// Bear Form
		if(IsTimerFinished(MorphTimer) && GetPhase() == 1)
		{
			SetPhase(2, Morph);
			// Morph into a bear since the spell doesnt work
			SetDisplayId(21635);
			// 20 Seconds until switch to Troll Form
			ResetTimer(MorphTimer, 20000);
		}
		
		// Troll Form
		else if(IsTimerFinished(MorphTimer) && GetPhase() == 2)
		{
			// Remove Bear Form
			RemoveAura(42377);
			// Transform back into a Troll
			SetDisplayId(21631);
			SetPhase(1);
			// 45 Seconds until switch to Bear Form
			ResetTimer(MorphTimer, 45000);

			Emote("Make way for Nalorakk!", Text_Yell, 12073);
		}
	}
예제 #8
0
        void SwitchWeapons()
        {
            // CREDITS to Skyboat on ascentemu.com/forums  he had some of this info on one of his releases
            switch (GetPhase())
            {
                case 1: // Phase 1 (Default)
                    SetDisplayWeaponIds(5192, 0);
                    _unit->SetBaseAttackTime(MELEE, _unit->GetBaseAttackTime(MELEE));    // 1483 is taken from NCDB creature_proto
                    break;
                case 2: // Phase 2
                    SetDisplayWeaponIds(5196, 5196);
                    _unit->SetBaseAttackTime(MELEE, _unit->GetBaseAttackTime(MELEE) / 2);
                    break;
                case 4: // Phase 4
                    // Is base attack time change needed if we use aura ?
                    SetDisplayWeaponIds(7230, 0);
                    _unit->SetBaseAttackTime(MELEE, _unit->GetBaseAttackTime(MELEE) * 2);
                    ApplyAura(SMITES_HAMMER);
                    break;
            }

            // Wait at the chest for 4.5seconds -- Still needs work
            _unit->setAttackTimer(4500, false);
            mWaitAtChest = AddTimer(4500);
            SetPhase(GetPhase() + 1);
        }
예제 #9
0
		void AIUpdate()
		{
			if(GetPhase() == 1 && GetHealthPercent() <= (mPhaseRepeat * 25))
			{
				switch(rand() % 2)
				{
					case 0:
						Emote("I'll give you more than you can handle.", Text_Yell, 13321);
						break;
					case 1:
						Emote("There's plenty of me to go around.", Text_Yell, 13322);
						break;
				}
				SetPhase(2);
				SetCanMove(false);
				SetAllowRanged(false);
				SetAllowSpell(false);
				SetAllowTargeting(false);
				ApplyAura(60191);

				for(int i = 0; i < 3; ++i)
				{
					mAddArray[i] = _unit->GetMapMgr()->GetInterface()->SpawnCreature(CN_TELESTRA_FIRE + i, FormSpawns[i].x, FormSpawns[i].y, FormSpawns[i].z, FormSpawns[i].o, true, true, 0, 0);
					if(mAddArray[i] != NULL)
						++mAddCount;
				}

			};

			if(GetPhase() == 2)
			{
				for(int i = 0; i < 3; ++i)
				{
					if(mAddArray[i] != NULL)
					{
						mAddArray[i]->Despawn(1000, 0);
						mAddArray[i] = NULL;
						--mAddCount;
					}
				}

				if(mAddCount != 0)
					return;

				Emote("Now to finish the job!", Text_Yell, 13323);
				RemoveAura(60191);
				SetCanMove(true);
				mPhaseRepeat = 1;
				SetPhase(mHeroic  ? 1 : 3);   //3 disables p2
			};

			ParentClass::AIUpdate();
		};
	void AIUpdate()
	{
		if( IsTimerFinished( mStanceTimer ) )
		{
			switch ( GetPhase() )
			{
			case STANCE_BATTLE:
				switchStance( RandomUInt( 1 ) + 2 );
				break;
			case STANCE_BERSERKER:
				if( RandomUInt( 1 ) == 1 )
					switchStance( STANCE_BATTLE );
				else
					switchStance( STANCE_DEFENSIVE );
				break;
			case STANCE_DEFENSIVE:
				switchStance( RandomUInt( 1 ) + 1 );
				break;
			};

			
			ResetTimer( mStanceTimer, TIMER_STANCE_CHANGE + ( RandomUInt( 7 ) * 1000 ) );
		};

		ParentClass::AIUpdate();
	};
예제 #11
0
/*
 * Set the game state according to the given JSON
 * game: the game state to set
 * json: a JSON representation of the game state
 */
void SetGameState(GameState *game, cJSON *json)
{
    game->round_id = JSON_INT(json, "round_id");
    game->initial_stack = JSON_INT(json, "initial_stack");
    game->stack = JSON_INT(json, "stack");
    game->current_bet = JSON_INT(json, "current_bet");
    game->call_amount = JSON_INT(json, "call_amount");
    game->phase = GetPhase(JSON_STRING(json, "betting_phase"));
    game->your_turn = JSON_INT(json, "your_turn");

    //Set the AI's list of opponents
    SetGameOpponents(game, JSON(json, "players_at_table"));

    //Update the current pot
    game->current_pot = game->current_bet;
    for (int i = 0; i < game->num_opponents; i++)
    {
        game->current_pot += game->opponents[i].current_bet;
    }

    //Set the AI's hand and the community cards
    game->handsize = GetCardArray(game->hand, JSON(json, "hand"));
    game->communitysize = GetCardArray(game->community, JSON(json, "community_cards"));

    UpdateGameDeck(game);
}
예제 #12
0
파일: Coil.cpp 프로젝트: welcheb/jemris
void Coil::GridMap () {

    double position[3]  = {0.0,0.0,0.0};
    double max = 0.0;

    for (int k=0; k< (m_dim==3?m_points:1); k++) {

        position [ZC] = (m_dim==3?k*m_extent/m_points-m_extent/2:0.0);

        for (int j=0; j<m_points; j++) {

            position [YC] = j*m_extent/m_points-m_extent/2;

            for (int i=0; i<m_points; i++) {

                position [XC] = i*m_extent/m_points-m_extent/2;
                double mag   = m_scale*GetSensitivity(position);
                m_sensmag(i,j,k) = mag;
                max = (max>mag?max:mag);
                m_senspha(i,j,k) = ( (m_conjugate?-1.0:1.0) * ( GetPhase(position) + m_phase) );
                if (m_senspha(i,j,k) != 0.0) m_complex = true;
            }
        }
    }
    m_norm = 1/max;

}
예제 #13
0
	void AIUpdate()
	{
		if(GetHealthPercent() <= 50 && GetPhase() == 1)
		{
			const char * Text = "";
			uint32 pSoundID = 0;
			uint32 Random = rand()%2;
			switch (Random)	
			{
				case 0:
					Text =  "I'll give you more than you can handle.";
					pSoundID = 13321;
					break;
				case 1:
					Text = "There's plenty of me to go around.";
					pSoundID = 13322;
					break;
			}
			
			Emote(Text, Text_Yell, pSoundID);

			SetPhase(2);
			SetCanMove(false);
			ApplyAura(60191);

			pFire = _unit->GetMapMgr()->GetInterface()->SpawnCreature( CN_TELESTRA_FIRE, 494.726990f, 89.128799f, -15.941300f, 6.021390f, true, true, NULL, NULL );
			pFrost = _unit->GetMapMgr()->GetInterface()->SpawnCreature( CN_TELESTRA_FROST, 495.006012f, 89.328102f, -16.124609f, 0.027486f, true, true, NULL, NULL );
			pArcane = _unit->GetMapMgr()->GetInterface()->SpawnCreature( CN_TELESTRA_ARCANE, 504.798431f, 102.248375f, -16.124609f, 4.629921f, true, true, NULL, NULL );
		};

		if( GetPhase() == 2 )
		{
			if( ( pFrost != NULL && pFrost->isAlive() ) || ( pFire != NULL && pFire->isAlive() ) || ( pArcane != NULL && pArcane->isAlive() ) )
				return;

			Emote("Now to finish the job!", Text_Yell, 13323);
			RemoveAura(60191);
			SetCanMove(true);
			SetPhase(3);
		};

		ParentClass::AIUpdate();
	};
	void OnDied(Unit* pKiller)
	{
		if( _unit->GetHealthPct() <= 0 && GetPhase() == 1)
		{
			_unit->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
			//_unit->GetMapMgr()->GetInterface()->SpawnGameObject(ID!!!! , _unit->GetPositionX(), _unit->GetPositionY(), _unit->GetPositionZ(), 0); 
			
			Emote("My life for the... death god!", Text_Yell, 13213);
			mRessTimer = AddTimer(4000); // 23000 will be after i get ID informations and add that ress event
			
		}
		
		if( _unit->GetHealthPct() <= 0 && GetPhase() == 2)
		{
			Emote("No! I can do... better! I can...", Text_Yell, 13211);
		}
		
		
	}
예제 #15
0
	void OnReachWP(uint32 iWaypointId, bool bForwards)
    {
		ForceWaypointMove(iWaypointId+1);
		if(GetPhase() == 1 && GetCurrentWaypoint() == 39)		
		{
			_unit->Emote(EMOTE_ONESHOT_TALK);
			SetPhase(2, Awakening);
			SpawnTimer = AddTimer(100000);
		}
		ParentClass::OnReachWP(iWaypointId, bForwards);
	}
예제 #16
0
 void AIUpdate()
 {
     if(GetHealthPercent() <= 75 && GetPhase() == 1)
     {
         SetPhase(2, HowlingRage1);
     }
     else if(GetHealthPercent() <= 45 && GetPhase() == 2)
     {
         if(GetUnit()->HasAura(7481))
             RemoveAura(7481);
         SetPhase(3, HowlingRage2);
     }
     else if(GetHealthPercent() <= 20 && GetPhase() == 3)
     {
         if(GetUnit()->HasAura(7483))
             RemoveAura(7483);
         SetPhase(4, HowlingRage3);
     }
     ParentClass::AIUpdate();
 }
예제 #17
0
	void AIUpdate()
	{
		if(!Elite1->isAlive() && !Elite2->isAlive() && !Elite3->isAlive() && !Elite4->isAlive() &&
		!Healer1->isAlive() && !Healer2->isAlive() && !Healer3->isAlive() && !Healer4->isAlive() && GetPhase() == 1)
		{
			SetCanEnterCombat(false);
			SetAllowMelee(false);
			SetAllowRanged(false);
			SetAllowSpell(false);
			SetAllowTargeting(false);
			SetCanMove(false);
			RemoveAllAuras();
			_unit->SetUInt64Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_9);		
			Emote("Impossible! Stay your attack, mortal... I submit! I submit!", Text_Yell, 8045);
			SetPhase(2);
			DomoSayTimer1 = AddTimer(7000);
			DomoSayTimer2 = AddTimer(16000);
			DomoTeleportTimer3 = AddTimer(34000);
		}
		
		if(GetPhase() == 2 && IsTimerFinished(DomoSayTimer1))
		{
			Emote("Brashly, you have come to rest the secrets of the Living Flame! You will soon regret the recklessness of your quest", Text_Yell, NULL);
			RemoveTimer(DomoSayTimer1);
		}
		
		if(GetPhase() == 2 && IsTimerFinished(DomoSayTimer2))
		{
			Emote("I go now to summon the lord whose house this is. Should you seek an audience with him, your paltry lives will surely be forfeit! Nevertheless, seek out his lair, if you dare!", Text_Yell, NULL);
			RemoveTimer(DomoSayTimer2);
		}
		
		if(GetPhase() == 2 && IsTimerFinished(DomoTeleportTimer3))
		{
			_unit->SetPosition(838.719971f, -830.810974f, -232.095001f, 2.870590f);
			RemoveTimer(DomoTeleportTimer3);
		}
		
			
		ParentClass::AIUpdate();
	}
예제 #18
0
		void AIUpdate()
		{
			// Every 25% Halazzi calls on the lynx
			if(!mLynx && GetHealthPercent() <= (100 - SplitCount * 25))
				Split();

			// Lynx OR Halazzi is at 20% HP Merge them together again
			if(mLynx && (mLynx->GetHealthPct() <= 20 || GetHealthPercent() <= 20))
				Merge();

			// At <25% Phase 3 begins
			if(GetHealthPercent() < 25 && GetPhase() == 1)
			{
				ResetTimer(mTotemTimer, 30000);
				SetPhase(3);
			}

			if(GetPhase() == 2 || GetPhase() == 3)
			{
				if(IsTimerFinished(mTotemTimer))
				{
					MoonScriptCreatureAI* Totem = NULL;
					Totem = SpawnCreature(CN_TOTEM, (_unit->GetPositionX() + RandomFloat(3) - 3), (_unit->GetPositionY() + RandomFloat(3) - 3), _unit->GetPositionZ(), 0, true);
					if(Totem)
					{
						Totem->Despawn(60000); // Despawn in 60 seconds
						Totem->AggroNearestPlayer();
						Totem = NULL;
					}
					switch(GetPhase())
					{
						case 2:
							ResetTimer(mTotemTimer, 60000);
							break;
						case 3:
							ResetTimer(mTotemTimer, 30000);
							break; // Spawn them faster then phase 2
					}
				}
			}
		}
예제 #19
0
	void AIUpdate()
	{
		if (mAliveAdds > 1)
			return;

		if (GetPhase() == 1 && GetHealthPercent() <= 50)
		{
			SetPhase(2, mEnrage);
		}

		ParentClass::AIUpdate();
	}
예제 #20
0
        void OnCombatStop(Unit* pTarget)
        {
            if (GetPhase() == 4)
                RemoveAura(SMITES_HAMMER);
            if (!IsAlive())
                SetWieldWeapon(false);

            SetPhase(1);
            SwitchWeapons();
            RemoveTimer(mWaitAtChest);
            ParentClass::OnCombatStop(pTarget);
        }
예제 #21
0
	void phaseTester()
	{

		_unit->Root();
		GetAllowMelee();
		SetBehavior(Behavior_Spell);

		if ((HandOfTheDeceiver1 && HandOfTheDeceiver2 && HandOfTheDeceiver3) && (HandOfTheDeceiver1->isDead() && HandOfTheDeceiver2->isDead() && HandOfTheDeceiver3->isDead()) && (GetPhase() != 1) && (GetPhase() != 2) && (starter == 0))
		{
			_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, SAY_KJ_EMERGE);
			_unit->PlaySoundToSet(SOUND_KJ_EMERGE);
			RemoveAura(42866);
			_unit->m_invisible = false;
			starter = 1;
		}

		switch(GetPhase())
		{
		case 1:
			{
				if(GetHealthPercent()<=85 && phase == 2)
				{
					_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, SAY_KJ_PHASE3);
					_unit->PlaySoundToSet(SOUND_KJ_PHASE3);
					AddPhaseSpell(1, AddSpell(SPELL_SINISTER_REFLECTION, Target_RandomPlayer, 10, 1.5f, 4, 0, 35));
					AddPhaseSpell(1, AddSpell(SPELL_SHADOW_SPIKE, Target_RandomDestination, 10, 2.0f, 6, 0, 35));
					AddPhaseSpell(1, AddSpell(SPELL_FLAME_DART, Target_RandomPlayer, 10, 1.3f, 4, 0, 35));
					ShieldOrb2 = _unit->GetMapMgr()->GetInterface()->SpawnCreature(CN_SHIELD_ORB, 1712.00f, 604.00f, 48.00f, 0.00f, true, true, 0, 0);
					phase++;
				}

				if(GetHealthPercent()<=55 && phase == 3)
				{
					_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, SAY_KJ_PHASE4);
					_unit->PlaySoundToSet(SOUND_KJ_PHASE4);
					ShieldOrb3 = _unit->GetMapMgr()->GetInterface()->SpawnCreature(CN_SHIELD_ORB, 1684.00f, 651.00f, 48.00f, 0.00f, true, true, 0, 0);
					dtimmer = 0;
					phase++;
				}

				if(GetHealthPercent()<=25 && phase == 4 && (dtimmer > 54 || dtimmer == 0))
				{
					_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, SAY_KJ_PHASE5);
					_unit->PlaySoundToSet(SOUND_KJ_PHASE5);
					ShieldOrb4 = _unit->GetMapMgr()->GetInterface()->SpawnCreature(CN_SHIELD_ORB, 1720.00f, 642.00f, 48.00f, 0.00f, true, true, 0, 0);
					CastSpellOnTarget(_unit, Target_Self, dbcSpell.LookupEntry(SPELL_SACRIFICE_OF_ANVEENA), true);
					dtimmer = 0;
					phase++;
				}
			}break;
		}
	}
예제 #22
0
	void AIUpdate()
	{
		// 40 yrds
		if((CoreRager1 && CoreRager1->isAlive() && GetRangeToUnit(CoreRager1) < 40) || (CoreRager2 && CoreRager2->isAlive() && GetRangeToUnit(CoreRager2) < 40))
			GolemaggTrust->mEnabled = true;
		else
			GolemaggTrust->mEnabled = false;

		if(GetPhase() == 1 && GetHealthPercent() <= 10)
			SetPhase(2);

		ParentClass::AIUpdate();
	}
예제 #23
0
파일: const.cpp 프로젝트: briedel/SQuIDS
std::unique_ptr<gsl_matrix_complex,void (*)(gsl_matrix_complex*)> Const::GetTransformationMatrix(size_t dim) const{
  if(dim>SQUIDS_MAX_HILBERT_DIM)
    throw std::runtime_error("Const::GetTransformationMatrix: dimension must be less than " SQUIDS_MAX_HILBERT_DIM_STR);
  
  gsl_matrix_complex* U = gsl_matrix_complex_alloc(dim,dim);
  gsl_matrix_complex* R = gsl_matrix_complex_alloc(dim,dim);
  gsl_matrix_complex* dummy = gsl_matrix_complex_alloc(dim,dim);
  gsl_matrix_complex_set_identity(U);
  gsl_matrix_complex_set_identity(R);
  gsl_matrix_complex_set_zero(dummy);
  
  const auto unit=gsl_complex_rect(1,0);
  const auto zero=gsl_complex_rect(0,0);
  auto to_gsl=[](const std::complex<double>& c)->gsl_complex{
    return(gsl_complex_rect(c.real(),c.imag()));
  };
  
  //construct each subspace rotation and accumulate the product
  for(size_t j=1; j<dim; j++){
    for(size_t i=0; i<j; i++){
      //set up the subspace rotation
      double theta=GetMixingAngle(i,j);
      double delta=GetPhase(i,j);
      double c=cos(theta);
      auto cp=sin(theta)*std::exp(std::complex<double>(0,-delta));
      auto cpc=-std::conj(cp);
      gsl_matrix_complex_set(R,i,i,to_gsl(c));
      gsl_matrix_complex_set(R,i,j,to_gsl(cp));
      gsl_matrix_complex_set(R,j,i,to_gsl(cpc));
      gsl_matrix_complex_set(R,j,j,to_gsl(c));
      
      //multiply this rotation onto the product from the left
      gsl_blas_zgemm(CblasNoTrans,CblasNoTrans,unit,R,U,zero,dummy);
      std::swap(U,dummy);
      
      //clean up the rotation matrix for next iteration
      gsl_matrix_complex_set(R,i,i,unit);
      gsl_matrix_complex_set(R,i,j,zero);
      gsl_matrix_complex_set(R,j,i,zero);
      gsl_matrix_complex_set(R,j,j,unit);
    }
  }
  
  //clean up temporary matrices
  gsl_matrix_complex_free(R);
  gsl_matrix_complex_free(dummy);

  return std::unique_ptr<gsl_matrix_complex,void (*)(gsl_matrix_complex*)>(U,gsl_matrix_complex_free);
}
예제 #24
0
파일: Coil.cpp 프로젝트: welcheb/jemris
double  Coil::GetPhase (const double time) {

    if (!m_complex) return m_phase;

    double position[3];
    position[0]=World::instance()->Values[XC];
    position[1]=World::instance()->Values[YC];
    position[2]=World::instance()->Values[ZC];
    DynamicVariables* dv = DynamicVariables::instance();
    dv->m_Motion->GetValue(time,position);

    if (m_interpolate)
		return ( InterpolateSensitivity(position,false));
	else
		return ( GetPhase(position));

}
예제 #25
0
		void AIUpdate()
		{
			if((GetHealthPercent() <= 85  && mSummon == 0) ||
			        (GetHealthPercent() <= 70 && mSummon == 1) ||
			        (GetHealthPercent() <= 55 && mSummon == 2) ||
			        (GetHealthPercent() <= 40 && mSummon == 3) ||
			        (GetHealthPercent() <= 25 && mSummon == 4))
			{
				CastSpell(mPureEnergy);
				++mSummon;
			}

			if(GetHealthPercent() <= 10 && GetPhase() == 1)
				SetPhase(2);


			ParentClass::AIUpdate();
		}
예제 #26
0
    void AIUpdate()
    {
        if ((GetHealthPercent() <= 85 && mSummon == 0) ||
            (GetHealthPercent() <= 70 && mSummon == 1) ||
            (GetHealthPercent() <= 55 && mSummon == 2) ||
            (GetHealthPercent() <= 40 && mSummon == 3) ||
            (GetHealthPercent() <= 25 && mSummon == 4))
        {
            CastSpell(mPureEnergy);
            ++mSummon;
            //SpawnCreature(CN_PURE_ENERGY, 231, -207, 6, 0, true);
        }

        if (GetHealthPercent() <= 10 && GetPhase() == 1)
            SetPhase(2);


        ParentClass::AIUpdate();
    }
예제 #27
0
void
SetGameStateRiver(GameState *game, stMsg_t stOneMsg)
{
	if (stOneMsg.m_nRowNo < 1) {
		printf("ERROR wrong row number in flop msg! \n");
	}
	
	game->communitysize = 5;
	game->your_turn = 0;
	game->phase_last = game->phase;
	game->phase = GetPhase("river");

	game->call_no = 0;
	game->raise_no = 0;
			
	stMsgRow_t stMsgRow = *(stOneMsg.m_pstMsgRow[0]);
	char card[3] = {'\0'};		
	HoldCardMsgRowToChar3(card, stMsgRow.m_szWordRest[0], stMsgRow.m_szWordRest[1]);
	game->community[5-1] = StringToCard(card);
}
예제 #28
0
float Stop(float V, float dt, float Accel,float KurrPhase,float GivPhase)
{
float StopPhase=V*(1 + V / Accel);
	do
	{
		
		if(GivPhase-KurrPhase>StopPhase||GivPhase-KurrPhase<0)
		{
			//send 1 dt seconds with GetFrequency(V) frequency
		}
		else
		{
			V=GetV(V,dt,-Accel);
			//OCR=GetFrequency(V);//send 1 dt seconds with GetFrequency(V) frequency

		}
		//delayms(dt);
		KurrPhase=GetPhase(KurrPhase,dt,V);
	}while(V>0);
	return 0;
}
예제 #29
0
// set game->hand[0] game->hand[1]
void
SetGameStateHold(GameState *game, stMsg_t stOneMsg)
{
	if (stOneMsg.m_nRowNo < 2) {
		printf("ERROR wrong row number in hold msg! \n");
	}
	
	game->handsize = 2;
	game->your_turn = 0;
	game->phase_last = game->phase;
	game->phase = GetPhase("deal");
	
	game->call_no = 0;
	game->raise_no = 0;
	
	for (int i = 0; i < 2; ++i) {
		stMsgRow_t stMsgRow = *(stOneMsg.m_pstMsgRow[i]);
		char card[3] = {'\0'};		
		HoldCardMsgRowToChar3(card, stMsgRow.m_szWordRest[0], stMsgRow.m_szWordRest[1]);
		game->hand[i] = StringToCard(card);
	}
}
예제 #30
0
void
SetGameStateFlop(GameState *game, stMsg_t stOneMsg)
{
	if (stOneMsg.m_nRowNo < 3) {
		printf("ERROR wrong row number in flop msg! \n");
	}	
	
	game->communitysize = 3;
	game->your_turn = 0;
	game->phase_last = game->phase;
	game->phase = GetPhase("flop");

	game->call_no = 0;
	game->raise_no = 0;
		
	for (int i = 0; i < 3; ++i) {
		stMsgRow_t stMsgRow = *(stOneMsg.m_pstMsgRow[i]);
		char card[3] = {'\0'};		
		HoldCardMsgRowToChar3(card, stMsgRow.m_szWordRest[0], stMsgRow.m_szWordRest[1]);
		game->community[i] = StringToCard(card);
	}
}