From 45d9dd949db1919bc89acc13f8e9286b49c59197 Mon Sep 17 00:00:00 2001 From: peauxh9ov <1757486528@qq.com> Date: Mon, 17 Jun 2024 23:59:36 +0800 Subject: [PATCH] ADD file via upload --- ChessGame.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 ChessGame.cpp diff --git a/ChessGame.cpp b/ChessGame.cpp new file mode 100644 index 0000000..deb8ab3 --- /dev/null +++ b/ChessGame.cpp @@ -0,0 +1,28 @@ +#include "ChessGame.h" + +ChessGame::ChessGame(Player* player, AI* ai, Chess* chess) +{ + this->player = player; + this->ai = ai; + this->chess = chess; + + player->init(chess); + ai->init(chess); +} + +//对局开始 +void ChessGame::play() +{ + chess->init(); + while (1) + { + //玩家执黑先彳亍 + player->go(); + if (chess->checkOver()) + break; + //人机后落子 + ai->go(); + if (chess->checkOver()) + break; + } +}