-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcgobangchessboard.h
86 lines (68 loc) · 2.38 KB
/
cgobangchessboard.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/******************************
* Author : YangRongBao
* Date : 2021.4
******************************/
#ifndef CGOBANGCHESSBOARD_H
#define CGOBANGCHESSBOARD_H
#include "cgobangchessman.h"
#include <QTime>
#include <QImage>
#include <QLabel>
#include <QDebug>
#include <QObject>
#include <QWidget>
#include <QVector>
#include <QtGlobal>
#include <QPainter>
#include <QMouseEvent>
#define CHESSMAN_PIXEL_RADIUS 13
#define COLOR_BLACK QColor(0, 0, 0)
#define COLOR_EDGE QColor(130, 130, 130)
#define COLOR_WHITE QColor(255, 255, 255)
#define POWERVALUE0_05 0.05
#define POWERVALUE0_10 0.10
#define POWERVALUE0_90 0.90
#define POWERVALUE0_95 0.95
#define POWERVALUE1_00 1.00
#define POWERVALUE1_15 1.15
#define POWERVALUE1_20 1.20
#define INITIALADDSCORE 1.0
class CGobangChessboard : public QLabel
{
Q_OBJECT
signals:
void aiReady();
void aiPlayed(int indexX, int indexY, CGobangChessman::CChessmanType type);
void blackWin();
void checked(int indexX, int indexY, CGobangChessman::CChessmanType type);
void humanPlayed(int indexX, int indexY, CGobangChessman::CChessmanType type);
void targetChanged();
void whiteWin();
void win();
public:
explicit CGobangChessboard(QWidget *parent = nullptr);
void addScoreInitially(double score);
void restart();
protected:
private:
const int m_chessboardImagePixelLength = 511;
const int m_ellipsePixelRadius = 2;
const int m_linesPixelSpace = 31;
const int m_penPixelLength = 1;
int m_chessboardPositionIndexX = -1;
int m_chessboardPositionIndexY = -1;
QVector<CGobangChessman*> m_vectorPlayPositionsIndexHistory;
QVector<QImage*> m_vectorPlayImagesHistory;
CGobangChessman **m_virtualChessboard = nullptr;
CGobangChessman::CChessmanType m_playerChessmanType = CGobangChessman::CChessmanType::Chessman_Black;
private slots:
void ai();
void checkWin(const int indexX, const int indexY, const CGobangChessman::CChessmanType type);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void paintChessboard();
bool paintChessman(int indexX, int indexY, CGobangChessman::CChessmanType chessmanType);
void paintPredictor();
void updateScore(int indexX, int indexY, CGobangChessman::CChessmanType type);
};
#endif // CGOBANGCHESSBOARD_H