void zz::bot::choose_randomly() {
  int index = rand( ) % _count_moves;
#ifdef DEBUG_BOT
    fprintf( stderr, " choose_randomly: [" );
    for( int i = 0; i < _count_moves; ++i ) {
      fprintf( stderr, "%d:%d", _moves[i], i == index );
      if( i != _count_moves - 1) fprintf( stderr, ", " );
    }
    fprintf( stderr, "]\n" );
#endif
  output_move( _moves[index] );
}
示例#2
0
文件: search.c 项目: dk00/old-stuff
// 下一手棋
void play()
{

	int ret;
	int ply, turn, time_limit;
	int chsbrd[BOARD_SIZE];
	int score;
	int r, move_type;
	int MaxDepth;
	clock_t t;
	printf("inputting board\n");
	ret = load_game("board.txt", piece_num, chsbrd, &turn, &time_limit);
	transform_board(board, chsbrd);
	dark_num = get_dark_num(board);
	red_num = get_piece_num(RED, piece_num);
	black_num = get_piece_num(BLACK, piece_num);
	best_src = 0;
	best_dest = 0;
	if(dark_num == PIECE_NUM)
		move_type = REVEAL_PIECE;
	else
		move_type = MOVE_PIECE;

	if(move_type == MOVE_PIECE){
		printf("searching\n");
		clock_limit = clock() + time_limit * CLK_TCK;
		if(time_limit < 20)
			max_depth = 6;
		else
			max_depth = (int) (log(time_limit / 20) / log(3)) * 2 + 6;
		score = search(board, piece_num, dark_num, red_num, black_num, turn, 1, max_depth, clock_limit);
	}
	move_type = (best_dest == -1) ? 1 : 0;
	if(best_src == 0){
		move_type = REVEAL_PIECE;
		printf("revealing\n");
		reveal(board);
	}
	best_src = translate_position(board, best_src);
	best_dest = translate_position(board, best_dest);
	printf("outputing\n\n");
	output_move("move.txt", move_type, best_src, best_dest, score);
}
void zz::bot::choose_first() {
  output_move( _moves[0] );
}