Example #1
0
int main ( int argc , char** argv ) {
	double start, end;

	// get cmdline args
	std::string input_file = argv[1];
	std::string output_file = argv[2];
	int num_steps = atoi( argv[3] );

	// check for valid input file
	if ( !utils::fexists( input_file ) ) { 
		printf( "Error: Input file does not exist.\n" );
		return 1;
	}

	// initialize adjacency list vector hash
	printf( "Loading network edges from %s\n", input_file.c_str() );
	start = omp_get_wtime();
	load_network( input_file );
	end = omp_get_wtime();
	printf( "Time to read input file = %lf seconds\n", end - start );
	
	// compute the normalized credit after numSteps
	printf("\nComputing the Credit Values for %d Rounds:\n", num_steps);
	CreditVec C( nodevec.size(), 1 ); // initialize credit at t=0 to 1 for each node
	CreditVec C_( nodevec.size(), 0 );
	std::vector<CreditVec> updates( num_steps );

	for (int i=0; i<num_steps; ++i) {
		printf("round %d = ", i+1);

		start = omp_get_wtime();
		credit_update(C, C_);
		end = omp_get_wtime();
		printf( "%f seconds\n", end - start );

		// store credit update before overwriting timestep t
		updates[i] = C_;

		C = C_; // C(t+1) becomes C(t) for next iteration
	}

	// output credit value results after the final step
	printf( "\nOutputting Network and Random Walk Data to %s\n", output_file.c_str() );
	write_output( output_file, updates );

	// free heap memory
	for ( auto& node: nodevec ) {
		delete node;
	}

	return 0 ;
}
Example #2
0
/* update local objects (shrapnells,extras,explosions...) and communicate
 * every client_comm_delay seconds either with real or fake server */
static void update_game( int ms )
{
	int i;
	
	/* run the fake server game */
	if ( game->game_type == GT_LOCAL ) {
		game_set_current( local_game );
		game_update( ms );
		game_set_current( game );
	}
		
	/* local animations and movements */
	for ( i = 0; i < game->paddle_count; i++ )
		client_paddle_update( game->paddles[i], ms );
	client_shots_update( ms );
	client_balls_update( ms );
	client_extras_update( ms );
	client_walls_update( ms );
	shrapnells_update( ms );
	frame_warp_icon_update( ms );
	shine_update( ms );
	exps_update( ms );
	displays_update( ms );
	credit_update( ms );

	/* communicate */
	if ( (no_comm_since+=ms) >= client_comm_delay ) {
		no_comm_since -= client_comm_delay;

		/* send paddle state */
		comm_send_paddle( l_paddle );
	
		/* receive game data from local or remote server and 
		 * apply it to the game context. */
		comm_recv();
		
		/* update score displays */
		if (!showing_best)
		  display_set_value( 
			  display_score[0], 
			  game->paddles[0]->player->stats.total_score + 
			  game->paddles[0]->score );
		if ( game->game_type == GT_NETWORK )
			display_set_value( 
				display_score[1], 
				game->paddles[1]->player->stats.total_score + 
				game->paddles[1]->score );

        /* update bonus level information */
        if (bl_display) update_bonus_level_display();
	}
}