程序设计基础(C++)课程设计
一、要求
实现游戏 Symmetry: The Board Game,至少实现人人对战,可选功能:实现人机对战。
要求使用本学期面向对象设计风格完成代码。
二、游戏规则
“Symmetry” is a new abstract strategy board game. The game rules are very simple, use the
concept of symmetry, and result in a very challenging gameplay!
“Symmetry” is an abstract 2-player game. Players need to create symmetrical patterns on the
board to gain territory, while simultaneously preventing the opponent from creating
symmetrical patterns on the board.
The excact rules of Symmetry are as follows:
-Black and White take turns putting stones on an NxN board (White starts).
-When a stone placing causes a square on the board to be fully covered with stones, this
square changes into the color of the last placed stone if the stone color pattern of the square
in question has become horizontally or vertically ´mirror´ symmetric!
-So ´diagonal´ symmetries will not cause any color change.
-Symmetric squares can potentially have any size (2x2, 3x3, 4x4 etc).
-Sometimes more than one square becomes a 'symmetry' by a move. All such squares change
color.
-The game ends when there are no empty fields left on the board.
-The winner is the player who at the end has the most stones of their color on the board!
可以通过游戏视频辅助理解规则
三、输入格式
从相对路径下文本文件 1.in 中读入双方每步走的位置。1.in 的格式为:
第一行是一个正整数 N,表示棋盘是 N*N 大小,N 不大于 10,其中左上角的坐标称为
(1,1),右下角的坐标称为(N,N);
从第二行开始的 N*N 行,每行是黑白某一方的行棋坐标,以两个 1~N 之间的整数表示。
白方先,白方黑方交替行棋。最终双方棋子将占满整个棋盘。
*人机对战模式下,输入格式可以自行调整。
四、输出格式
1、把每步运行后的棋盘依次输出到相对路径下文本文件 1.out 中,用 1 代表白棋,2 代
表黑棋,0 代表空白。一个 4*4 的棋盘输出可能是这样的:
0000
0210
0120
0000
2、在打印棋盘前,要先输出一行 Step n,其中 n 要用具体数字代入,表示当前是第几步之
后的棋盘,n 从 1 到 N*N。
3、在打印棋盘后,要注明 White: a Black: b,其中 a 和 b 要用具体的数字代入,表示棋盘
中有 a 个白子和 b 个黑子。