• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ print_board函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中print_board函数的典型用法代码示例。如果您正苦于以下问题:C++ print_board函数的具体用法?C++ print_board怎么用?C++ print_board使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了print_board函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: lemipc

void			lemipc(int ac, char **av)
{
	t_info		*info;

	info = init(ac, av);
	print_board(info->game, 0);
	while (is_last(info))
		;
	while (42)
	{
		sem_op(info->semid, -1);
		print_board(info->game, 1);
		is_dead(info);
		if (is_last(info))
			shmclear(&info, 1);
		if (info->lead)
			find(info);
		else
			listen_lead(info);
		print_board(info->game, 0);
		sem_op(info->semid, 1);
		usleep(TIMEOUT);
	}
	shmclear(&info, 2);
}
开发者ID:Sconso,项目名称:Lemipc,代码行数:25,代码来源:lemipc.c


示例2: print_board

void Board::simulate_game()
{
  unsigned int moves = 0;

  print_board();

  while (!game_over)
  {
    switch (current_player)
    {
      case Square::BLACK:
        do_best_move();
        break;

      case Square::WHITE:
        do_random_move();
        break;

      default:
        printf("default in simulate_game?\n");
        break;
    }

    print_board();

    if (game_over)
    {
      printf("Game over after %u moves\n", moves);
      break;
    }

    ++moves;
  }
}
开发者ID:ghanan94,项目名称:cooperative-adaptive-algorithms-assignment-2,代码行数:34,代码来源:board.cpp


示例3: main

