int max(char board[][7], int depth, int alpha, int beta)
{
    if(depth==0)
    {
        return appx_score(board);
    }
    else if(check_win(board)==1)
        return -100000-depth;
    else if(check_win(board)==2)
        return 0;
    else
    {
    int temp=0, ctr=0;

    int col_order[7]={3,2,4,1,5,0,6};
    int score_order[7]={-100000, -100000, -100000, -100000, -100000, -100000, -100000};
    for(int i=0; i<7; i++)
    {
        if(is_free(i, board))
        {
            update_board(i+1, 'c', board);
            score_order[ctr]=appx_score(board);
            col_order[ctr]=i;
            update_board(i+1, 'a', board);
            ctr=ctr+1;
        }
    }
    for(int x=0; x<ctr; x++)
	{
		for(int y=0; y<ctr-x-1; y++)
		{
			if(score_order[y]<score_order[y+1])
			{
				int temp2 = col_order[y+1];
				int temp1 = score_order[y+1];
				col_order[y+1] = col_order[y];
				col_order[y] = temp2;
				score_order[y+1] = score_order[y];
				score_order[y] = temp1;
			}
		}
	}
    for(int j=0; j<ctr; j++)
    {
        if(alpha<beta)
        {
            update_board(col_order[j]+1, 'c', board);

            temp=mini(board, depth-1, alpha, beta);
            if(temp>alpha)
                alpha=temp;

            update_board(col_order[j]+1, 'a', board);
        }
        else return alpha;
    }
    return alpha;    //beta becomes alpha
   }

}
Beispiel #2
0
int		max(t_env *e, int p, int depth)
{
	int	i;
	int	v;
	int	vmax;

	i = -1;
	if (depth == 0 && check_win(e, p) == 0)
		return (evaluate(e));
	else if (check_win(e, p) == 1)
		return (MAX_VALUE - (MAX_DEPTH - depth) * 10);
	else
	{
		vmax = -MAX_VALUE;
		while (++i < e->w)
		{
			if (e->board[0][i] == '.')
			{
				board_insert(e, i, p);
				v = min(e, p % 2 + 1, depth - 1);
				vmax = (v > vmax ? v : vmax);
				board_delete(e, i);
			}
		}
	}
	return (vmax);
}
Beispiel #3
0
int joker_next_round(int style)
{
	int j;
	for (j=0;j<MAX_JOKER_PLAYER;j++)
		if (PINFO(joker_getpos(j)).style!=-1 && PINFO(joker_getpos(j)).flag & PEOPLE_ALIVE)
			PINFO(joker_getpos(j)).flag &=~ PEOPLE_VOTED;
	if (style==JOKER_NEXT_PLAYER_MAYPASS)
	{
		CURRENT_JOKER_TYPE=-1;
		CURRENT_JOKER_VALUE=-1;
		ONTABLE_NUM=0;
		return check_win();
	}
	else if (style==JOKER_NEXT_PLAYER_MAYNOTPASS)
	{
		vote_result();
		ONTABLE_NUM=0;
		for (j=0;j<MAX_JOKER_PLAYER;j++)
			ONTABLE_LIST[j]=-1;
		CURRENT_JOKER_TYPE=-1;
		CURRENT_JOKER_VALUE=-1;
		ONTABLE_NUM=0;
		return check_win();
		
	}
		//joker_ontable_show
//		return vote_result(); //结算一下本轮的胜利者和得分
	else if (style==JOKER_NEXT_PLAYER_BRIDGE_BID);
//		return vote_result(); //3pass叫牌结束
	return 0;
}
//Allow both avatar and boss to move during spell animations.
void mid_spell_move(Coords *cc, int i){
    avatar_move(cc->game_speed,cc);
    check_win(cc);
    if(i > 2){
        boss_Move(cc); 
        check_win(cc);
    }
    check_win(cc);
}
Beispiel #5
0
/*
 * This is the main loop of the connect four game.  It first prints a 
 * welcome message, allocates the board, and then begins the game loop
 */
