void CMyRng::TestChoices() // TEST CHOICES /////////////////////////////////////////// { printf(" Testing CHOICES ---------------------------------\n"); int x[9]; int numchoice=4+Dice(5); double chance[9]; int i; double sum=0; for (i=0;i<numchoice;i++) { x[i]=0; chance[i]=Uniform01()+sum; sum+=chance[i]; } for (i=0;i<numchoice;i++) { chance[i]/=sum; } long t1=time(0); for (i=0;i<1e7;i++) { int q=Choices(chance); x[q]++; } long t2=time(0); for (i=0;i<numchoice;i++) { printf(" Choice %d (%3.1lf%%): %3.1lf%% [%3.1lf%%]\n",i, 100.0*chance[i],((double)x[i]/1e7)*100.0,100.0*chance[i]); } printf(" Time: %lds\n",t2-t1); printf("\n"); }
void GameEventManager::PlayEvent(Player * pPlayer,Cell*Room[20][20]) { if(*m_pEventPosition !=0 && Room[GetRow()][GetColumn()] !=NULL) { Room[GetRow()][GetColumn()]->Reset(); //Resets the Cell the event is in } switch(GetEvent()) { //Floor 1 case 0: GameStart(pPlayer); *m_pEventPosition=+1; break; case 1: FirstRadioContact(pPlayer); CreateNextEvent(Room); break; case 2: FindTheKey(pPlayer); CreateNextEvent(Room); break; case 3: GoToElevator(pPlayer); //There is no create here because this is the end of the room, the next room will deal with continuing it on *m_pEventPosition+=1; //So the next event will be loaded *m_pRoom1Clear = true; break; //Floor 2 case 4: YouFoundTheGenerator(pPlayer); CreateNextEvent(Room); break; case 5: FindGasoline(pPlayer); CreateNextEvent(Room); break; case 6: FindTools(pPlayer); CreateNextEvent(Room); break; case 7: FindKey(pPlayer); CreateNextEvent(Room); break; case 8: UnderAttack(pPlayer); *m_pEventPosition+=1; //So the next event will be loaded (since the Create new isnt called) *m_pRoom2Clear = true; break; case 9: GetThroughTheDoor(); *m_pEventPosition+=1; break; //Floor 3 case 10: DarkRevelations(pPlayer); CreateNextEvent(Room); break; case 11: Choices(pPlayer); break; } }