/* ------------------------------------------------------------ makeMOVE --- */ Instrument *makeMMOVE() { MOVE *inst; inst = new MOVE(); // The class is called MOVE, but the inst is MMOVE inst->set_bus_config("MMOVE"); return inst; }
/* ------------------------------------------------------------ makeMOVE --- */ Instrument *makeMOVE() { MOVE *inst; inst = new MOVE(); inst->set_bus_config("MOVE"); return inst; }
int Book::GetMoveAll( Shogi* pshogi, Moves& moves, TYPE type ){ /************************************************ 定跡手を列挙する。 ************************************************/ int i; int flag; list<BLIST>::iterator ib; list<MLIST>::iterator im; list<MLIST>* pmlist; uint64 hash = pshogi->GetHash(); MOVE mtemp; 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 ){ mtemp.Import( (*im).mv ); if( pshogi->IsLegalMove( mtemp ) ){ switch( type ){ // 評価値を用いる場合 case TYPE_EVAL: mtemp.value = (*im).val; break; // 出現頻度を用いる場合 case TYPE_FREQ: default: mtemp.value = (*im).cnt * 100 / (*ib).cnt; break; } moves.Add( mtemp ); } } moves.Sort(); return moves.GetNumber(); }
void Client::OnPacket(MOVE& pks) { if (pc->GetFSMState() != FieldObjectFSM::MOVE) { pc->ChangeFSM(FieldObjectFSM::MOVE); } pc->velocity.x = pks.x(); pc->velocity.y = pks.y(); pc->velocity.z = pks.z(); if ((pc->velocity.x == 0 && pc->velocity.y == 0 && pc->velocity.z == 0) == false) { pc->velocity = glm::normalize(pc->velocity); } }
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; }
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; }
Book& Book::operator+=( Book& book ){ /************************************************ 定跡データの併合 ************************************************/ list<BLIST>::iterator ib; list<MLIST>::iterator im; list<MLIST>* pmlist; unsigned h; MOVE mtemp; for( h = 0 ; h < BOOK_HASH_SIZE ; ++h ){ for( ib = book.blist[h].begin() ; ib != book.blist[h].end() ; ++ib ){ pmlist = &(*ib).mlist; for( im = pmlist->begin() ; im != pmlist->end() ; ++im ){ mtemp.Import( (*im).mv ); Add( (*ib).hash, mtemp, OVER_WRITE, (*im).cnt ); } } } return *(this); }
gex::Point2 moveToPoint(const MOVE& _move) { return gex::Point2(_move.x(),_move.y()); }
int Book::GetMove( Shogi* pshogi, MOVE& move, TYPE type ){ /************************************************ 定跡から指し手を探す。 ************************************************/ unsigned i; int flag; list<BLIST>::iterator ib; list<MLIST>::iterator im; int cnt; uint64 hash = pshogi->GetHash(); MOVE mtemp; i = (unsigned)( 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; // 指し手を決定 switch( type ){ // 評価値を用いる場合 case TYPE_EVAL: { list<MLIST>* pmlist = &(*ib).mlist; int vmax = (*pmlist->begin()).val - 1; for( im = pmlist->begin() ; im != pmlist->end() ; ++im ){ mtemp.Import( (*im).mv ); if( (*im).val > vmax && pshogi->IsLegalMove( mtemp ) ){ vmax = (*im).val; move = mtemp; } } return 1; } break; // 出現頻度を用いる場合 case TYPE_FREQ: default: list<MLIST>* pmlist = &(*ib).mlist; cnt = (int)( gen_rand32() % (*ib).cnt ); for( im = pmlist->begin() ; im != pmlist->end() ; ++im ){ cnt -= (*im).cnt; if( cnt < 0 ){ mtemp.Import( (*im).mv ); if( pshogi->IsLegalMove( mtemp ) ){ move = mtemp; return 1; } } } break; } return 0; }