Ejemplo n.º 1
0
        void start_new_block()
        {
         //  elog( "-----------------     start_new_block           --------------------" );
           FC_ASSERT( _callback_del != nullptr ); // no point in mining if there is no one to tell when we find the result

           _cur_block.trxs_hash = _cur_block.calc_trxs_hash();

           //uint64_t block_diff = _cur_block.calc_difficulty();
           //name_pow_target = mini_pow_difficulty(min_name_pow);

           auto next_blk = ++_block_ver;

        //  ilog( "wait for complete" );
           for( uint32_t i = 0; i < DEFAULT_MINING_THREADS; ++i )
           {
              if( _mining_complete[i].valid() )
              {
                  _mining_complete[i].wait();
              }
           }
         // ilog( "start next" );

           if( _cur_block.name_hash != 0 )
           {
              for( uint32_t i = 0; i < DEFAULT_MINING_THREADS; ++i )
              {
                 auto b = _cur_block; // create a copy to pass to thread
                 _mining_complete[i] = _threads[i].async( [b,i,this,next_blk](){ start_mining(b,i,next_blk); } );
              }
           }
        }
Ejemplo n.º 2
0
/*
 * Main(): Executes FP Growth algorithm.
 */
int
main(int argc, char **argv)
{

	num_freq_sets = size = colcnt = num_oflines = num_updates = 0;

	/** Create instance of class FPTree */
	fptreePtr fptree;

	/** Read data to be mined from file */
	printf("\nReading Input Data..");
	input_dataset();

	/** Reorder and prune input data according to frequency of single attr */
	printf("\nOrdering Input Data..");
	order_input_data();
	printf("\nRecasting input Data pruning infrequent items");
	recast_data_prune_unsupported();
	printf("\nPrinting frequent-1 itemsets");
	gen_freq_one_itemsets();/** Prints freq-1 itemsets */


    /** Build initial FP-tree */
	printf("\nBuilding FP tree");
	create_fptree(fptree);	/* skip invalid elements(-1) */
	printf("\nPrinting FP tree.");
	out_fptree(fptree);	/* need to print the tree */

	/** Mine FP-tree */
	printf("\nMining FP tree");
	start_mining(fptree);/** frequent sets are generated and stored to file here. */
	printf("\nReleasing memory consumption of tree.");
	out_fptree_storage(fptree->root);
	release_memory(fptree);	/** Frees all used memory */

	return 0;
}
Ejemplo n.º 3
0
int main(int argc, char *argv[]) {
	/*set line buffering of stdout*/
	setvbuf(stdout, NULL, _IOLBF, 0);

	int maxloops;	
	if(argc == 1)
		maxloops = 100;
	else
		maxloops = atoi(argv[1]);
	printf("EVaura activated for %i mining loops\n", maxloops);

	/*Initialize random number generator*/
	point rsult;
	points rsults = {0, NULL};
	gsl_rng_default_seed = time(NULL);
   	r = gsl_rng_alloc (gsl_rng_default);


	current_time = time(NULL);
	int shieldson = 0;
	int randompulse, pulsetimer;
	char number_of_belts = 0;
	char current_belt = 0;
	char is_belt_toast[20] = {0};
	char unable_to_lock = 0;

    display = XOpenDisplay(NULL); // Open first (-best) display
    screen = DefaultScreenOfDisplay(display);
	assert(display);
	
	xdodisplay = xdo_new_with_opened_display (display,":0",1);
	xdo_window_select_with_click(xdodisplay, &EVEwindow);	

	update_screenshot(); //obtain display properties
	initialize_images(); 
	initialize_ore_tables();

	ship *s = &mackinaw;

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

		undock();

		//Warp to belt
		click_on(&menu_belts_inactive, 1, "");
		mysleep(500);

		update_screenshot();
		number_of_belts = find_multiple(&aba_menu, NULL);
		if(number_of_belts < 1){
			printf("No belts found!!!\n Docking!");
			//dock();
			//break;
		}
		else 
			printf("We found %i belts\n", number_of_belts);

		//choose random belt which isn't already depleted
		while((current_belt = random_int(1, number_of_belts)) && 
				is_belt_toast[(int)current_belt] == 1) {
			printf("We chosed %i. belt, but is is empty\n", current_belt);
		}

		if (findmatch(&menu_name, &rsult) == 0){
			click(rsult.X + random_int(0,30), rsult.Y + 19*current_belt, 1, "s");
			printf("Warping to %i. belt\n", current_belt);
		}

		if(random_int(0,3) > 1) {
			start_shields(s);
			shieldson = 1;
		}
		else
			shieldson = 0;
	
		wait_for_warp(s);
		//arrived to belt

		launch_drones(s);

		click_on(&menu_mining_inactive, 1, "");
		mysleep(1500);

		lock_nearest_roid();
		start_mining(&pulsetimer, &randompulse);

		if(shieldson == 0)
			start_shields(s);

		while(1){
			sleep(1);
			update_screenshot();

			if (findmatch(&full_cargo2, NULL) == 0)
				break;

			if (findmatch(&invalid_target, NULL) == 0)
				click_on(&OK, 1, "");

			switch (check_roid_lock()) {
				case 0 :
					unable_to_lock++;
					if(unable_to_lock > 6){
						printf("We were repeatedly unable to lock anything, this belt is probably toast\n");
						//FIXME: this could probably also happen with pirates or roids too far to lock
						is_belt_toast[(int)current_belt] = 1;
						i--;//decrease counter, sice this loop wasnt finished
						goto dock;
					}
					printf("we didnt found any locked roids, attempting to lock one\n");
					if (lock_best_roid() == 0) {	
						start_mining(&pulsetimer, &randompulse);
						unable_to_lock = 0;
					}
					continue;
				case 1 :
					if(find_multiple(&i_mining_laser_active, &rsults) == 0){
						start_mining(&pulsetimer, &randompulse);
					}
					lock_best_roid();
					unable_to_lock = 0;
					continue;
			}

			switch (find_multiple(&i_mining_laser_active, &rsults)) {
				case 0 :
					printf("we have a locked roid however lasers were not active\n");
					start_mining(&pulsetimer, &randompulse);
					continue;
				case 1 :
					xdo_keysequence(xdodisplay, CURRENTWINDOW, "F1", 5);
					//pulse random laser, if we are lucky we turn on the right one
					//if not, we will turn on both next time
					break;
			}

			sleep(2);

			if ( (time(NULL) - pulsetimer) > randompulse ) {
				printf("cycling lasers\n");
				xdo_keysequence(xdodisplay, CURRENTWINDOW, "F1", 5);
				xdo_keysequence(xdodisplay, CURRENTWINDOW, "F2", 5);
				mysleep(1000);
				update_screenshot();
				if (check_roid_lock() == 1) {
					mysleep(50);
					xdo_keysequence(xdodisplay, CURRENTWINDOW, "F1", 5);
					xdo_keysequence(xdodisplay, CURRENTWINDOW, "F2", 5);
					mysleep(random_int(100,300));
				}
				else if(check_roid_lock() > 1 ){
					mouse_move(locked_roids.rsult[0].X, locked_roids.rsult[0].Y);
					xdo_click(xdodisplay, CURRENTWINDOW, 1);
					xdo_keysequence(xdodisplay, CURRENTWINDOW, "F1", 5);
					mysleep(550);
					mouse_move(locked_roids.rsult[1].X, locked_roids.rsult[1].Y);
					xdo_click(xdodisplay, CURRENTWINDOW, 1);
					xdo_keysequence(xdodisplay, CURRENTWINDOW, "F2", 5);
				}

				pulsetimer = time(NULL);
				randompulse = random_int(50,150);
			}
		}

dock:
		dock_drones(s);//we can dock while preparing to warp
		if (click_on(&menu_default_inactive, 1, "") == 0) {
			printf("defalut menu inactive, clicking on it\n");
			mysleep(random_int(800,1200));
		}
		else
			printf("default menu probably active, no need to click\n");

		update_screenshot();
		if(click_on(&aba_peace_station, 1, "d") == 0) {
			printf("found Aba station, attempting a warp\n");
		}
		else 
			printf ("Cant find Aba station, something bad is going on.\n");
	
		wait_for_warp(s);
		mysleep(10000);//FIXME: new function wait for dock???

		
		for (int i = 0; unload_ore(s) == 1; i++){
			mysleep(5000);
			if(i > 4){		
				printf("Unable to unload ore\n");
				goto exit;
			}
		}


	}

exit:

	if(displayImage)
		cvReleaseImage(&displayImage);

	XCloseDisplay(display);

	return 0;
}