Exemple #1
0
int main(void)
{
	while(1) 
	{
		read_cards();
		analyze_hand();
	} 
}
Exemple #2
0
/**********************************************************
 * main: Calls read_cards, analyze_hand, and print_result *
 *       repeatedly.                                      *
 **********************************************************/
int main(void)
{
  for (;;) {
    read_cards();
    analyze_hand();
    print_result();
  }
}
/******************************************************************
* main: Calls read_cards, analyze_hand, and print_result          *
* 		repeatedly                                                *
******************************************************************/
int main(int argc, char *argv[]) {
	for(;;)
	{
		read_cards();
		analyze_hand();
		print_result();
	}
	return 0;
}
Exemple #4
0
/*
 * Calls read_cards, analyze_hand, and print_result repeatedly.
 */
int main(void)
{
	int hand[NUM_CARDS][2];

	while(true) {
		read_cards(hand);
		analyze_hand(num_in_rank, num_in_suit);
		print_result();
	}
}
/*************************************************************
 * main: Calls read_cards, analyze_hand, and print_result    *
 *       repetedly.                                          *
 *************************************************************/
int main(void)
{
    int num_in_rank[NUM_RANKS], num_in_suit[NUM_SUITS];

    for (;;) {
        read_cards(num_in_rank, num_in_suit);
        analyze_hand(num_in_rank, num_in_suit);
        print_result();
    }
}
/**********************************************************
 * main: Calls read_cards, analyze_hand, and print_result *
 *       repeatedly.                                      *
 **********************************************************/
int main(void)
{
    int hand[NUM_CARDS][2];

    for (;;) {
        read_cards(hand);
        analyze_hand(hand);
        print_result();
    }
}
Exemple #7
0
/**********************************************************
 * main: Calls read_cards, analyze_hand, and print_result *
 *       repeatedly.                                      *
 **********************************************************/
int main(void)
{
  int num_in_rank[NUM_RANKS];
  int num_in_suit[NUM_SUITS];
  bool straight, flush, four, three;
  int pairs;   /* can be 0, 1, or 2 */

 for (;;) {
    read_cards(num_in_rank, num_in_suit);
    analyze_hand(num_in_rank, num_in_suit, &straight, &flush, &four, &three, &pairs);
    print_result(&straight, &flush, &four, &three, &pairs);
  }
}
Exemple #8
0
int main(void) {
    int num_in_rank[RANKS];
    int num_in_suit[SUITS];
    bool straight, flush, four, three;
    int pairs;
    while (read_cards(num_in_rank, num_in_suit)) {
        analyze_hand(num_in_rank, num_in_suit, &straight, &flush, &four, &three,
                     &pairs);
        print_result(&straight, &flush, &four, &three, &pairs);
    }

    /* This _should_ now return. I will test when I have a working system */
    return 0;
}
Exemple #9
0
static void initGame(JNIEnv *env, jclass classz) {
	real_game.random_seed = time(NULL);

	/* Load card designs */
	read_cards();

	/* Load card images */
	// done in Java onCreate()
	//load_images();

	/* Read preference file */
	read_prefs();

	apply_options();

	/* Create choice logs for each player */
	int i;
	for (i = 0; i < MAX_PLAYER; i++) {
		/* Create log */
		real_game.p[i].choice_log = (int *)malloc(sizeof(int) * 4096);

		/* Save original log */
		orig_log[i] = real_game.p[i].choice_log;

		/* Create history of log sizes */
		real_game.p[i].choice_history = (int*)malloc(sizeof(int) * 512);

		/* Save original history */
		orig_history[i] = real_game.p[i].choice_history;

		/* Clear choice log size and position */
		real_game.p[i].choice_size = 0;
		real_game.p[i].choice_pos = 0;
	}

 	reset_gui();
	modify_gui(); // adjust for the number of players

	/* Start new game */
	restart_loop = RESTART_NEW;

	run_game();
}
Exemple #10
0
/*
 * Read messages from server and have AI answer choice queries.
 */
int main(int argc, char *argv[])
{
    int i;

    /* Read card database */
    read_cards();

    /* Create choice logs */
    for (i = 0; i < MAX_PLAYER; i++)
    {
        /* Create choice log for player */
        real_game.p[i].choice_log = (int *)malloc(sizeof(int) * 4096);
    }

    /* Loop forever */
    while (1)
    {
        /* Try to read data */
        data_ready();
    }
}
/*
 * Play a number of training games.
 */