int main()
{
	puts("Welcome to Connect Four\n");

	int* board = new_board();
    
	while (1)
	{
		print_board(board);

		int column = -1;

		// Get human input until they enter a valid choice...
		while (1)
		{
			printf("Enter your move (column number): ");
			scanf("%d", &column);

			if (column < 0 || column >= WIDTH)
			{
				printf("Input a valid choice (0 - 6).\n");
			}
			else if (place(board, column, 1) == 0)
			{
				printf("That column is full.\n");
			}
            else
            {
                break;
            }
		}
        // Did the human input make him or her win?
        if (check_win(board, 1) != 0)
        {
            print_board(board);
            printf("Player 1 wins!\n");
            break;
        }

		// Do the AI's move...
		int ai_column = get_next_move(evaluate_board(board));
		place(board,ai_column, 2);

		// Did the AI's move cause it to win?
        if (check_win(board, 2) != 0)
        {
            print_board(board);
            printf("Player 2 wins!\n");
            break;
        }
	}

	free(board);

	exit(EXIT_SUCCESS);
}
Beispiel #6
0
int main(){
    int round,i,j;
    int count_fault;

    while( scanf("%d",&round) == 1 && round != -1 ){  
        getchar();   //skip '\n'
        scanf("%s",right);
        getchar();   //skip '\n'
        scanf("%s",guess);
        count_fault = 0;

        del_repeat(guess);    //用同一个字母多次猜测,只算1次成功或失败,所以guess要去重

        int guess_length = strlen(guess);
        int right_length = strlen(right);
        for(i=0; i<guess_length; i++){  
            char cur_char = guess[i];

            if( cur_char == -1 )      //如果是与前面重复的字母,则直接跳过
                continue;

            int have_char = 0;
            for(j=0; j<right_length; j++){
                if( cur_char == right[j] ){  
                    right[j] = -1;
                    have_char = 1;
                }
            }
            if( !have_char )
                count_fault++;

            if( count_fault >= 7 
                    || check_win(right) ){   //如果已经匹配成功,则即使guess没有遍历完也算作win
                break;
            }
        }

        printf("Round %d\n",round);
        if(count_fault >= 7){
            printf("You lose.\n");
            continue;
        }
        if( check_win(right) ){  
            printf("You win.\n");
            continue;
        }
        printf("You chickened out.\n");
    
    }

    //printf("time used = %f\n", (double)clock()/CLOCKS_PER_SEC);
    return 0;
}
Beispiel #7
0
void			start_game(t_grid *grid)
{
	int			random;
	int			i;
	int			winner;

	ft_putendl("starting the game");
	srand(time(NULL));
	random = rand() % 2;
	i = 0;
	while ((!(winner = check_win(grid, "XO"))) &&
			(!(winner = tie(grid))))
	{
		ft_screenclr();
		random ^= 1;
		if (random)
		{
			while (player_turn(grid) == 0)
				++i;
		}
		else
			ai_turn(grid);
	}
	display_grid(grid);
	call_winner(winner);
}
Beispiel #8
0
int min(uint16_t move, int ply) {
    //printf("ply: %d\n", ply);
    //bboards[0] |= move;
    update_ply(ply);
    update_analysis(move, 0);
    int min_score = 2;
    if(check_win(0)){
        //bboards[0] ^= move;
        undo_analysis(move, 0);
        return 1;
    }
    //uint16_t next_move = 1;
    for(int i = 0; i < 16; i++) {
        //printf("max: %d\n", i);
        if(is_legal(1 << i)){
            int score = max(1 << i, ply + 1);
            if(score < min_score)
                min_score = score;
        }
        //next_move <<= 1;
    }
    //printf("whew\n");
    //bboards[0] ^= move;
    undo_analysis(move, 0);
    if(min_score != 2)
        return min_score;
    else
        return 0;
}
Beispiel #9
0
/*Adaption of CountLeaves suggested by prof Di Lena, in this case I just count the winning leaves for player1*/
static unsigned int CountWins(NODE *T) {
	if (T == NULL)
		return 0;

	else {
		unsigned int n = 0;
		if (T->leftchild == NULL) { //if it doesnt have children it's a leaf.
			if (check_win(1, ReverseTrans(T->transboard)) == 1) //I also check if it's a winning leaf
				n = (T->depth)*(T->depth); //n is a value that better reflects winning leaves after less moves to help the algorithm go towards a path statistically better (winning-wise)
		}								   //fluctuates as a parabola

		else {
			NODE *tmp;
			for (tmp = T->leftchild; tmp != NULL; tmp = tmp->rightbrothers) {
				n = n + CountWins(tmp); //recursive call that sums the obtained values
			}							//Anyways I should fina the perfect formula to determine statistically how much depth should weigh in the decision. As for now depth^2 works pretty well I must say
		}

		return n;


	}


}
Beispiel #10
0
void goto_night_butterfly()
{
	int i;
	if (!check_win())
	{
		send_msg(-1,"\x1b[31;1mҹĻ½µÁÙÁË...\x1b[m");
		for(i=0;i<MAX_PLAYER;i++)
			if (PINFO(i).style!=-1 && (PINFO(i).flag & PEOPLE_ALIVE))
			{
				if (PINFO(i).flag & PEOPLE_KILLER)
						goto_night_msg(i, "¼âµ¶","²Ðº¦");
				else if (PINFO(i).flag & PEOPLE_FOREST)
						goto_night_msg(i, "Ê÷Ö¦","½ûÑÔ");
				else if (PINFO(i).flag & PEOPLE_BUTTERFLY)
						goto_night_msg(i, "³á°ò","Óµ±§");
				else if (PINFO(i).flag & PEOPLE_SHOOTER)
						goto_night_msg(i, "¹­¼ý","ÏûÃð");
				else if (PINFO(i).flag & PEOPLE_DOCTOR)
						goto_night_msg(i, "ÕëͲ","×¢Éä");
				else if (PINFO(i).flag & PEOPLE_POLICE)
						goto_night_msg(i, "¾¯°ô","²é¿´");
				
			}
		goto_night_common();
 
	}
}
Beispiel #11
0
int
main(){
	int max_turns = BOARD_SIZE * BOARD_SIZE;
	int num_turns = 0;
	char *c_player = XX;
	printf("A basic game of tic-tac-toe.\n");
	printf("Board size is %i x %i\n", BOARD_SIZE, BOARD_SIZE);
	while (check_win() != 1){
		if (c_player == XX){
			c_player = OO;
		}else{
			c_player = XX;
		}
		if (num_turns++ >= max_turns){
			print_board();
			printf("Draw game!\n");
			return 0;
		}
		do{
			print_board();
		}while (perform_move(c_player));

	}
	printf("Game over! The winner was %s\n", c_player);
	return 0;
}
Beispiel #12
0
static void	do_window(GLFWwindow *win, t_env *env)
{
	int			state;

	while (!glfwWindowShouldClose(win))
	{
		if (GLFW_PRESS == (state = glfwGetKey(win, GLFW_KEY_LEFT))
			&& (env->bar > -0.87f))
			env->bar -= 0.03f;
		if (GLFW_PRESS == (state = glfwGetKey(win, GLFW_KEY_RIGHT))
			&& (env->bar < 0.87f))
			env->bar += 0.03f;
		glClear(GL_COLOR_BUFFER_BIT);
		square_create(env);
		the_ball(env);
		the_bar(env);
		aff_score(env);
		glfwPollEvents();
		glfwSwapBuffers(win);
		if (env->life == -1)
		{
			ft_putendl("A looser is YOU ! D:");
			glfwSetWindowShouldClose(win, GL_TRUE);
		}
		if (check_win(env))
			glfwSetWindowShouldClose(win, GL_TRUE);
	}
}
Beispiel #13
0
void		aff_map(t_struct *st)
{
  int		continu;
  SDL_Event	event;

  continu = 1;
  map(st);
  SDL_Flip(st->ecran);
  while (continu == 1)
    {
      SDL_WaitEvent(&event);
      if (check_win(event) == -1)
	exit(0);
      if (go_to_menu_pr(event, st, 2) == 1)
	continu = 0;
      if (event.type == SDL_KEYDOWN)
	{
	  catch_event_map(event, st);
	  st->map_sel = arrange_struct(st->map_sel, st->map);
	  if (event.key.keysym.sym == SDLK_RETURN)
	    continu = 0;
	  map(st);
	  SDL_Flip(st->ecran);
	}
    }
}
Beispiel #14
0
//Клик по Клетке 22-----------------------------------------------------------
void __fastcall Tmain_window::Pole22Click(TObject *Sender) {

    Inform1->Caption = " ";
    Inform2->Caption = " ";

    if (step_enabled == true)

        if (square3x3[1][1] == 0) {

            square3x3[1][1] = 1;
            Pole22->Font->Color = clWhite;
            Pole22->Caption = "0";
            check_win();
            h1 = 1;
            v1 = 1;
            step_comp();
        }

        else {

            Inform2->Caption = "Клетка занята";
            Inform1->Caption = "Ваш ход";

        }

    else {

        Inform1->Caption = "Сейчас вы не можете сделать ход";
        Inform2->Caption = " ";

    }

}
Beispiel #15
0
//Клик по Клетке 11-----------------------------------------------------------
void __fastcall Tmain_window::Pole11Click(TObject *Sender) {

    Inform1->Caption = " ";
    Inform2->Caption = " ";

    if (step_enabled == true) //если можно ходить

        if (square3x3[0][0] == 0) {//если клетка свободна

            square3x3[0][0] = 1; //помечаем элемент массива-клетки
            Pole11->Font->Color = clWhite;
            Pole11->Caption = "0";
            check_win();//проверка на конец игры
            h1 = 0; //координата клетки в которую сходили
            v1 = 0; //координата клетки в которую сходили
            step_comp(); //ход компьюетара
        }

        else {//если клетка не свободна

            Inform2->Caption = "Клетка занята";
            Inform1->Caption = "Ваш ход";

        }

    else {//если ходить нельзя

        Inform1->Caption = "Сейчас вы не можете сделать ход";
        Inform2->Caption = " ";

    }

}
Beispiel #16
0
// evaluate black's move
// returns the evaluation of the strongest
// opponent reply
int max(uint16_t move, int ply) {
    //bboards[1] |= move;
    update_ply(ply);
    update_analysis(move, 1);
    int max_score = -2;
    if(check_win(1)){
        //bboards[1] ^= move;
        undo_analysis(move, 1);
        return -1;
    }
    //uint16_t next_move = 1;
    for(int i = 0; i < 16; i++) {
        //printf("min: %d\n", i);
        if(is_legal(1 << i)){
            int score = min(1 << i, ply + 1);
            if(score > max_score)
                max_score = score;
        }
        //next_move <<= 1;
    }
    //printf("whew\n");
    //bboards[1] ^= move;
    undo_analysis(move, 1);
    if(max_score != -2)
        return max_score;
    else
        return 0;
}
Beispiel #17
0
int	game(char **grid, char **gridenemy)
{
  char	str[3];
  int	*coord;

  if ((coord = malloc(sizeof(*coord) * 2)) == NULL)
      return (1);
  while (check_loose(grid, gridenemy) != 1)
    {
      my_printf("\nmy navy:");
      my_display(grid);
      my_printf("\nenemy navy:");
      my_display(gridenemy);
      my_printf("\nattack : ");
      check_input_coord(str, coord);
      send_coord(coord);
      hitornot(gridenemy, coord);
      if (check_win(grid, gridenemy) == 1)
	return (1);
      my_printf("\nwaiting for enemy's attack...\n");
      receive_coord(coord);
      check_result(grid, coord);
    }
  free(coord);
  return (0);
}
Beispiel #18
0
int joker_next_player(int mode, int style) //mode=0 if first is not allowed, mode=1 if first is allowed
{
	//下一个人是谁呢?
	int i,k;
	i=CURRENT_TABLEPOS; //牌桌上的位置
	k=0;
	set_turn_time();
	while ((!(PINFO(joker_getpos(i)).vnum > 0) ||
		(PINFO(joker_getpos(i)).flag & PEOPLE_VOTED) ||
		(mode==JOKER_NEXT_PLAYER_NOTALLOWFIRST) )&&!k)
	{
		mode=JOKER_NEXT_PLAYER_ALLOWFIRST;
		i++;
		if (i>=MAX_JOKER_PLAYER)
			i=0;
		//假如有人掉线,马上结束
		if (PINFO(joker_getpos(i)).vnum >0 && 
			(PINFO(joker_getpos(i)).style ==-1 || 
			!(PINFO(joker_getpos(i)).flag & PEOPLE_ALIVE)))
		{
			k=check_win();
			return -1;
		}
		//假如已经回到上一次出牌的人那里
		if (joker_getpos(i)==CURRENT_LEADER)
		{	
			if (CURRENT_JOKER_TYPE==-1)
				return -1;
			k=joker_next_round(style);
		}
		if (PINFO(joker_getpos(i)).flag & PEOPLE_VOTED && style == JOKER_NEXT_PLAYER_MAYPASS)
			joker_pass_msg(joker_getpos(i),JOKER_PASS_GIVEUP);
		if (PINFO(joker_getpos(i)).flag & PEOPLE_VOTED && style == JOKER_NEXT_PLAYER_BRIDGE_BID)
			joker_pass_msg(joker_getpos(i),JOKER_PASS_BRIDGE);
		
	}	
	if (style == JOKER_NEXT_PLAYER_MAYPASS || CURRENT_JOKER_TYPE>=0)
	{
		CURRENT_POS=joker_getpos(i);
		CURRENT_TABLEPOS=i;
		send_msg3(-1, "轮到\33[33;1m", joker_getpos(i),"\33[m出牌");
		if (style==JOKER_NEXT_PLAYER_MAYPASS)
			send_msg(joker_getpos(i), 
					"\33[34mCtrl-T跳过,Ctrl-S在跳过和询问之间切换,Ctrl-U查看自己的牌。\33[m");
		else if (style==JOKER_NEXT_PLAYER_MAYNOTPASS)
			send_msg(joker_getpos(i),"\33[34mCtrl-U查看自己的牌。\33[m");
		else if (style==JOKER_NEXT_PLAYER_BRIDGE_BID)
			send_msg(joker_getpos(i),
					"\33[34mCtrl-T跳过,Ctrl-S在跳过和询问之间切换,Ctrl-U查看自己的牌。\33[m");
        }
	else if (style ==JOKER_NEXT_PLAYER_MAYNOTPASS && CURRENT_JOKER_TYPE<0)
	{
		i=CURRENT_TABLEPOS;
		send_msg3(-1, "轮到\33[33;1m", joker_getpos(i),"\33[32;1m领先\33[m出牌");
		send_msg(joker_getpos(i),"\33[34mCtrl-U查看自己的牌。\33[m");
	}

	kill_msg(-1);
	return i;
}	
Beispiel #19
0
int			player(t_gboard *p4, char *cl, int player)
{
	int		move;
	int		win;

	move = -1;
	while (move == -1)
	{
		ft_putendl("Your turn you mud !");
		if ((move = ft_player()) == -1)
		{
			ft_putstr(cl);
			p4->error = COL_STR;
		}
		else
		{
			ft_putstr(cl);
			move = ft_play(p4, move, player);
		}
		print_board(p4);
		if (move != -1)
			win = check_win(p4, player);
	}
	return (win);
}
Beispiel #20
0
static void sound_callback(gchar *file)
{
  if (! gcomprisBoard)
    return;

  if (!playing_sound)
    return;

  playing_sound = FALSE;
  if (currentMode == MODE_TUX){
    if (to_tux) {
      if (firstCard && secondCard){
	if (compare_card(firstCard, secondCard)==0){
	  gc_sound_play_ogg ("sounds/gobble.wav", NULL);
	  win_id = g_timeout_add (1000,
				  (GSourceFunc) hide_card, NULL);
	  tux_id = g_timeout_add (2000,
				  (GSourceFunc) tux_play, NULL);
	  return;
	} else {
	  to_tux = FALSE;
	  return;
	}
      } else {
	tux_id = g_timeout_add (2000,
			      (GSourceFunc) tux_play, NULL);
	return;
      }
    }
  }
  if (firstCard && secondCard)
    check_win();
}
Beispiel #21
0
int main(void) {
	const char *TOKENS = "AB";
	char board[ROWS * COLS];
	memset(board, ' ', ROWS * COLS);

	int round, done = 0;

	for (round = 0; round < ROWS * COLS && !done; round++) {
		print_board(board);
		while (!place_token(board, round % 2, TOKENS)) {
			print_board(board);
			puts("**Column full!**\n");
		}
		done = check_win(board);
	}
	print_board(board);

	if (round == ROWS * COLS && !done) {
		puts("Tie Game! Play Again");
	}
	else {
		round--;
		printf("Player %d (%c) wins!\n", round % 2 + 1, TOKENS[round % 2]);
	}

	return 0;
}
int main()
{
    char board[6][7];
    for(int i=0; i<6; i++)
        for(int j=0; j<7; j++)
            board[i][j]='0';
    int move;
    printf("enter first move\n");
    scanf("%d", &move);
    update_board(move, 'c', board);
    display(board);
    while(1)
    {
        play_server(board);
        display(board);
        if(check_win(board)==1)
        {
            printf("server wins");
            break;
        }
        else if(check_win(board)==2)
        {
            printf("draw");
            break;
        }
        else
        {
            printf("enter_move\n");
            scanf("%d", &move);
            update_board(move, 'c', board);
            display(board);
            if(check_win(board)==1)
            {
                printf("you win");
                break;
            }
            else if(check_win(board)==2)
            {
                printf("draw");
                break;
            }
        }
    }
    return 0;
}
Beispiel #23
0
int		turn_ia(t_env *e)
{
	board_insert(e, minimax(e, MAX_DEPTH), 2);
	e->counter_ai--;
	if (check_win(e, 2) == 1)
	{
		disp_win(e, AI);
		return (1);
	}
	if (board_complete(e) == 1 || (e->counter_ai == 0 && e->counter_hu == 0 &&
		check_win(e, 2) == 0))
	{
		disp_win(e, NONE);
		return (1);
	}
	board_disp(e);
	return (0);
}
Beispiel #24
0
int		turn_player(t_env *e)
{
	get_input(e);
	board_insert(e, e->input, 1);
	e->counter_hu--;
	if (check_win(e, 1) == 1)
	{
		disp_win(e, HUMAN);
		return (1);
	}
	if (board_complete(e) == 1 || (e->counter_ai == 0 && e->counter_hu == 0 &&
		check_win(e, 1) == 0))
	{
		disp_win(e, NONE);
		return (1);
	}
	board_disp(e);
	return (0);
}
Beispiel #25
0
void joker2_next_round()
{
    int j;
    RINFO.round=-1;
    RINFO.victim=-1;
    for (j=0; j<JOKER2_PERSON; j++)
        if (PINFO(RINFO.secretvotelist[j]).style!=-1 && PINFO(RINFO.secretvotelist[j]).flag & PEOPLE_ALIVE)
            PINFO(RINFO.secretvotelist[j]).flag &=~ PEOPLE_VOTED;
    check_win();
}
Beispiel #26
0
/**
 * ゲームオーバーの手か
 * @param int pos 手
 * @param stone_t turn 現在の手番
 * @param stone_t board[][] 盤面
 * @return int true:1, false:0
 */
