-
大小: 10KB文件類型: .rar金幣: 2下載: 0 次發(fā)布日期: 2021-05-20
- 語(yǔ)言: 其他
- 標(biāo)簽:
資源簡(jiǎn)介
用Qt寫的單機(jī)版五子棋游戲的源代碼,可供參考。

代碼片段和文件信息
#include?“dialog.h“
SelectDialog::SelectDialog(QWidget?*?parent?Qt::WindowFlags?f)
????:?QDialog(parent)
{
bAlgorithm?=?0;
wAlgorithm?=?0;
times?=?100;
setFixedSize(250?150);
QTextCodec::setCodecForTr(QTextCodec::codecForLocale());
setWindowtitle(tr(“選擇算法及對(duì)戰(zhàn)次數(shù)“));
blackAlgorithm?=?new?QComboBox;
blackAlgorithm->addItem(tr(“算法1(隨機(jī)算法)“)?1);
blackAlgorithm->addItem(tr(“算法2(貪心算法)“)?2);
blackAlgorithm->addItem(tr(“算法3(改進(jìn)的隨機(jī)算法)“)?3);
connect(blackAlgorithm?SIGNAL(currentIndexChanged(int))
this?SLOT(bAlgorithmChanged(int)));
whiteAlgorithm?=?new?QComboBox;
whiteAlgorithm->addItem(tr(“算法1(隨機(jī)算法)“)?1);
whiteAlgorithm->addItem(tr(“算法2(貪心算法)“)?2);
whiteAlgorithm->addItem(tr(“算法3(改進(jìn)的隨機(jī)算法)“)?3);
connect(whiteAlgorithm?SIGNAL(currentIndexChanged(int))
this?SLOT(wAlgorithmChanged(int)));
label1?=?new?QLabel(tr(“黑棋的算法為:“)?this);
QHBoxLayout?*?layout1?=?new?QHBoxLayout;
layout1->addWidget(label1);
layout1->addWidget(blackAlgorithm);
label2?=?new?QLabel(tr(“白棋的算法為:“)?this);
QHBoxLayout?*?layout2?=?new?QHBoxLayout;
layout2->addWidget(label2);
layout2->addWidget(whiteAlgorithm);
label3?=?new?QLabel(tr(“對(duì)戰(zhàn)的次數(shù)為:“)?this);
currentTimesSlider?=?new?QSpinBox(this);
currentTimesSlider->setRange(01000);
currentTimesSlider->setSingleStep(100);
currentTimesSlider->setValue(100);
connect(currentTimesSlider?SIGNAL(valueChanged(int))?this
SLOT(currentTimesChanged(int)));
QHBoxLayout?*?layout3?=?new?QHBoxLayout;
layout3->addWidget(label3);
layout3->addWidget(currentTimesSlider);
okButton?=?new?QPushButton(tr(“確定“)?this);
connect(okButton?SIGNAL(clicked())?this?SLOT(OK()));
QHBoxLayout?*?layout4?=?new?QHBoxLayout;
layout4->addWidget(okButton);
QVBoxLayout?*?mainLayout?=?new?QVBoxLayout;
mainLayout->addLayout(layout1);
mainLayout->addLayout(layout2);
mainLayout->addLayout(layout3);
mainLayout->addLayout(layout4);
setLayout(mainLayout);
}
SelectDialog::~SelectDialog()
{
}
void?SelectDialog::bAlgorithmChanged(int?value)
{
bAlgorithm?=?value;
}
void?SelectDialog::wAlgorithmChanged(int?value)
{
wAlgorithm?=?value;
}
void?SelectDialog::OK()
{
close();
}
void?SelectDialog::currentTimesChanged(int?value)
{
times?=?value;
}
void?SelectDialog::getValue(int?&?bAlgo?int?&?wAlgo?int?&?currentTimes)
{
bAlgo?=?bAlgorithm;
wAlgo?=?wAlgorithm;
currentTimes?=?times;
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????2496??2012-04-23?19:38??單機(jī)版五子棋游戲\dialog.cpp
?????文件???????1077??2012-04-23?19:38??單機(jī)版五子棋游戲\dialog.h
?????文件????????183??2012-04-23?19:39??單機(jī)版五子棋游戲\main.cpp
?????文件???????8296??2012-04-23?19:39??單機(jī)版五子棋游戲\window.cpp
?????文件???????1207??2012-04-23?19:39??單機(jī)版五子棋游戲\window.h
?????文件??????17262??2012-04-23?19:39??單機(jī)版五子棋游戲\Wuziqi.cpp
?????文件???????2582??2012-04-23?19:39??單機(jī)版五子棋游戲\Wuziqi.h
?????目錄??????????0??2012-04-23?19:39??單機(jī)版五子棋游戲
-----------?---------??----------?-----??----
????????????????33103????????????????????8
評(píng)論
共有 條評(píng)論