Beispiel #1
0
void ShtServer::onMatchFinished(const QString &uuid)
{
    qWarning() << "OnMatchFinished, uuid: " << uuid;
    Match *m = findMatch(uuid);
    matches.removeOne(m);
    m->deleteLater();
}
Beispiel #2
0
void main() {

	int gamesettings[7] = {0};
	Player players[2] = {Player(), Player()};
	Match match;
	match = Match();

	SetUpGame(gamesettings, players);

	for (int i = gamesettings[gamestoplay]; i > 0; i--) {
		match.Play(players, gamesettings);
	}

	cout << players[0].GetName() << "\t:\t" << players[1].GetName() << endl << endl;
	cout << players[0].matchwins << "\t:\t" << players[1].matchwins << endl << endl;
	for (int i = 0; i < 7; i++) {
		cout << "7\t:\t" << i << "\t:\t" << (float)(players[0].windensity[i]*100)/gamesettings[gamestoplay] << "%" << endl;
	}
	for (int i = 0; i < 7; i++) {
		cout << i << "\t:\t7\t:\t" << (float)(players[1].windensity[i]*100)/gamesettings[gamestoplay] << "%" << endl;
	}

	while(true){}



}
Beispiel #3
0
void MatchView::OnInitialUpdate()
{
	CFormView::OnInitialUpdate();

	// TODO: 在此添加专用代码和/或调用基类
	list_match.SetExtendedStyle(LVS_EX_FULLROWSELECT);

	list_match.InsertColumn(0, _T("比赛名称"), LVCFMT_CENTER);
	list_match.InsertColumn(1, _T("举办时间"), LVCFMT_CENTER);

	CHeaderCtrl* pHeader = list_match.GetHeaderCtrl();
	int nCurrWidth, nColHdrWidth;
	ASSERT(pHeader);
	list_match.SetRedraw(FALSE);
	for(int iCurrCol = 0; iCurrCol < pHeader->GetItemCount(); ++iCurrCol){
		list_match.SetColumnWidth(iCurrCol, LVSCW_AUTOSIZE);
		nCurrWidth = list_match.GetColumnWidth(iCurrCol);
		list_match.SetColumnWidth(iCurrCol, LVSCW_AUTOSIZE_USEHEADER);
		nColHdrWidth = list_match.GetColumnWidth(iCurrCol);
		list_match.SetColumnWidth(iCurrCol, max(nCurrWidth, nColHdrWidth));
	}
	list_match.SetRedraw(TRUE);
	list_match.Invalidate();

	Match mat;
	mat._meeting.ID = this->meetingID;
	vector<Match> v_match = mat.Query();
	vector<Match>::iterator i_d;
	for(i_d = v_match.begin(); i_d != v_match.end(); ++i_d){
		AddMatToList(&(*i_d));
	}
}
Beispiel #4
0
bool IndexParseData::write(const std::function<bool(const String &)> &write, const Match &match) const
{
    auto process = [&write, &match](const String &str, const Sources &sss) {
        if (!sss.isEmpty()) {
            if (!write(str + ":"))
                return false;

            for (const auto &ss : sss) {
                const Path file = Location::path(ss.first);
                if (match.isEmpty() || match.match(file)) {
                    write("  " + file + ":");
                    for (const auto &s : ss.second) {
                        if (!write("    " + s.toString()))
                            return false;
                    }
                }
            }
        }
        return true;
    };
    if (!process("Sources", sources))
        return false;

    for (const auto &commands : compileCommands) {
        if (!process(Location::path(commands.first), commands.second.sources))
            return false;
    }
    return true;
}
Beispiel #5
0
void Generator::convert(const Match & match,const GroebnerRule & r1,
         const GroebnerRule & r2,Polynomial & result) const {
  result.doubleProduct(match.const_left1(),r1.RHS(),match.const_right1());
  Polynomial temp;
  temp.doubleProduct(match.const_left2(),r2.RHS(),match.const_right2());
  result -= temp;
};
Beispiel #6
0
 bool operator() (const Match& a, const Match& b) const {
     Location la = a.getTarget();
     Location lb = b.getTarget();
     
     long sa = score(la);
     long sb = score(lb);
     
     return sa < sb;
 }
