int showStats(int step, int totalSteps, int step_stat){ t_end = clock(); double time_used = (double)(t_end - t_start) / CLOCKS_PER_SEC; double time_per_step = time_used / step; double time_remaining = time_per_step*(totalSteps - step); int maxSize = maxCorrectSize(); static int historyMax = 0; if (historyMax < maxSize)historyMax = maxSize; cout << endl << step << '/' << totalSteps << " steps" << endl; cout << "max size: " << maxSize << endl; cout << "max pseudo size: " << max_pseudo_size << endl; cout << "time used: "; timeDisplay(time_used); cout << "time per " << step_stat << " steps: " << time_per_step * step_stat << endl; cout << "estimated remaining time: "; timeDisplay(time_remaining); cout << endl; if (step % 100000 == 0){ char fn[30] = "F:\\coordinates"; char num[10]; _itoa_s(step, num, 10); strcat_s(fn, sizeof(fn), num); strcat_s(fn, sizeof(fn), ".txt"); ofstream coorOut(fn); //coorOut << T << endl << step << endl << maxSize << endl << historyMax << endl; for (int i = 0; i < N; i++){ coorOut << mol[i].px.x << '\t' << mol[i].px.y << '\t' << mol[i].px.z << '\t' << mol[i].outputTrace << endl; } coorOut.close(); } //char fn[30] = "F:\\sizeat"; //char num[10]; //_itoa_s((int)T, num, 10); //strcat_s(fn, sizeof(fn), num); //strcat_s(fn, sizeof(fn), "K.txt"); //static ofstream sizeOut(fn); //sizeOut << step << '\t' << maxSize << endl; return 0; }
void Dialog::connections() { connect(m_chbTimer, SIGNAL(clicked(bool)), this, SLOT(toggleTimer(bool))); connect(m_bStart, SIGNAL(clicked()), this, SLOT(start())); connect(m_bStop, SIGNAL(clicked()), this, SLOT(stop())); connect(m_Protocol, SIGNAL(DataIsReaded(bool)), this, SLOT(received(bool))); connect(m_BlinkTimeTxColor, SIGNAL(timeout()), this, SLOT(colorIsTx())); connect(m_BlinkTimeRxColor, SIGNAL(timeout()), this, SLOT(colorIsRx())); connect(m_BlinkTimeTxNone, SIGNAL(timeout()), this, SLOT(colorTxNone())); connect(m_BlinkTimeRxNone, SIGNAL(timeout()), this, SLOT(colorRxNone())); connect(m_bRec, SIGNAL(clicked()), this, SLOT(record())); connect(m_BlinkTimeRec, SIGNAL(timeout()), this, SLOT(blinkRecButton())); connect(m_bStopRec, SIGNAL(clicked()), this, SLOT(stopRec())); connect(m_bSetRate, SIGNAL(clicked()), this, SLOT(setRate())); connect(m_TimeDisplay, SIGNAL(timeout()), this, SLOT(timeDisplay())); QShortcut *aboutShortcut = new QShortcut(QKeySequence("F1"), this); connect(aboutShortcut, SIGNAL(activated()), qApp, SLOT(aboutQt())); }
void MainInterface::Init() { QFont ft; ft.setPointSize(30); QPalette pa; pa.setColor(QPalette::WindowText,Qt::white); time=20; MoveDistance=0; m_pickingCardTimer=new QTimer(this); m_pickingCardTimer->setInterval(8); connect(m_pickingCardTimer,SIGNAL(timeout()),this,SLOT(PickingCards())); /*****设置移动的牌和放在中间不动的牌***********/ m_AllCardsPic.load(":/img/res/card2.png"); m_cardBackPic = m_AllCardsPic.copy(160,4*105,80,105); m_basecardPos = QPoint( (width()-card_width)/2, height()/2-100 ); m_movingcard=new CardPicture(this); m_basecard=new CardPicture(this); m_movingcard->setPic(m_cardBackPic); m_basecard->setPic(m_cardBackPic); m_movingcard->move(m_basecardPos); m_basecard->move(m_basecardPos); //闹钟图片 m_clock=new QLabel(this); m_clock->setPixmap(QPixmap(":/img/res/clock.png")); m_clock->move((width()-m_clock->width())/2+20,(height()-m_clock->width())/2-50); m_clock->hide(); m_rePickingCards = new QLabel(this); m_rePickingCards->setText("重新发牌"); m_rePickingCards->setFont(ft); m_rePickingCards->setPalette(pa); m_rePickingCards->move((width()-m_clock->width())/2-50,(height()-m_clock->height())/2); m_rePickingCards->hide(); m_timeLabel=new QLabel(this); m_timeLabel->setFont(ft); m_timeLabel->setPalette(pa); m_timeLabel->move(490,350); m_timeLabel->hide(); timer=new QTimer(this); timer->setInterval(1000); connect(timer,SIGNAL(timeout()),this,SLOT(timeDisplay())); /**********按钮初始化*****************/ /*开始按钮*/ m_start= new QPushButton(this); m_start->setText("开始游戏"); m_start->move((width()-m_start->width())/2+10,height()-card_height-20); connect(m_start,SIGNAL(clicked()),this,SLOT(on_start_clicked())); /*叫地主按钮*/ m_bet0=new QPushButton(this); m_bet1=new QPushButton(this); m_bet2=new QPushButton(this); m_bet3=new QPushButton(this); m_bet0->hide(); m_bet1->hide(); m_bet2->hide(); m_bet3->hide(); m_bet0->setText("不叫地主"); m_bet1->setText("1分"); m_bet2->setText("2分"); m_bet3->setText("3分"); m_bet0->move(320,height()-card_height-40); m_bet1->move(420,height()-card_height-40); m_bet2->move(520,height()-card_height-40); m_bet3->move(620,height()-card_height-40); connect(m_bet0,SIGNAL(clicked()),this,SLOT(on_bet0_clicked())); connect(m_bet1,SIGNAL(clicked()),this,SLOT(on_bet1_clicked())); connect(m_bet2,SIGNAL(clicked()),this,SLOT(on_bet2_clicked())); connect(m_bet3,SIGNAL(clicked()),this,SLOT(on_bet3_clicked())); /*出牌,提示和要不起按钮*/ m_playhand=new QPushButton(this); m_pass = new QPushButton(this); m_tip = new QPushButton(this); m_playhand->hide(); m_pass->hide(); m_tip->hide(); m_playhand->setText("出牌"); m_pass->setText("要不起"); m_tip->setText("提示"); m_pass->move(width()/2-120,height()-card_height-40); m_playhand->move(width()/2-20,height()-card_height-40); m_tip->move(width()/2+80,height()-card_height-40); connect(m_playhand,SIGNAL(clicked()),this,SLOT(on_playhand_clicked())); connect(m_pass,SIGNAL(clicked()),this,SLOT(on_pass_clicked())); connect(m_tip,SIGNAL(clicked()),this,SLOT(on_tip_clicked())); /*继续按钮*/ m_continue= new QPushButton(this); m_continue->hide(); m_continue->setText("继续游戏"); m_continue->move((width()-m_continue->width())/2+10,height()-card_height-40); connect(m_continue,SIGNAL(clicked()),this,SLOT(on_continue_clicked())); /*音效*/ bkMusic=new QSound(":/sound/res/bkMusic.wav",this); winMusic=new QSound(":/sound/res/win.wav",this); loseMusic=new QSound(":/sound/res/loseMusic.wav",this); shuffleCardsMusic=new QSound(":/sound/res/shuffleCardsMusic.wav",this); noCallMusic=new QSound(":/sound/res/bujiao.wav",this); callLordMusic=new QSound(":/sound/res/jiaodizhu.wav",this); bkMusic->play(); bkMusic->setLoops(-1); /*叫分标识*/ m_gameprocess->getDownPlayer()->betLabel=new QLabel(this); m_gameprocess->getDownPlayer()->betLabel->setFont(ft); m_gameprocess->getDownPlayer()->betLabel->setPalette(pa); m_gameprocess->getDownPlayer()->betLabel->move(width()/2-20,(height()-card_height-70)); m_gameprocess->getLeftPlayer()->betLabel=new QLabel(this); m_gameprocess->getLeftPlayer()->betLabel->setFont(ft); m_gameprocess->getLeftPlayer()->betLabel->setPalette(pa); m_gameprocess->getLeftPlayer()->betLabel->move(150,m_basecardPos.y()); m_gameprocess->getRightPlayer()->betLabel=new QLabel(this); m_gameprocess->getRightPlayer()->betLabel->setFont(ft); m_gameprocess->getRightPlayer()->betLabel->setPalette(pa); m_gameprocess->getRightPlayer()->betLabel->move(width()-250,m_basecardPos.y()); /*要不起的标识*/ m_gameprocess->getDownPlayer()->passLabel=new QLabel(this); m_gameprocess->getDownPlayer()->passLabel->setText("要不起"); m_gameprocess->getDownPlayer()->passLabel->move(width()/2-50,(height()-card_height-100)); m_gameprocess->getDownPlayer()->passLabel->setFont(ft); m_gameprocess->getDownPlayer()->passLabel->setPalette(pa); m_gameprocess->getDownPlayer()->passLabel->hide(); m_gameprocess->getLeftPlayer()->passLabel=new QLabel(this); m_gameprocess->getLeftPlayer()->passLabel->setText("要不起"); m_gameprocess->getLeftPlayer()->passLabel->move(150,m_basecardPos.y()); m_gameprocess->getLeftPlayer()->passLabel->setFont(ft); m_gameprocess->getLeftPlayer()->passLabel->setPalette(pa); m_gameprocess->getLeftPlayer()->passLabel->hide(); m_gameprocess->getRightPlayer()->passLabel=new QLabel(this); m_gameprocess->getRightPlayer()->passLabel->setText("要不起"); m_gameprocess->getRightPlayer()->passLabel->move(width()-250,m_basecardPos.y()); m_gameprocess->getRightPlayer()->passLabel->setFont(ft); m_gameprocess->getRightPlayer()->passLabel->setPalette(pa); m_gameprocess->getRightPlayer()->passLabel->hide(); /*角色标识*/ m_gameprocess->getDownPlayer()->roleLabel=new QLabel(this); m_gameprocess->getDownPlayer()->roleLabel->move(700,400); m_gameprocess->getDownPlayer()->roleLabel->hide(); m_gameprocess->getLeftPlayer()->roleLabel=new QLabel(this); m_gameprocess->getLeftPlayer()->roleLabel->move(110,50); m_gameprocess->getLeftPlayer()->roleLabel->hide(); m_gameprocess->getRightPlayer()->roleLabel=new QLabel(this); m_gameprocess->getRightPlayer()->roleLabel->move(820,50); m_gameprocess->getRightPlayer()->roleLabel->hide(); }