int main(int argc, char *argv[])
{
	game my_game;
	int i, j, n = 100;
	int num_players = 3;
	int expansion = 0, advanced = 0, promo = 0;
	char buf[1024], *names[MAX_PLAYER];
	double factor = 1.0;

	/* Set random seed */
	my_game.random_seed = time(NULL);

	/* Read card database */
	if (read_cards(NULL) < 0)
	{
		/* Exit */
		exit(1);
	}

	/* Parse arguments */
	for (i = 1; i < argc; i++)
	{
		/* Check for verbosity */
		if (!strcmp(argv[i], "-v"))
		{
			/* Set verbose flag */
			verbose++;
		}

		/* Check for number of players */
		else if (!strcmp(argv[i], "-p"))
		{
			/* Set number of players */
			num_players = atoi(argv[++i]);
		}

		/* Check for advanced game */
		else if (!strcmp(argv[i], "-a"))
		{
			/* Set advanced flag */
			advanced = 1;
		}

		/* Check for expansion level */
		else if (!strcmp(argv[i], "-e"))
		{
			/* Set expansion level */
			expansion = atoi(argv[++i]);
		}

		/* Check for promo cards */
		else if (!strcmp(argv[i], "-o"))
		{
			/* Set promo cards */
			promo = 1;
		}

		/* Check for number of games */
		else if (!strcmp(argv[i], "-n"))
		{
			/* Set number of games */
			n = atoi(argv[++i]);
		}

		/* Check for random seed */
		else if (!strcmp(argv[i], "-r"))
		{
			/* Set random seed */
			my_game.random_seed = atoi(argv[++i]);
		}

		/* Check for alpha factor */
		else if (!strcmp(argv[i], "-f"))
		{
			/* Set factor */
			factor = atof(argv[++i]);
		}
	}

	/* Set number of players */
	my_game.num_players = num_players;

	/* Set expansion level */
	my_game.expanded = expansion;

	/* Set advanced flag */
	my_game.advanced = advanced;

	/* Set promo flag */
	my_game.promo = promo;

	/* Assume no options disabled */
	my_game.goal_disabled = 0;
	my_game.takeover_disabled = 0;

	/* No campaign selected */
	my_game.camp = NULL;

	/* Call initialization functions */
	for (i = 0; i < num_players; i++)
	{
		/* Create player name */
		sprintf(buf, "Player %d", i);

		/* Set player name */
		my_game.p[i].name = strdup(buf);
		names[i] = my_game.p[i].name;

		/* Set player interfaces to AI functions */
		my_game.p[i].control = &ai_func;

		/* Initialize AI */
		my_game.p[i].control->init(&my_game, i, factor);

		/* Create choice log for player */
		my_game.p[i].choice_log = (int *)malloc(sizeof(int) * 4096);

		/* Clear choice log size and position */
		my_game.p[i].choice_size = 0;
		my_game.p[i].choice_pos = 0;
	}

	/* Play a number of games */
	for (i = 0; i < n; i++)
	{
		/* Initialize game */
		init_game(&my_game);

		printf("Start seed: %u\n", my_game.start_seed);

		/* Begin game */
		begin_game(&my_game);

		/* Play game rounds until finished */
		while (game_round(&my_game));

		/* Score game */
		score_game(&my_game);

		/* Print result */
		for (j = 0; j < num_players; j++)
		{
			/* Print score */
			printf("%s: %d\n", my_game.p[j].name,
			                   my_game.p[j].end_vp);
		}

		/* Declare winner */
		declare_winner(&my_game);

		/* Call player game over functions */
		for (j = 0; j < num_players; j++)
		{
			/* Call game over function */
			my_game.p[j].control->game_over(&my_game, j);

			/* Clear choice log */
			my_game.p[j].choice_size = 0;
			my_game.p[j].choice_pos = 0;
		}

		/* Reset player names */
		for (j = 0; j < num_players; j++)
		{
			/* Reset name */
			my_game.p[j].name = names[j];
		}
	}

	/* Call interface shutdown functions */
	for (i = 0; i < num_players; i++)
	{
		/* Call shutdown function */
		my_game.p[i].control->shutdown(&my_game, i);
	}

	/* Done */
	return 0;
}