Example #1
0
// 定跡データから、現在の局面kの合法手がその局面でどれくらいの頻度で指されたかを返す。
void Book::fromJoseki(Position &pos, int &mNum, MoveStack moves[], BookEntry data[])
{
	BookKey key;
	BookEntry d_null;
	MoveStack *last = generate<MV_LEGAL>(pos, moves);
	mNum = last - moves;
	memset(&d_null, 0, sizeof(d_null));

	int i;
	StateInfo newSt;
	for (i = 0; i < mNum; i++) {
		Move m = moves[i].move;
		pos.do_move(m, newSt);
		int ret = pos.EncodeHuffman(key.data);
		pos.undo_move(m);
		if (ret < 0) {
			pos.print_csa(m);
			output_info("Error!:Huffman encode!\n");
			continue;
		}
		Joseki_type::iterator p;
		p = joseki.find(key);
		if (p == joseki.end()) {
			// データなし
			data[i] = d_null;
		} else {
			// データあり
			data[i] = p->second;
		}
	}
}
Example #2
0
// 現在の局面がどのくらいの頻度で指されたか定跡データを調べる
int Book::getHindo(const Position &pos)
{
	BookKey key;
	int hindo = 0;

	int ret = pos.EncodeHuffman(key.data);
	if (ret < 0) {
		pos.print_csa();
		output_info("Error!:Huffman encode!\n");
		return 0;
	}
	Joseki_type::iterator p;
	p = joseki.find(key);
	if (p != joseki.end()) {
		// データあり
		hindo = p->second.hindo;
	}

	return hindo;
}