五子棋规则

 

五子棋竞赛规则

一、五子棋棋盘

棋盘正中一点为“天元”。棋盘两端的横线称端线。棋盘左右最外边的两条纵线称边线。从两条端线和两条边线向正中发展而纵横交叉在第四条线形成的四个点称为“星”。天元和星应在棋盘上用直径约为0.5厘米的实心小圆点标出。

以持黑方为准,棋盘上的纵轴线从左到右用英文字母A~O标记。横行线从近到远用阿拉伯数字1-15标记。纵横轴上的横纵线交叉点分别用横纵线标记的名称合写成。如“天元”H8,四个“星”分别为D4、D12、L12、L4等。

二、五子棋比赛规则

五子棋行棋顺序
    黑先、白后,从天元开始相互顺序落子。

五子棋判断胜负
    最先在棋盘横向、竖向、斜向形成连续的相同色五个棋子的一方为胜。
    黑棋禁手判负(Lose),白棋无禁手。黑棋禁手包括“三、三”(Double Three)(包括“四、三、三”)、“四、四”(Double Four)(包括“四、四、三”)、“长连”(Overline)。黑棋只能以“四、三”取胜。
    如分不出胜负,则定为平局(Draw)。
    对局中中途退场判为负。
    五连与禁手同时形成,先五为胜。
    黑方禁手形成时,白方应立即指出。若白方未发现或发现后未指明而继续应子,则不能判黑方负。
    时间限定:每方20分钟包干,然后1分钟读秒。

五子棋规则的解释
禁手的解释
图2至图9的x点为黑棋的禁手点。

三三禁手(图2)


三三禁手(图3)


四四禁手(图4)


四四禁手(图5)


四四禁手(图6)


四四禁手(扁担阵)(图7)


四三三禁手(图8)


长连禁手(图9)


关于非禁手
图10“a”这一点不是三三,因为横向不是活三,而是一个长连禁手的骨架(日本称为“六腐”)。

(图10)

图11“a”这一点也不是三三,因为横向也不是活三,而是一个假活三(此形状日本称之为“下止”)。


(图11)

图12“a”这一点有可能被看作是三三。但是,由于竖跳三的下一手在x点将成四四禁手而不能走,这种竖三属于死三,所以a点不算三三。

(图12)

三、五子棋定义和术语
一着:在对局过程中,行棋方把棋子落在棋盘无子的交叉点上,不论落子的手是否脱离棋子,均被视为一着。
回合:双方和走一着,称为一个回合。
一方
黑方:执黑棋一方的简称。
白方:执白棋一方的简称。
轮走方:对局即将开始时的黑方或在对局过程中一方着法完毕后的另一方或在“三手可交换”中如果白方提出交换黑白棋后新的白方。
开局:由黑棋下二着,白棋下一着,在对局开始阶段形成的布局。
对局
胜局:有一方获胜的对局。
追下取胜:白棋利用抓黑棋禁手取胜。
自由取胜:追下取胜以外的技术性取胜。
VCF胜。
和局:分不出胜负的对局。
终局:对局结束。
连:在棋阳线和阴线的任意一条线上形成的有5个或5个以上的同色棋子不间隔地紧紧相连。
五连:在棋盘上形成的5个同色棋子的“连”。
长连:在棋盘上形成的6个或6个以上同色棋子的“连”。
“四”包括“活四”和“冲四”。
活四:在棋盘某一条阳线或阴线上有同色4子不间隔地紧紧相连,且在此4子两端延长线上各有一个无子的交叉点与此4子紧密相连。(图13)

(图13)

冲四:除“活四”外的,再下一着棋便可形成五连,并且存在五连的可能性的局面。(图14,15)

(图14)


(图15)


白棋再下一着可形成长连的局面也视为“四”。(图16)

(图16)

“三”指活三,包括“连三”和“跳三”。
连三:在棋盘某一条阳线或阴线上有同色三子相连,且在此三子两端延长线上有一端至少有一个,另一端至少有两个无子的交叉点与此三子紧密相连。
跳三:中间仅间隔一个无子交叉点的连三,但两端延长线均至少有一个无子的交叉点与此三子相连。
禁手:对局中禁止使用的着法。
黑棋禁手包括“三三”、“四四”和“长连”。
三三:由于黑方走一着在无子交叉点上同时形成二个或二个以上黑方“活三”的局面。(图17)

(图17)

四四:由于黑方走一着在无子交叉点上同时形成二个或二个以上黑方“四”的局面。(图18)

(图18)

白棋无禁手。
“四三”:指某一方同时具备两个先手,其中一个是“四”,一个是“活三”。
先手:对方必须应答的着法,其中“冲四”称为绝对先手。
计分:

局分:
胜方得2分,负方得-2分。

