Exemple #1
0
void findK()
{
	const int iters=100000, nSteps=100000;
	CDynArray<double> ak(iters);
	CBBSimulator bb(nSteps);
	for(int i=0;i<iters;i++)
	{
		bb.simulate();
		ak[i] = bb.getk();
	}
	std::ofstream kfile("kfile.tsv");
	
	const bool bOutputAll = false;
	if(bOutputAll)
	{
		std::sort(ak.begin(), ak.end());
		ak.pp("\n", kfile);
	}
	else
	{
		double dMean, dVar;
		ak.getMeanVar(dMean, dVar);
		kfile << dMean << endl;
		kfile << dVar << endl;
	}
	
	kfile.close();



}
Exemple #2
0
 /**
  * @brief Provide a list of all the kernels found
  * 
  * This method will return all the kernel file references as found in the ISIS
  * label.  It will optionally remove the file paths and return only the kernel
  * file name if requested.  If removePath is false, it returns the complete
  * path to the SPICE kernels.
  * 
  * @param removePath Do we remove the file paths and return only the file
  *                   names?
  * 
  * @return std::vector<std::string> A vector of filenames of SPICE kernels
  */
 Kernels::KernelFiles Kernels::getList(bool removePath) const {
     KernelFiles flist;
     for (unsigned int i = 0 ; i < _kernels.size() ; i++) {
       KernelFiles kfiles = _kernels[i].getNames();
       for (unsigned int k = 0 ; k < kfiles.size() ; k++) {
         if (removePath) {
             Filename kfile(kfiles[k]);
             flist.push_back(kfile.Name());
         }
         else {
             flist.push_back(kfiles[k]);
         }
       }
     }
     return (flist);
 }
Exemple #3
0
// Saves the players options...
void Ultra1::App::PlayerOptions::Save( )
{
  	std::string home;
#ifdef WIN32
	home = getenv("USERPROFILE");
#else
	home = getenv("HOME");
#endif
	std::fstream ffile((home + "/.ultrabear1/config/screen.dat").c_str( ), std::ios::out );
  if(!ffile.is_open( )) throw Sim::Exception("Save", "Could not write to screen file");
	if( fullscreen )
		ffile << 1 << std::endl;
	else
		ffile << 0 << std::endl;
	ffile.close( );

	std::fstream sfile((home + "/.ultrabear1/config/sound.dat").c_str( ), std::ios::out );
  if(!sfile.is_open( )) throw Sim::Exception("Save", "Could not write to sound file");
	if( sound )
		sfile << 1 << std::endl;
	else
		sfile << 0 << std::endl;
	if( music )
		sfile << 1 << std::endl;
	else
		sfile << 0 << std::endl;
	sfile.close( );

	std::fstream kfile((home + "/.ultrabear1/config/keys.dat").c_str( ), std::ios::out );
  if(!kfile.is_open( )) throw Sim::Exception("Save", "Could not write to keys file");
	kfile << left << std::endl;
	kfile << right << std::endl;
	kfile << up << std::endl;
	kfile << down << std::endl;
	kfile << jump << std::endl;
	kfile << 0 << std::endl;
	kfile << pause << std::endl;
	kfile.close( );

}
Exemple #4
0
Ultra1::App::App(bool fullscreen) : Sim::App(WIDTH, HEIGHT, fullscreen, "Ultra Bear 1", UBD_PREFIX "/images/icon.png") ,
                                                  sound_player(NUM_SOUNDS, NUM_MUSICS), text_writer(NUM_FONTS)
{
	// The order in which fonts and sounds are added matters!
	// They must coincide with the order in Constants.h!
	text_writer.AddFont( UBD_PREFIX "/fonts/FreeSans.ttf", 14 );
	text_writer.AddFont( UBD_PREFIX "/fonts/galapogo.ttf", 36 );
	text_writer.AddFont( UBD_PREFIX "/fonts/galapogo.ttf", 72 );
	text_writer.AddFont( UBD_PREFIX "/fonts/galapogo.ttf", 24 );

	// Add the filenames of our sound and music files
	sound_player.AddMusic( UBD_PREFIX "/music/1.ogg" );
	sound_player.AddMusic( UBD_PREFIX "/music/2.ogg" );
	sound_player.AddMusic( UBD_PREFIX "/music/3.ogg" );
	sound_player.AddMusic( UBD_PREFIX "/music/4.ogg" );
	sound_player.AddMusic( UBD_PREFIX "/music/5.ogg" );

	sound_player.AddSound( UBD_PREFIX "/sounds/button.wav" );
	sound_player.AddSound( UBD_PREFIX "/sounds/force.wav" );
	sound_player.AddSound( UBD_PREFIX "/sounds/jump.wav" );
	sound_player.AddSound( UBD_PREFIX "/sounds/coin.wav" );
	sound_player.AddSound( UBD_PREFIX "/sounds/armor.wav" );
	sound_player.AddSound( UBD_PREFIX "/sounds/kill.wav" );
	sound_player.AddSound( UBD_PREFIX "/sounds/die.wav" );
	sound_player.AddSound( UBD_PREFIX "/sounds/finish.wav" );
	sound_player.AddSound( UBD_PREFIX "/sounds/life.wav" );

	// We always want SDL to repeat keys...
	SDL_EnableKeyRepeat( SDL_DEFAULT_REPEAT_INTERVAL, SDL_DEFAULT_REPEAT_INTERVAL );

	stats.lives = 5;
	stats.coins = 0;
	stats.points = 0;
	stats.current_map = 1;
	stats.current_level = 1;
	stats.back_up = false;
	stats.stay = false;
	stats.moveon = false;
	stats.curr_level_next = 1;

	// We open the sound file to load previous sound/music settings...
	std::string home;
#ifdef WIN32
	home = getenv("USERPROFILE");
#else
	home = getenv("HOME");
#endif
  std::fstream file((home + "/.ultrabear1/config/sound.dat").c_str( ), std::ios::in );
	if(!file.is_open()) throw Sim::Exception("App constructor", "could not load sound preferences");
  int s, m;
	file >> s;
	file >> m;
	options.sound = (s == 1) ? true : false;
	options.music = (m == 1) ? true : false;
	file.close( );

	// We open the keys file to lad previous key configurations...
	std::fstream kfile((home + "/.ultrabear1/config/keys.dat").c_str( ), std::ios::in );
	if(!kfile.is_open()) throw Sim::Exception("App constructor", "could not load key preferences");
	int temp;
	kfile >> temp;
	options.left = (SDLKey)temp;
	kfile >> temp;
	options.right = (SDLKey)temp;
	kfile >> temp;
	options.up = (SDLKey)temp;
	kfile >> temp;
	options.down = (SDLKey)temp;
	kfile >> temp;
	options.jump = (SDLKey)temp;
	kfile >> temp;
	SDLKey dummy;
  dummy = (SDLKey)temp;  // we used to have a "dash" key, but it was worthless
	kfile >> temp;
	options.pause = (SDLKey)temp;
	kfile.close( );

	options.fullscreen = full = fullscreen;
	LoadAllSounds( );

	sound_player.SetMusicVolume( 80 );
}