Beispiel #7
0
 void SerializeMatch(Writer &writer, const Match &match) {
     writer.StartObject();
     writer.Key("startEA");
     writer.Uint(match.getStartEA().getValue());
     writer.Key("endEA");
     writer.Uint(match.getEndEA().getValue());
     writer.Key("patternName");
     writer.String(match.getPatternName());
     writer.EndObject();
 }
Match * UserHandler::getMatch() {
    for (int i = 0; i < shared_data_->match_list.size(); i++) {
        Match * m = shared_data_->match_list.at(i);
        if ((m->getClubs()[0] == manager_->getClub()) || (m->getClubs()[1] == manager_->getClub())) {
            return m;
        }
    }

    return NULL;
}
Beispiel #9
0
int main(void)
{

    Time t (6,34,25);
    Match m;
    m.printTime(t);
    //printTime(t);
    system("pause");
    return 0;
}
Beispiel #10
0
void MatchView::OnBnClickedBuMDel()
{
	// TODO: 在此添加控件通知处理程序代码
	if(MessageBox(_T("确定删除所选比赛吗?"), _T("确认"), MB_YESNO | MB_ICONQUESTION) == IDNO)
		return;
	int n_se = list_match.GetSelectionMark();
	Match mat;
	mat.ID = list_match.GetItemData(n_se);
	mat.Delete();
	list_match.DeleteItem(n_se);
}
Beispiel #11
0
bool BracketVisElement::linkToMatch(const Match& ma) const
{
  Category myCat = getLinkedCategory();
  if (ma.getCategory() != myCat) return false;

  // lock the database before writing
  DbLockHolder lh{db, DatabaseAccessRoles::MainThread};

  row.update(BV_MATCH_REF, ma.getId());
  return true;
}
Beispiel #12
0
  void PairWiseDrawer::drawMatch(const Match& m, const Color3ub& c, bool drawLine) const
  {
    drawFeature(0, m.x(), c);
    drawFeature(1, m.y(), c);

    if(drawLine)
    {
      Vector2f a,b;
      a = scale(0)*m.posX(); b = scale(1)*(m.posY()+offF(1));
      DO::drawLine(a, b, c);
    }
  }
Beispiel #13
0
/** removes player from players list and removes
 *  all matches which he/she had participated
 */
void Group::removePlayer( Player player )
{
  _players.removeOne( player );
  QMutableListIterator<Match> i( _matches );
  while( i.hasNext() ) {
    Match m = i.next();
    if ( ( m.playerA() == player ) ||
         ( m.playerB() == player ) ) {
      i.remove();
    }
  }
}
Beispiel #14
0
/** \return earned rating for 'p' player. i.e. the sum of
 *          earned points per each match.
 */
double Group::earnedRating( Player p ) const
{
  double total = 0.0;
  for ( int i = 0; i < _matches.count(); i++) {
    Match m = _matches.at( i );

    if ( m.participated( p ) && m.played() ) {
      total += m.earnedRating( p );
    }
  }

  return total;
}
Beispiel #15
0
bool DataBase::_insertMatch(const Match &match) {
  QSqlQuery query(_db);
  query.prepare("insert into Match (match_id, time_stamp, game_type)"\
		" values(?, ?, ?)");
  query.addBindValue(match.getId());
  query.addBindValue(match.getDate().toTime_t());
  query.addBindValue(static_cast<int>(match.getMatchType()));
  if (!query.exec()) {
    qCritical() << "Could not insert match!\n";
    return false;
  }
  return _insertMatchDetails(match.getDetails());
}
Beispiel #16
0
/** Find all matches which player 'p' is participating.
 */
