Exemple #1
0
int Book::EntryCheck( uint64 hash, const MOVE& move ){
/************************************************
定跡に指し手があるか調べる。
************************************************/
	int i;
	int flag;
	list<BLIST>::iterator ib;
	list<MLIST>::iterator im;
	list<MLIST>* pmlist;
	unsigned int mv;

	i = (int)( hash & BOOK_HASH_MASK );

	// 局面が既にあるか調べる。
	flag = 0;
	for( ib = blist[i].begin() ; ib != blist[i].end() ; ++ib ){
		if( (*ib).hash == hash ){
			flag = 1;
			break;
		}
	}

	if( flag == 0 )
		return 0;

	// 指し手を探す。
	pmlist = &(*ib).mlist;
	for( im = pmlist->begin() ; im != pmlist->end() ; ++im ){
		mv = move.Export();
		if( (*im).mv == mv )
			return 1;
	}

	return 0;
}
Exemple #2
0
ENTRY_TYPE HashTable::Entry( uint64 hash, int rdepth,
                             int alpha, int beta, int value, const MOVE& move ) {
    /************************************************
    ハッシュテーブルに追加
    ************************************************/
    HASH_TABLE table;
    ENTRY_TYPE ret = HASH_NOENTRY;

    if( !GetTable( hash, table ) || table.rdepth <= rdepth ) {
        if( table.hash == hash ) {
            ret = HASH_OVERWRITE;
        }
        else {
            if( table.cnt == cnt ) {
                ret = HASH_COLLISION;
            }
            else {
                ret = HASH_ENTRY;
            }
            table.first = 0U;
        }
        table.cnt = cnt;
        table.hash = hash;
        if( value >= VMAX || value <= VMIN ) {
            table.rdepth = INT_MAX;
            table.type = VALUE_EXACT;
        }
        else {
            table.rdepth = rdepth;
            if( value >= beta ) {
                table.type = VALUE_LOWER;
            }
            else if( value <= alpha ) {
                table.type = VALUE_UPPER;
            }
            else {
                table.type = VALUE_EXACT;
            }
        }
        table.value = value;
        unsigned m = move.Export();
        if( table.first != m ) {
            table.second = table.first;
        }
        else {
            table.second = 0U;
        }
        table.first = m;

        SetTable( table );
    }

    return ret;
}