Engine

Engine module (see engine.h) handles search functionality independent of particular search algorithms. This means issues like: The highlight of the module and a gateway to the search functionality is Engine::doSearch function (actually, this is called from user communication tool - either aei controller or getMove interface):

if setup, don't even start the uct

  //Engine::doSearch
  ...
  if (board->isSetupPhase()){
    bestMove_ = initialSetup(board->getPlayerToMove() == GOLD);
    return;
  }

initialise and start the search entities

  ...  
  timeManager_->startClock();

  for(t=0; t<threadsNum; t++){
    ucts[t] = new Uct(board, masterUct);
    //wrapper for all stuff neccessary for search start
    SearchStartKit * s = new SearchStartKit(board, this, ucts[t]);
    //Engine::searchTreeWrapper runs the Uct::doSearch
    rc = pthread_create(&threads[t], &attr, Engine::searchTreeWrapper,(void*) s); 
    if (rc) {
      stringstream ss;
      ss << "Fatal thread error no. " << rc << " when creating.";
      logError(ss.str().c_str());
      exit(1);
    } 
  } 

search finalization and results mockup

  ...
  for(t=0; t<threadsNum; t++){
    rc = pthread_join(threads[t], &status); 
    if (rc) {
      stringstream ss;
      ss << "Fatal thread error no. " << rc << " when joining.";
      logWarning(ss.str().c_str());
      pthread_detach(threads[t]);
    }
  }
  
  timeManager_->stopClock();
  //go through ucts from different threads and collect statistics into masterUct
  mockupSearchResults(board, ucts, masterUct, threadsNum); 
  ...
  //end Engine::doSearch

Generated on Thu Aug 6 23:29:07 2009 for akimot by  doxygen 1.5.7.1