MatchList Group::matchList( Player p ) const
{
  MatchList ml;

  for ( int i = 0; i < _matches.count(); i ++ ) { 
    Match m = _matches.at( i );

    if ( m.participated( p ) ) {
      ml << m;
    } 
  }
 
  return ml; 
}
Beispiel #17
0
 // Method prints out the results for each set of input user tiles
 void printResults(const string l)
 {
   cout << setw(2) << highScore;
   cout << " " << l << ": ";
   for(Match::const_iterator itr = matching.begin(); itr != matching.end(); itr++)
     if(l == itr->first)
       cout << itr->second << " ";
     
   if(count == 0)
     cout << "No words found." << endl;
   else
     cout << endl;
   
   return;
 } // void printResults(const string l)
Beispiel #18
0
int MatchHelpers::inPenaltyArea(const Match& m, const Vector3& v)
{
	bool in_x = fabs(v.x) < 20.15f;
	float yp = v.y;

	if(!in_x)
		return 0;

	if(yp < m.getPitchHeight() * -0.5f + 16.5f)
		return -1;
	if(yp > m.getPitchHeight() * 0.5f - 16.5f)
		return 1;

	return 0;
}
// ---------------------------------------------------------------------------
//  Match: private helpers methods
// ---------------------------------------------------------------------------
void Match::initialize(const Match &toCopy){

  //do not copy over value of fPositionSize as it is irrelevant to the 
  //state of the Match

  fMemoryManager = toCopy.fMemoryManager;
  int toCopySize = toCopy.getNoGroups();
  setNoGroups(toCopySize);

  for (int i=0; i<toCopySize; i++){
    setStartPos(i, toCopy.getStartPos(i));
    setEndPos(i, toCopy.getEndPos(i));
  }           

}
Beispiel #20
0
MatchList Group::playedMatchList( Player p ) const
{
  MatchList ml;

  for ( int i = 0; i < _matches.count(); i ++ ) { 
    Match m = _matches.at( i );

    if ( ( m.playerA() == p ) || ( m.playerB() == p ) ) {
      if ( m.played() ) {
        ml << m;
      }
    } 
  }
 
  return ml; 
}
Beispiel #21
0
void MatchView::OnNMDblclkList1(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
	// TODO: 在此添加控件通知处理程序代码
	*pResult = 0;
	if(pNMItemActivate->iItem < 0) return;
	Match mat;
	mat.ID = list_match.GetItemData(pNMItemActivate->iItem);
	vector<Match> v_m = mat.Query();
	Dialog_Match_Prop d_Ma_Prop(TRUE);
	d_Ma_Prop._match = v_m[0];
	if(d_Ma_Prop.DoModal() == IDOK){
		list_match.SetItemText(pNMItemActivate->iItem, 0, d_Ma_Prop._match.Name);
		list_match.SetItemText(pNMItemActivate->iItem, 1, d_Ma_Prop._match.StartDate);
	}
}
MatchResDialog::MatchResDialog( Match match, QWidget* parent )
    : QDialog( parent ),
      _match( match ),
      _okButton( new QPushButton( tr( "Save" ) ) )
{
    setWindowTitle( tr( "Match score" ) );

    _okButton->setEnabled( false );

    QGridLayout* l = new QGridLayout( this );

    QLabel* playerA = new QLabel( match.playerA().name(), this );
    QLabel* playerB = new QLabel( match.playerB().name(), this );

    l->addWidget( playerA, 0, 0, Qt::AlignJustify );
    l->addWidget( playerB, 0, 1, Qt::AlignJustify );

    unsigned int games = match.games_const().count();
    for ( unsigned int i = 0; i < match.maxGames(); i ++ ) {
        QLineEdit* ballsA = new QLineEdit( this );
        QLineEdit* ballsB = new QLineEdit( this );

        if ( i < games ) {
            // this should be done before connecting of lineedits to textChanged
            // slot
            ballsA->setText( QString::number( match.games_const().at( i ).aBalls ) );
            ballsB->setText( QString::number( match.games_const().at( i ).bBalls ) );
        }

        connect( ballsA, SIGNAL( textChanged( const QString& ) ),
                 this, SLOT( textChanged( ) ) );
        connect( ballsB, SIGNAL( textChanged( const QString& ) ),
                 this, SLOT( textChanged( ) ) );

        l->addWidget( ballsA, i + 1, 0 );
        l->addWidget( ballsB, i + 1, 1 );
    }

    if ( games ) {
        textChanged();
    }

    l->addWidget( _okButton, l->rowCount(), 0, 1, 2 );

    connect( _okButton, SIGNAL( clicked() ), this, SLOT( okButtonClicked() ) );
}
Beispiel #23
0
/** Find match which corresponds to player 'a' and 'b' pair.
 */
