Пример #1
0
/**
 * @brief 指し手のリストをSFEN形式の文字列リストに変換します。
 */
std::vector<std::string> MoveNodeList::to_sfen_list() const
{
    std::vector<std::string> result;

    for (auto node : m_nodeList) {
        result.push_back(move_to_uci(node.move()));
    }

    return result;
}
Пример #2
0
Move test_bestmove(Position& pos, int maxdepth) {
	Move bestmove = MOVE_NONE;
	

	
	
	
	MoveStack mlist[MAX_MOVES];
	StateInfo st;
	Move m;

	// Generate all legal moves
	MoveStack* last = generate<MV_LEGAL>(pos, mlist);
	
	
	for (int it_depth = 1; it_depth <= maxdepth; ++it_depth) {
	
		bool bSearchPv = true;
		int alpha = -100000;
		int beta  =  100000;
		int score = alpha;
		
		for (MoveStack* cur = mlist; cur != last; cur++) {
			m = cur->move;
			pos.do_move(m, st);
			if (bSearchPv) {
				score = -test_search(pos, -beta, -alpha, it_depth - 1);
			} else {
				score = -test_search(pos, -alpha-1, -alpha, it_depth - 1);
				if (score > alpha) // in fail-soft ... && score < beta ) is common
					score = -test_search(pos, -beta, -alpha, it_depth - 1); // re-search
			}
			pos.undo_move(m);
			
			if(score > alpha) {
				alpha = score; // alpha acts like max in MiniMax
				bestmove = m;
			}
			bSearchPv = false;
		}
		
		
		cout << it_depth << " " << move_to_uci(bestmove, 0) << " " << score << endl;
		
	}
	
	
	return bestmove;
}