/*
 * 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);
}
开发者ID:tdooner,项目名称:eecs-314-final-project,代码行数:60,代码来源:main.c


示例4: main

int main(int argc, char **argv) {
	if (argc < 3) {
		printf("Usage: ./gol <infile> <print>\n");
		return 0;
	}

	FILE *f = fopen(argv[1], "r");
	int to_print = strtol(argv[2], NULL, 10);

	// Check if we opened the file
	if (f != NULL) { 
		int num_rows = 0;
		int num_cols = 0;
		int num_iterations = 0;
		int num_pairs = 0;
		double total_time = 0.0;
		
		// read numbers
		fscanf(f, "%d\n%d\n%d\n%d", &num_rows, &num_cols, &num_iterations, &num_pairs);

		// set up board
		board_t *board = init_board(f, num_rows, num_cols, num_pairs);

		// set up timing
		struct timeval start_time;
		struct timeval end_time;
		gettimeofday(&start_time, NULL);

		// run iterations
		int i = num_iterations;
		while (board_next(board, &i)) {
			if (to_print) {
				print_board(board, num_iterations - i);
				usleep(200000);
				clear(num_rows + 4);
			}
			i--;
		}

		// get end time
		gettimeofday(&end_time, NULL);
		total_time = ((end_time.tv_sec + (end_time.tv_usec/1000000.0)) - (start_time.tv_sec + (start_time.tv_usec/1000000.0)));

		// print final board
		print_board(board, num_iterations);

		printf("total time for %d iteration%s of %dx%d world is %f sec\n", num_iterations, (num_iterations != 1) ? "s" : "", num_rows, num_cols, total_time);
		fclose(f);
		board_free(board);
	} else {
		printf("There was an error opening '%s'\n", argv[1]);
		return 1;
	}

	return 0;
}
开发者ID:jjacobson93,项目名称:comp280-labs,代码行数:56,代码来源:gol.c


示例5: get_play

//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;
}
开发者ID:sdzharkov,项目名称:ECS30,代码行数:55,代码来源:play.c


示例6: doisjogadores

void doisjogadores(char **board) {
    system("clear");
    print_usage2();
    print_board(board);
    while ((!game_over(board) && (!someone_wins(board, 'O')))) {
        while(1) {
            printf("\n\t\t\tVez de jogador 1:\n");
            if (jogada(board,'X')) {
                break;
                //print_board(board)
            }
        }
        if(game_over(board) || someone_wins(board, 'X'))
            break;
        system("clear");
        print_board(board);

        while (1) {
            printf("\n\t\t\tVez de jogador 2:\n");
            if(jogada(board,0)) {
                break;
            }
        }
        system("clear");
        print_board(board);
    }
    system("clear");
    print_board(board);
    if (someone_wins(board, 'X')) {
        printf("\t\t\t\t\t\t\t\tJogador 1 ganhou!\n");

        enter();

        getchar();
        ultimos(board, 1);
    } else if (someone_wins(board, 'O'))  {
        printf("\t\t\t\t\t\t\t\tJogador 2 ganhou!\n");

        enter();


        getchar();
        ultimos(board, 2);
    } else {
        printf("\t\t\t\t\t\t\t\tFoi um empate!\n");

        enter();
        getchar();
        getchar();
    }


}
开发者ID:portoedu,项目名称:Tic-Tac-Toe-Engine,代码行数:53,代码来源:main.c


示例7: play_game

void play_game() {
	char name[50];
	printf("Hi!\n\nI am Z3TA.\n\nWhat's your name: ");
	scanf("%s", name);
	int play_first = 0;
	printf("\n\nDo you want to play first? 1 - Yes, 0 - No:  ");
	scanf("%d", &play_first);
	printf("\n\n\nX: Z3TA\nO: %s\n\n\n",name);
	if(!play_first) {
			while(!board_full(board) && !check_win(board)) {
			computer_move();
			printf("Z3TA just made a move...\n");
			print_board();
			if(board_full(board) || check_win(board)) {
				break;
			}
			player_move();
			printf("%s just made a move...\n", name);
			print_board();
		}
	}

	else {
			while(!board_full(board) && !check_win(board)) {
			player_move();
			printf("%s just made a move...\n", name);
			print_board();
			if(board_full(board) || check_win(board)) {
				break;
			}
			computer_move();
			printf("Z3TA just made a move...\n");
			print_board();
		}
	}

	printf("\n\n------------------------------\n\n");
	if(check_win(board) == 0) {
		printf("It's a DRAW!\n");
	}
	else if(check_win(board) == 1) {
		printf("%s WON!\n", name);
	}
	else {
		printf("Z3TA WON!\n");
	}
	printf("\n------------------------------\n");
}
开发者ID:MayankVachher,项目名称:TicTacToe,代码行数:48,代码来源:TicTacToe_MiniMax.c


示例8: select_single_click_handler

void select_single_click_handler(ClickRecognizerRef recognizer, Window *window) {
  (void)recognizer;
  (void)window;

  static short idx = 0;
  static short userTurn = 1;
  
  if(userTurn == 1) {
    if(idx < 4) {
      input[idx++] = X_VALUE(xoffset);
      input[idx++] = Y_VALUE(yoffset);
    }
  
    if(idx == 4) {
      input[idx] = 10;
      userTurn = 0;
      idx = 0;
      chess_move(input);
    }
  }
  else {
    input[0] = 10;
    userTurn = 1;
    idx = 0;
    text_layer_set_text(&strBoardLayer, "thinking...");
    chess_move(input);
  }
  print_board();
}
开发者ID:jiga,项目名称:pebble-apps,代码行数:29,代码来源:chess.c


示例9: main

int main( int argc, char *argv[] )
{
    atexit(end);

    running = 0;
    level = 0;

    init_gui( &argc, argv );

    if( parse_args( &argc, argv ) < 0 )
        exit(0);

    if( init_game( &argc, argv ) < 0 )
        exit(0);

    if( argc > 1 )
    {
        print_usage(argv[0]);
        exit(0);
    }

    print_board();
    start_gui();

    end();
    exit(0);/*Jules : on ne devrait jamais arriver ici mais bon... */
    return 0; /*Vinz : ici encore moins mais restons standards */
}
开发者ID:vsiles,项目名称:LoutreBlocks,代码行数:28,代码来源:main.c


示例10: main

