Exemple #1
0
glm::vec3 AudioReflector::getFaceNormal(BoxFace face) {
    // Menu::getInstance()->isOptionChecked(MenuOption::AudioSpatialProcessingSlightlyRandomSurfaces);
    bool wantSlightRandomness = true;
    glm::vec3 faceNormal;
    const float MIN_RANDOM_LENGTH = 0.99f;
    const float MAX_RANDOM_LENGTH = 1.0f;
    const float NON_RANDOM_LENGTH = 1.0f;
    float normalLength = wantSlightRandomness ? randFloatInRange(MIN_RANDOM_LENGTH, MAX_RANDOM_LENGTH) : NON_RANDOM_LENGTH;
    float remainder = (1.0f - normalLength)/2.0f;
    float remainderSignA = randomSign();
    float remainderSignB = randomSign();

    if (face == MIN_X_FACE) {
        faceNormal = glm::vec3(-normalLength, remainder * remainderSignA, remainder * remainderSignB);
    } else if (face == MAX_X_FACE) {
        faceNormal = glm::vec3(normalLength, remainder * remainderSignA, remainder * remainderSignB);
    } else if (face == MIN_Y_FACE) {
        faceNormal = glm::vec3(remainder * remainderSignA, -normalLength, remainder * remainderSignB);
    } else if (face == MAX_Y_FACE) {
        faceNormal = glm::vec3(remainder * remainderSignA, normalLength, remainder * remainderSignB);
    } else if (face == MIN_Z_FACE) {
        faceNormal = glm::vec3(remainder * remainderSignA, remainder * remainderSignB, -normalLength);
    } else if (face == MAX_Z_FACE) {
        faceNormal = glm::vec3(remainder * remainderSignA, remainder * remainderSignB, normalLength);
    }
    return faceNormal;
}
Exemple #2
0
double joeGames(GameType type,long gamesCount)
{
	Player firstPlayer;
	Player secondPlayer;

	int firstWinsCounter = 0;
	int secondWinsCounter = 0;

	if(type!=SWITCH)									//	If it's not a switch game
		firstPlayer = (type==JOE_FIRST ? JOE : SID);		//	... first player is chosen, depending on the game type
	else
		firstPlayer = randomSign() < 0 ? JOE : SID;		//	Otherwise the first player is chosen via a coin toss
	
	secondPlayer = (firstPlayer==JOE ? SID : JOE);		//	Second player is chosen, based on the first player choice

	for(long tr = 0;tr<gamesCount;tr++)						//	Going over the games
	{
		int firstPlay  = play(firstPlayer);						//	First player plays by himself
		int secondPlay = play(secondPlayer);					//	Second player plays by himself

		if(firstPlay<=secondPlay)								//	If the first player won faster than the second player ...
		{
			firstWinsCounter++;											// ... increase wins count

			if(type==SWITCH)									//	If it's a switch game
			{
				swap(firstPlayer,secondPlayer);						//	Players swap
				swap(firstWinsCounter,secondWinsCounter);							//	and keep their wins counts
			}

		}
		else
		{
			secondWinsCounter++;										//	Otherwise second player wins
		}

	}

	if(firstPlayer==JOE)										//	Return Joe's statistics
		return (double)firstWinsCounter*100/(gamesCount);
	else
		return (double)secondWinsCounter*100/(gamesCount);
}