bool checkSelfConjugate(vec_mp test_point, BertiniRealConfig & program_options, boost::filesystem::path input_file) { // setup input file int *declarations = NULL; partition_parse(&declarations, input_file, "func_input_real", "config_real",0); // the 0 means not self conjugate free(declarations); //check existence of the required witness_data file. FILE *IN = safe_fopen_read("witness_data"); fclose(IN); //we put the point and its conjugate into the same member points file and run the membership test simultaneously with one bertini call. membership_test_input_file("input_membership_test", "func_input_real", "config_real",3); //setup member_points file, including both the first witness point, and its complex-conjugate write_member_points_sc(test_point);//,fmt int blabla; parse_input_file("input_membership_test", &blabla); membershipMain(13423, blabla, 0, 1, 0); initMP(mpf_get_default_prec()); std::vector<int> component_numbers = read_incidence_matrix(); if (component_numbers[0]==component_numbers[1]) { // printf("component IS self conjugate\n"); return true; } else { // printf("component is NOT self conjugate\n"); return false; } }
int get_incidence_number(vec_mp test_point, BertiniRealConfig & program_options, boost::filesystem::path input_file) { // setup input file int *declarations = NULL; partition_parse(&declarations, input_file, "func_input_real", "config_real",0); // the 0 means not self conjugate free(declarations); //check existence of the required witness_data file. FILE *IN = NULL; IN = safe_fopen_read("witness_data"); fclose(IN); //only need to do this once. we put the point and its conjugate into the same member points file and run the membership test simultaneously with one bertini call. membership_test_input_file("input_membership_test", "func_input_real", "config_real",3); //setup member_points file, including both the first witness point, and its complex-conjugate write_member_points_singlept(test_point); // std::vector<std::string> command_line_options; // command_line_options.push_back("input_membership_test"); // int blabla; parse_input_file("input_membership_test", &blabla); membershipMain(13423, blabla, 0, 1, 0); initMP(mpf_get_default_prec()); // bertini_main_wrapper(command_line_options, 1, 0,0); std::vector<int> component_number = read_incidence_matrix(); return component_number[0]; }
void mp_run_multiplayer() { int i; int round = 1; int result = 0; int done = 0; int activeplayers = params[PLAYERS]; int winners[MAX_PLAYERS]; currentplayer = 0; for (i = 0; i < MAX_PLAYERS; ++i) winners[i] = -1; if (initMP() ) { fprintf(stderr, "Initialization failed, bailing out\n"); return; } //cycle through players until all but one has lost if (params[MODE] == ELIMINATION) { while(!done) { //TODO maybe gradually increase difficulty game_set_start_message(pnames[currentplayer], "Go!", "", ""); result = comets_game(local_game); if (result == GAME_OVER_LOST || result == GAME_OVER_ESCAPE) { //eliminate player pscores[currentplayer] = 0xbeef; winners[--activeplayers] = currentplayer; } do //move to the next player { ++currentplayer; currentplayer %= params[PLAYERS]; if (currentplayer == 0) ++round; } while (pscores[currentplayer] == 0xbeef); //skip over eliminated players if (activeplayers <= 1) //last man standing! { DEBUGMSG(debug_multiplayer, "%d wins\n", currentplayer); winners[0] = currentplayer; done = 1; } } } //players take turns, accumulating score, and the highest score wins else if (params[MODE] == SCORE_SWEEP) { int hiscore = 0; int currentwinner = -1; //play through rounds for (round = 1; round <= params[ROUNDS]; ++round) { for (currentplayer = 0; currentplayer < params[PLAYERS]; ++currentplayer) { game_set_start_message(pnames[currentplayer], _("Go!"), NULL, NULL); result = comets_game(local_game); //pscores[currentplayer] += Opts_LastScore(); //add this player's score if (result == GAME_OVER_WON) pscores[currentplayer] += 500; //plus a possible bonus } } //sort out winners for (i = 0; i < params[PLAYERS]; ++i) { int j = 0; hiscore = 0; for (j = 0; j < params[PLAYERS]; ++j) { if (pscores[j] >= hiscore) { hiscore = pscores[j]; currentwinner = j; } winners[i] = currentwinner; pscores[currentwinner] = -1; } } } DEBUGMSG(debug_multiplayer, "Game over; showing winners\n"); showWinners(winners, params[PLAYERS]); cleanupMP(); }