int main(int argc, const char *argv[])
{
    fb_info fb_v;
    fb_info * temp;
	pthread_t id;
	int ret;
    Dot mid;
    mid.x = 512;
    mid.y = 275;
    char ip_address[20];
    int mode;
    create_fb(&fb_v);
    system("clear");
    mode = startup(fb_v, ip_address);
    draw_pic(fb_v,OFFSET - 20,0,940,720,gImage_chessboard);
    draw_pic(fb_v,OFFSET - 120,200,100,100,gImage_chessboard);
    draw_pic(fb_v,OFFSET - 120,500,100,100,gImage_chessboard);
    draw_piece(fb_v,OFFSET - 70,250,40,0x00000000);
    draw_piece(fb_v,OFFSET - 70,550,40,0xffffffff);
    print_board(fb_v,23,30,30,OFFSET,15,0x00000000);
    temp = &fb_v;
    if((ret = pthread_create(&id, NULL, (void *) mouse_test,(void *)temp)) != 0)
    {
        printf("Create pthread error!\n");
        exit(1);
    }
    if(mode == 1)
        udp_server(fb_v);
    else
        udp_client(fb_v, ip_address);
    return 0;
}
开发者ID:ymqqqqdx,项目名称:FrameBuffer,代码行数:32,代码来源:main.c


示例11: device_open

static int device_open(struct inode *inode, struct file *file)
{
	char wins[WINBUF];

	if (Device_Open)
		return -EBUSY;
	
	Device_Open++;
	if (ai_turn) {
		ai_turn = FALSE;
		if (make_ai_move(PLAYER_X)) 
			winner = PLAYER_X;

	}

	if (ai_two_in_a_row(PLAYER_O) == -1)
		winner = PLAYER_O;

	print_board(msg);

	if (winner != NO_PLAYER) {
		memset(wins,0,sizeof(wins));
		sprintf(wins,"\n %c wins (send '%s' to restart')\n", winner, RESET_COMMAND);
		strcat(msg,wins);
	}

	msg_Ptr = msg;
	try_module_get(THIS_MODULE);

	return SUCCESS;
}
开发者ID:quatrix,项目名称:kernel-tic-tak-toe,代码行数:31,代码来源:xomain.c


示例12: main

main()
{
	int i,j;			/* counters */
	int a[DIMENSION*DIMENSION+1];
	boardtype board;		/* Seduko board structure */
	boardtype temp;

	read_board(&board);
	print_board(&board);
	copy_board(&board,&temp);


	for (fast=TRUE; fast>=FALSE; fast--) 
		for (smart=TRUE; smart>=FALSE; smart--) {

			printf("----------------------------------\n");
			steps = 0;
			copy_board(&temp,&board);
			finished = FALSE;
		
			backtrack(a,0,&board);
			/*print_board(&board);*/

			printf("It took %d steps to find this solution ",steps);
			printf("for fast=%d  smart=%d\n",fast,smart);


		}
}
开发者ID:LihuaWu,项目名称:recipe,代码行数:29,代码来源:sudoku.c


示例13: test_move

int test_move(char *fen, int side, char *move, int move_correct)
{
	IS_CHECKMATE = IS_DRAW = 0;
	B b = fen_to_board(fen);
	print_board(b);
	printf("\n");
	Move m = find_move(b, side, 180);
	if(m == atomove(move, b) && move_correct) {
		printf("CORRECT\n\n");
		goto SUCESS;
	} else if(m != atomove(move, b) && !move_correct) {
		printf("CORRECT\n\n");
		print_move(m);
		printf("\n%s\n", movetoa(m));
		goto SUCESS;
	} else goto FAILURE;
	SUCESS:
		printf("\n\n#############################\n");
		free(b);
		return 1;
	FAILURE:
		printf("FAILURE: ");
		print_move(m);
		printf("\n%s\n", movetoa(m));
		printf("\n\n#############################\n");
        free(b);
        return 0;
}
开发者ID:NiallEgan,项目名称:chess_engine,代码行数:28,代码来源:puzzle_test.c


示例14: main

int main(void)
{
	init_data();
	print_board();
	mouse_doing();
	return 0;
}
开发者ID:psjicfh,项目名称:C_stage,代码行数:7,代码来源:gobang.c


示例15: player

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);
}
开发者ID:vikingeff,项目名称:4puis,代码行数:25,代码来源:ft_play.c


示例16: user_action