Match& Group::match( Player a, Player b )
{
  for ( int i = 0; i < _matches.count(); i ++ ) { 
    Match m = _matches.at( i );

    if ( ( m.playerA() == a ) && ( m.playerB() == b ) ) {
      return _matches[ i ];
    } else if ( ( m.playerB() == a ) && ( m.playerA() == b ) ) {
      _matches[i].swapPlayers();
      return _matches[ i ];
    } 
  }

  // should never get here!  
  qWarning() <<  "can't find match of " << a.name() << "and" << b.name();
  return (* new Match( a, b ) );
}
Beispiel #24
0
bool Project::match(const Match &p)
{
    Path paths[] = { p.pattern(), p.pattern() };
    paths[1].resolve();
    const int count = paths[1].compare(paths[0]) ? 2 : 1;
    Scope<const FilesMap&> files = lockFilesForRead();
    for (int i=0; i<count; ++i) {
        const Path &path = paths[i];
        if (files.data().contains(path) || p.match(mPath))
            return true;
        const uint32_t id = Location::fileId(path);
        if (isIndexed(id))
            return true;

    }
    return false;
}
Beispiel #25
0
MatchList Group::matchList( Player a, Player b ) const
{
  MatchList ml;

  for ( int i = 0; i < _matches.count(); i ++ ) { 
    Match m = _matches.at( i );

    if ( m.participated( a ) && m.participated( b ) ) {
      if ( !( m.playerA() == a ) ) {
        // right player order required
        m.swapPlayers();
      }
      ml << m;
    } 
  }

  return ml;
}
Beispiel #26
0
double MatchHelpers::distanceToPitch(const Match& m,
		const Vector3& v)
{
	float r = m.getPitchWidth() * 0.5f;
	float l = -r;
	float u = m.getPitchHeight() * 0.5f;
	float d = -u;
	if(v.x >= l && v.x <= r && v.y >= d && v.y <= u)
		return 0.0f;
	float dhoriz = v.x < l ? l - v.x : v.x - r;
	float dvert  = v.y < d ? d - v.y : v.y - u;
	if(dvert < 0)
		return dhoriz;
	else if(dhoriz < 0)
		return dvert;
	else
		return sqrt(dvert * dvert + dhoriz * dhoriz);
}
Beispiel #27
0
void PsmFile::insertMatches(const vector<Match>& matches){

    // insert the result into tables msRunSearchResult, BiblioSpecSearchResult
    char zSql[2048];
    double pValue = -1;

    for(int i = 0; i < reportMatches_; i++) {
        Match tmpMatch = matches.at(i);
        const RefSpectrum* tmpRefSpec = tmpMatch.getRefSpec();
        //        const Spectrum* s = tmpMatch.getExpSpec();

       pValue = -1 * log(tmpMatch.getScore(BONF_PVAL));
        if(isinf( pValue ))
            pValue = 1000;

        sprintf(zSql,
                "insert into msRunSearchResult(runSearchID,scanID,charge,"
                "peptide,preResidue, postResidue, validationStatus) "
                "values(%d,%d,%d,'%s','%s','%s','=')",
                blibRunSearchID_,
                0,//                s->getScanID(),
                0,//tmpRefSpec->getCharge(),
                (tmpRefSpec->getSeq()).c_str(),
                (tmpRefSpec->getPrevAA()).c_str(),
                (tmpRefSpec->getNextAA()).c_str());
        SqliteRoutine::SQL_STMT(zSql, db_);
        
        zSql[0]='\0';
        
        int resultID=(int)sqlite3_last_insert_rowid(db_);
        sprintf(zSql, "insert into BiblioSpecSearchResult "
                "values(%d,%d,%d,%d,%f,%f,'%s')",
                resultID,
                tmpRefSpec->getLibSpecID(),
                tmpMatch.getMatchLibID(),
                i+1,
                tmpMatch.getScore(DOTP),
                pValue,
                tmpRefSpec->getMods().c_str());
        SqliteRoutine::SQL_STMT(zSql, db_);
        zSql[0]='\0';
    } // next match

}
Beispiel #28
0
int main( int argc, char** argv ) {
	QApplication app( argc, argv );
	MainWindow mainWindow;;
	mainWindow.show();

#if 0
	QTextEdit textEdit;
	textEdit.setReadOnly( true );
	textEdit.show();
#endif
	
	Match match;
	match.add( new TestBot( "test1" ) );
	match.add( new TestBot( "test2" ) );
	match.add( new Arena() );
	match.display();
	
	return app.exec();
}
Beispiel #29
0
void MatcherMonomial::constructMatch( const Monomial & mona,int a,
       const Monomial & monb,int b, const subMonomial & aINode,
       const subMonomial & bINode, MATCHING_TYPES type,
       Match & match ) const {
  match.firstGBData = a;
  match.secondGBData = b;

  const int bStartm1 = bINode.start()-1;
  MonomialIterator iter = monb.begin();
  int i=1;
  for(;i<=bStartm1;++i,++iter) {
    match.left1() *= (* iter);
  }
  const int bNumFactor = monb.numberOfFactors();
  int temp2 = bINode.start()+bINode.length();
  if(temp2<=bNumFactor) {
    MonomialIterator iter2 = monb.begin();
    int jj = temp2-1;
    while(jj) { ++iter2;--jj;};
    for(int j=temp2;j<=bNumFactor;++j,++iter2) {
      match.right1() *= (* iter2);
    }
  }
  if(type==SUBSET_MATCH) {
    match.subsetMatch = false;
    match.overlapMatch = true;  
  } else if(type==OVERLAP_MATCH) {
    match.subsetMatch = false;
    match.overlapMatch = true;
    const int aStartm1 = aINode.start()-1;
    MonomialIterator iter3 = mona.begin(); 
    for(i=1;i<=aStartm1;++i,++iter3) {   
       match.left2() *= (* iter3);
    }   
    MonomialIterator iter4 = mona.begin(); 
    const int temp4 = aINode.start()+aINode.length();
    int jj = temp4-1;
    while(jj) { ++iter4;--jj;};
    for(int j=temp4;j<=mona.numberOfFactors();++j,++iter4) {   
       match.right2() *= (* iter4);
    }   
  }
};
Beispiel #30
0
int Project::reindex(const Match &match)
{
    Set<uint32_t> dirty;
    {
        MutexLocker lock(&mMutex);

        const DependencyMap::const_iterator end = mDependencies.end();
        for (DependencyMap::const_iterator it = mDependencies.begin(); it != end; ++it) {
            if (match.isEmpty() || match.match(Location::path(it->first))) {
                dirty.insert(it->first);
            }
        }
        if (dirty.isEmpty())
            return 0;
        mModifiedFiles += dirty;
    }
    startDirtyJobs();
    return dirty.size();
}