Esempio n. 1
0
void PseudorandomNumber::initRandomNumbers(size_t size){
	for (size_t i = 0; i < size; i++){
		_randomNumbers.push_back(_dis(_gen));
		if (_randomNumbers.size() % 10000 == 0){
			CCLOG("%u", _randomNumbers.size());
		}
	}
}
Esempio n. 2
0
bool Find_Farest_2points(Point &p1, Point &p2)
{
  double max_dis = -EPS;
  for(int i = 1; i <= cnt_hpi; i++)
    for(int j = 1; j <= cnt_hpi; j++) {
      double tmp = _dis(hpi[i], hpi[j]);
      if(tmp > max_dis) {
        max_dis = tmp;
        p1 = hpi[i], p2 = hpi[j];
      }
    }
  return cnt_hpi > 0;
}
std::vector<std::string>
HTTPFrontEndObj::onQuery(std::unique_ptr<cv::Mat> &&image,
                         std::unique_ptr<CameraModel> &&camera) {
  std::unique_ptr<Session> session(new Session);
  session->overallStart = getTime(); // log start of processing
  session->type = HTTP_POST;

  std::unique_ptr<SessionData> sessionData(new SessionData);
  QSemaphore &detected = sessionData->detected;

  _mutex.lock();
  long id = _dis(_gen); // this is not thread safe
  _sessionMap.emplace(id, std::move(sessionData));
  _mutex.unlock();

  session->id = id;

  QCoreApplication::postEvent(
      _identObj.get(),
      new QueryEvent(std::move(image), std::move(camera), std::move(session)));

  // TODO use condition variable?
  detected.acquire();

  _mutex.lock();
  auto iter = _sessionMap.find(id);
  sessionData = std::move(iter->second);
  _sessionMap.erase(id);
  _mutex.unlock();

  assert(sessionData != nullptr);
  assert(sessionData->session != nullptr);

  session = std::move(sessionData->session);

  // print time
  session->overallEnd = getTime(); // log processing end time
  std::cout << "Time overall: " << session->overallEnd - session->overallStart
            << " ms" << std::endl;
  std::cout << "Time features: "
            << session->featuresEnd - session->featuresStart << " ms"
            << std::endl;
  std::cout << "Time words: " << session->wordsEnd - session->wordsStart
            << " ms" << std::endl;
  std::cout << "Time perspective: "
            << session->perspectiveEnd - session->perspectiveStart << " ms"
            << std::endl;

  return *(sessionData->names);
}
Ruch Gracz3::ruch( Ruch stary_ruch ) {
	Ruch _return;

	//limiter 6 od 0
	//numer podpuszczacza od 1

	if( limiter_szesciu < 8 ) {
		_return = podpuszczacz( numer_podpuszczacza );
	}
	if( numer_podpuszczacza > 8 ) {
		numer_podpuszczacza = 1;
		kiedy_badanie = 0;
	}

	//---------------------zapis danych

	//---------------------zaczyna docelowy alg--------------------//
	if( limiter_szesciu > 19 ) {
		std::cout << win_ratio() << std::endl;
		jego_okres.push_back( analizer_up( ruchy, 12 ) );
		if( win_ratio() < 0.3 && limiter_szesciu > 40 ) {
			_return = Ruch( _dis( _gen ) );;
		}
		else if( win_ratio() < 0.75 && kiedy_badanie > static_cast<int>(1000 / (kiedy_badanie + 1) && limiter_szesciu > 50) ) {
			_return = podpuszczacz( numer_podpuszczacza );
			//std::cout << "podpuszczacz" << std::endl;
		}
		else if( analizer_up( ruchy, 8 ) == -1 ) {//brak schematu
			if( limiter_szesciu > 50 )
				_return = kontrator( statystyka( 45 ) );
			else
				_return = kontrator( statystyka( limiter_szesciu-1 ) );
		}
		else if( analizer_up( ruchy, 8 ) > 0 ) {//jakis okres
			_return = kontrator( jaki_ruch_okresu( ruchy, 8, analizer_up( ruchy, 8 ) ) );
		}
	}
	else if( limiter_szesciu > 7 && limiter_szesciu < 20) {
		jego_okres.push_back( analizer_up( ruchy, ruchy.size() ) );
		if( analizer_up( ruchy, ruchy.size() ) == -1 ) {
			_return = statystyka( ruchy.size() );
		}
		else {
			_return = kontrator( jaki_ruch_okresu( ruchy, ruchy.size(), analizer_up( ruchy, ruchy.size() ) ) );
		}
	}

	
		ruchy.push_back( stary_ruch );
		moje_ruchy.push_back( _return );
		if( limiter_szesciu > 4 ) {
			if( czy_wygralem( moje_ruchy, ruchy, ruchy.size() - 1 ) ) {
				wygr.ja++;
				wygr.wygrana_tab.push_back( 1 );
			}
			else {
				wygr.on++;
				wygr.wygrana_tab.push_back( 0 );
			}
		}
	
	

	kiedy_badanie++;
	limiter_szesciu++;
	return _return;
}