转自:http://www.itiyu.com/project/chess/331/rule.htm

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
以下是符合5.14.2qt版本的代码,实现五子棋规则和悔棋功能: mainwindow.h ``` #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QPushButton> #include <QLabel> #include <QGridLayout> #include <QMessageBox> class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(QWidget *parent = nullptr); ~MainWindow(); private slots: void buttonClicked(); void undoClicked(); private: QPushButton *buttons[15][15]; QPushButton *undoButton; QLabel *messageLabel; QGridLayout *gridLayout; int chessboard[15][15]; int currentPlayer; bool gameOver; int steps; int history[225][3]; void initUI(); void initChessboard(); bool checkWin(int row, int col); bool checkHorizontal(int row, int col); bool checkVertical(int row, int col); bool checkDiagonal1(int row, int col); bool checkDiagonal2(int row, int col); void showMessage(QString message); void updateChessboard(int row, int col); void undoChessboard(); }; #endif // MAINWINDOW_H ``` mainwindow.cpp ``` #include "mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { initUI(); initChessboard(); } MainWindow::~MainWindow() { } void MainWindow::initUI() { QWidget *centralWidget = new QWidget(this); setCentralWidget(centralWidget); gridLayout = new QGridLayout(centralWidget); gridLayout->setSpacing(0); for (int i = 0; i < 15; i++) { for (int j = 0; j < 15; j++) { buttons[i][j] = new QPushButton(centralWidget); buttons[i][j]->setFixedSize(40, 40); buttons[i][j]->setProperty("row", i); buttons[i][j]->setProperty("col", j); gridLayout->addWidget(buttons[i][j], i, j); connect(buttons[i][j], SIGNAL(clicked()), this, SLOT(buttonClicked())); } } undoButton = new QPushButton(tr("悔棋"), centralWidget); undoButton->setFixedSize(80, 40); connect(undoButton, SIGNAL(clicked()), this, SLOT(undoClicked())); gridLayout->addWidget(undoButton, 15, 0, 1, 2); messageLabel = new QLabel(centralWidget); messageLabel->setFixedSize(150, 40); gridLayout->addWidget(messageLabel, 15, 2, 1, 13, Qt::AlignLeft | Qt::AlignVCenter); setFixedSize(620, 620); setWindowTitle(tr("五子棋")); } void MainWindow::initChessboard() { for (int i = 0; i < 15; i++) { for (int j = 0; j < 15; j++) { chessboard[i][j] = 0; } } currentPlayer = 1; gameOver = false; steps = 0; memset(history, 0, sizeof(history)); showMessage(tr("黑方先手")); } bool MainWindow::checkWin(int row, int col) { if (checkHorizontal(row, col) || checkVertical(row, col) || checkDiagonal1(row, col) || checkDiagonal2(row, col)) { return true; } return false; } bool MainWindow::checkHorizontal(int row, int col) { int count = 1; for (int i = col - 1; i >= 0; i--) { if (chessboard[row][i] == chessboard[row][col]) { count++; } else { break; } } for (int i = col + 1; i < 15; i++) { if (chessboard[row][i] == chessboard[row][col]) { count++; } else { break; } } if (count >= 5) { return true; } return false; } bool MainWindow::checkVertical(int row, int col) { int count = 1; for (int i = row - 1; i >= 0; i--) { if (chessboard[i][col] == chessboard[row][col]) { count++; } else { break; } } for (int i = row + 1; i < 15; i++) { if (chessboard[i][col] == chessboard[row][col]) { count++; } else { break; } } if (count >= 5) { return true; } return false; } bool MainWindow::checkDiagonal1(int row, int col) { int count = 1; for (int i = row - 1, j = col - 1; i >= 0 && j >= 0; i--, j--) { if (chessboard[i][j] == chessboard[row][col]) { count++; } else { break; } } for (int i = row + 1, j = col + 1; i < 15 && j < 15; i++, j++) { if (chessboard[i][j] == chessboard[row][col]) { count++; } else { break; } } if (count >= 5) { return true; } return false; } bool MainWindow::checkDiagonal2(int row, int col) { int count = 1; for (int i = row - 1, j = col + 1; i >= 0 && j < 15; i--, j++) { if (chessboard[i][j] == chessboard[row][col]) { count++; } else { break; } } for (int i = row + 1, j = col - 1; i < 15 && j >= 0; i++, j--) { if (chessboard[i][j] == chessboard[row][col]) { count++; } else { break; } } if (count >= 5) { return true; } return false; } void MainWindow::showMessage(QString message) { messageLabel->setText(message); } void MainWindow::updateChessboard(int row, int col) { buttons[row][col]->setIcon(currentPlayer == 1 ? QIcon(":/black.png") : QIcon(":/white.png")); chessboard[row][col] = currentPlayer; history[steps][0] = row; history[steps][1] = col; history[steps][2] = currentPlayer; steps++; if (checkWin(row, col)) { gameOver = true; QString message = QString("恭喜%1方获胜!").arg(currentPlayer == 1 ? "黑" : "白"); showMessage(message); QMessageBox::information(this, "游戏结束", message); } else if (steps == 15 * 15) { gameOver = true; showMessage("平局"); QMessageBox::information(this, "游戏结束", "平局"); } else { currentPlayer = currentPlayer == 1 ? 2 : 1; QString message = QString("%1方落子").arg(currentPlayer == 1 ? "黑" : "白"); showMessage(message); } } void MainWindow::undoChessboard() { if (steps > 0) { steps--; int row = history[steps][0]; int col = history[steps][1]; int player = history[steps][2]; buttons[row][col]->setIcon(QIcon()); chessboard[row][col] = 0; currentPlayer = player; QString message = QString("%1方悔棋").arg(currentPlayer == 1 ? "黑" : "白"); showMessage(message); } } void MainWindow::buttonClicked() { if (gameOver) { return; } QPushButton *button = qobject_cast<QPushButton *>(sender()); int row = button->property("row").toInt(); int col = button->property("col").toInt(); if (chessboard[row][col] == 0) { updateChessboard(row, col); } } void MainWindow::undoClicked() { if (gameOver) { return; } undoChessboard(); } ``` 注意:在工程的资源文件 (.qrc) 中需要添加黑棋图标(black.png)和白棋图标(white.png)。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值