int user_action(char board1[BOARD_SIZE][BOARD_SIZE], char board2[BOARD_SIZE][BOARD_SIZE], char user) {
	switch (user) {
		case 'a': 
			add_cell(board2) ;
			break ;

		case 'r':
			remove_cell(board2) ;
			break ;

		case 'n':
			apply_rules(board1, board2) ;
			break ;

		case 'q':
			return 0 ;

		case 'p':		
			while (1) {
				apply_rules(board1, board2) ;	
				copy_board(board1, board2) ;
				printf("\033[2J\033[H") ;
				usleep(500000) ;
				print_board(board1) ;			
			}
	}
	return 1 ;
}
开发者ID:srack,项目名称:fundcomp1,代码行数:28,代码来源:life.c


示例17: main

int main(int argc, char *argv[])
{
    cint_t board_a[BOARD_HEIGHT][BOARD_WIDTH] = {
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        { 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0 },
        { 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0 },
        { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 },
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        { 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0 },
        { 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0 },
        { 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0 },
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
    };
    cint_t board_b[BOARD_HEIGHT][BOARD_WIDTH];

    cint_t *origin = (cint_t *) board_a
         , *dest   = (cint_t *) board_b;

    for (;;) {
        next_state(origin, dest);

        system("clear");
        print_board(dest);
        sleep(1);

        cint_t *tmp = origin;
        origin = dest;
        dest = tmp;
    }

    return 0;
}
开发者ID:RaphaelJ,项目名称:Cours-passerelle,代码行数:33,代码来源:game_of_life.c


示例18: main

//begin main
int main (void) {

	char current[BOARD_SIZE][BOARD_SIZE] ;
	char future[BOARD_SIZE][BOARD_SIZE] ;

	initialize_board(current, ' ') ;
	initialize_board(future, ' ') ;

	char choice ;	
	int stillgoing = 1;

	while (stillgoing) {
		
		printf("\033[2J\033[H") ;

		copy_board(current, future) ;
		print_board(current) ;	

		printf("Please enter one of the following:\n a: to add a new cell\n r: to remove a cell\n n: to advance the simulation\n q: to quit\n p: to play the game forever\n") ;
		scanf("%c", &choice) ;
		
		stillgoing = user_action(current, future, choice) ;		
	}
	return 0 ;

}	//end main
开发者ID:srack,项目名称:fundcomp1,代码行数:27,代码来源:life.c


示例19: main

int main(int argc, const char *argv[])
{
	init_data();
	print_board();
	mouse_doing();
/*
	save_bg(512, 367);
	draw_cursor(512, 367);
	sleep(1);
	restore_bg(512, 367);
	draw_cursor(612, 300);
*/

//	fb_circle(500, 400, 100, 0x00ffff00);
/*
	fb_line(0, 0, fb_v.w-1, fb_v.h-1, 0x00ff00ff);
	fb_line(fb_v.w-1, 0, 0, fb_v.h-1, 0x00ccff00);
	fb_line(300, fb_v.h-1, 400, 0, 0x00ff00bb);
*/

/*
	int i, j;
	for (i = 0; i < 100; i++)
	{
		for (j = 0; j < 100; j++)
		{
			fb_one_pixel(500+i, 300+j, 0x0000ff00);
		}
	}
*/

	return 0;
}
开发者ID:Greatjackson,项目名称:lg-project,代码行数:33,代码来源:main.c


示例20: main

int main()
{
  int color = 1;
  int z;

  srand( (unsigned)time( NULL ) );
  for (;;) {
    z = play_one_move(color);
    printf("moves=%4d, color=%d, z=%d\n",moves, color, get81(z));
    print_board();

    record[moves] = z;
    moves++;
    if ( moves == MAX_MOVES ) {
      printf("max moves!\n");
      break;
    }
    if ( z == 0 && moves >= 2 && record[moves-2] == 0 ) {
      printf("two pass\n");
      break;
    } 

    color = flip_color(color);
  }

  return 0;
}
开发者ID:KitAiProject,项目名称:Go,代码行数:27,代码来源:go03.c



注:本文中的print_board函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ print_buf函数代码示例发布时间:2022-05-30
下一篇:
C++ print_block函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap