人机对战实战用SingleGame.h
#ifndef SINGLEGAME_H
#define SINGLEGAME_H
#include "Board.h"
#include "Step.h"
class SingleGame : public Board
{
public:
SingleGame();
void click(int id, int row,int col); // 重写点击函数
void getAllPossibleMove(QVector<Step *> &steps); // 获取所有可能的结果保存
Step* getBestMove(); // 根据规则获取最优的移动
void fakeMove(Step* step);
void unfakeMove(Step* step);
int calcScore();
};
#endif // SINGLEGAME_H
SingleGame类继承自Board类
click为重写虚函数
此时主函数变为
main.cpp
#include <QApplication>
#include "SingleGame.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
SingleGame w;
w.show();
return a.exec();
}
重写click函数如下
void SingleGame::click(int id,int row,int col)
{
if(!thi