int is_terminate_hand(int pos, stone_t turn, const stone_t board[HIGHT][AREA])
{
	stone_t copy[HIGHT][AREA];
	int layer;
	copy_board(board, copy);

	layer = put_stone(pos, turn, copy);	// 置いてみる

	return check_win(layer, pos, turn, copy) || is_full(copy);
}
Beispiel #27
0
//ask the user for a play
void get_play(Board board) {
	int enter_row, enter_col;
	while(1){ //while still true, keep going through this loop
		printf("Enter row a row between 0-%d and a column between 0-%d: ", board.row - 1, board.col - 1);
		scanf("%d %d", &enter_row, &enter_col);
		enter_row = board.row - enter_row - 1;
		if (in_bounds(board, enter_row, enter_col)) {
			if (board.tile[enter_row][enter_col].revealed == '!') {
				if (option_2(board, enter_row, enter_col)) {
					break;
				}
				else {
					continue;
				}
			}
			else if (board.tile[enter_row][enter_col].revealed == '?') {
				if (option_3(board, enter_row, enter_col)) {
					break;
				}
				else {
					continue;
				}
			}
			else if (board.tile[enter_row][enter_col].revealed == '#') {
				if (option_1(board, enter_row, enter_col)) {
					reveal_board(board, enter_row, enter_col, 0); 
					break;
				}
				else {
					continue;
				}
			}
			else {
				printf("This tile is already revealed.\n");
				continue;
			}
		}
		else {
			continue;
		}
	}
	if (check_win(board)) {
			print_board(board);
			printf("You Won!!\n");
			exit (0); //end the program because the game is over and the user has lost 
	}

	if (isgameover(board)) {
			print_board(board);
			printf("You Lost :(\n");
			exit(0); //end the program because the game is over and the user has lost
	}
	return;
}
Beispiel #28
0
init(){

    int comp_choice;
    int winner;
    char player_choice[20];

    printf("What is your choice? ");
    scanf("%s", player_choice);

    comp_choice = rand() % 3;
    winner = check_win(comp_choice, player_choice);
    printf("The score is now you: %d , computer: %d \n" , player_wins, comp_wins);

}
Beispiel #29
0
void mainloop(void) {
    int last_tick = -1;
    int current_tick;
    // Loop forever, so that we don't fall back into the bootloader code
    while (1) {
        check_win();
        current_tick = get_num_ticks();
        if (current_tick != last_tick) {
            update_shots(current_tick);
            last_tick = current_tick;
        }
        update_player_position();
        check_collision();
    }
}
//Allow Dealer/Player to act on their turn
static void change_turn(int to)
{
	check_win();

	if(gameRunning == 1)
	{
		if(to == DEALER)
		{
			turn = DEALER;
			dealer_turn();
		}else{
			turn = PLAYER;
			player_turn();
		}
	}
}