1个稳定版本
使用旧Rust 2015
1.0.0 | 2018年2月11日 |
---|
在#atari中排名9
37KB
759 行
Atari Go游戏的简单克隆。
本游戏基于昆士兰大学信息技术与电子工程系CSSE2310/CSSE7231课程作业。
如何玩游戏?
有两名玩家(可以是人类或自动化的),分别用棋盘上的0和X表示。规则非常简单,如下:
- 当一组相同的棋子横向或纵向相连时,它们被认为是一串。
- 与一串横向或纵向相邻的空格被认为是“自由”,或是一串可以扩展的空间。
- 当一个串没有剩余的自由时,这个串被认为被捕获。
- 任何被捕获的串的玩家被认为是输掉了游戏。
- 在可能导致任何玩家的串被捕获的移动情况下,当前玩家有选择获胜移动的选项。
在游戏的每个步骤中,玩家(人类或计算机)将输入下一移动的row
和column
(即放置下一个棋子的位置)。只有有效的移动会被接受。同时请注意,用户必须使用正常的从左上角开始的0索引计数输入row
和column
值。例如,移动1 2
指的是第二行第三列(棋盘左上角的坐标为0 0
)。
用法
如果使用Cargo运行,
$ cargo run nogo [ p1type p2type height width | filename ]
其中p1type
和p2type
可以是c
(计算机)或h
(人类)。
height
和width
表示棋盘大小的单元格,必须是4到1000之间的整数。
filename
指的是之前保存游戏的完整路径。游戏将继续从上次离开的地方继续,使用从保存的游戏数据推断出的相同的玩家类型。
如果直接使用可执行文件运行,
$ nogo [ p1type p2type height width | filename ]
所有术语的含义与之前解释的完全相同。
保存/加载游戏
在游戏过程中任何时候,玩家都可以输入w[full-path-of-the-save-file]
来代替输入下一步的行列。也就是说,直接输入w
,然后紧跟游戏保存文件的全路径,路径中间没有空格。例如:
Player X> w/opt/games/my_save_file.nogo
当然,这意味着在游戏过程中保存游戏,至少有一位玩家是真人玩家。
要加载已保存的游戏文件,只需像在Usage
部分所示调用它即可
$ cargo run nogo /opt/games/my_save_file.nogo
。游戏将从上次停止的地方继续。
游戏示例
为了帮助玩家开始游戏,这里有一个人类玩家(玩家1)和电脑(玩家2)之间的小游戏示例。
$ cargo run c h 5 5
Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
Running `target/debug/nogo c h 5 5`
Welcome to nogo!
/-----\
|.....|
|.....|
|.....|
|.....|
|.....|
\-----/
Player 0: 2 0
/-----\
|.....|
|.....|
|0....|
|.....|
|.....|
\-----/
Player X> 0 1
/-----\
|.X...|
|.....|
|0....|
|.....|
|.....|
\-----/
Player 0: 4 1
/-----\
|.X...|
|.....|
|0....|
|.....|
|.0...|
\-----/
Player X> 2 1
/-----\
|.X...|
|.....|
|0X...|
|.....|
|.0...|
\-----/
Player 0: 0 2
/-----\
|.X0..|
|.....|
|0X...|
|.....|
|.0...|
\-----/
Player X> 1 0
/-----\
|.X0..|
|X....|
|0X...|
|.....|
|.0...|
\-----/
Player 0: 2 3
/-----\
|.X0..|
|X....|
|0X.0.|
|.....|
|.0...|
\-----/
Player X> 3 0
/-----\
|.X0..|
|X....|
|0X.0.|
|X....|
|.0...|
\-----/
Player X wins!
Thank you for playing nogo!
另一个示例,这次是电脑对战电脑
$ cargo run c c 7 5
Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
Running `target/debug/nogo c c 7 5`
Welcome to nogo!
/-----\
|.....|
|.....|
|.....|
|.....|
|.....|
|.....|
|.....|
\-----/
Player 0: 2 0
/-----\
|.....|
|.....|
|0....|
|.....|
|.....|
|.....|
|.....|
\-----/
Player X: 3 1
/-----\
|.....|
|.....|
|0....|
|.X...|
|.....|
|.....|
|.....|
\-----/
Player 0: 4 1
/-----\
|.....|
|.....|
|0....|
|.X...|
|.0...|
|.....|
|.....|
\-----/
Player X: 5 2
/-----\
|.....|
|.....|
|0....|
|.X...|
|.0...|
|..X..|
|.....|
\-----/
Player 0: 5 1
/-----\
|.....|
|.....|
|0....|
|.X...|
|.0...|
|.0X..|
|.....|
\-----/
Player X: 6 2
/-----\
|.....|
|.....|
|0....|
|.X...|
|.0...|
|.0X..|
|..X..|
\-----/
Player 0: 0 3
/-----\
|...0.|
|.....|
|0....|
|.X...|
|.0...|
|.0X..|
|..X..|
\-----/
Player X: 6 3
/-----\
|...0.|
|.....|
|0....|
|.X...|
|.0...|
|.0X..|
|..XX.|
\-----/
Player 0: 1 4
/-----\
|...0.|
|....0|
|0....|
|.X...|
|.0...|
|.0X..|
|..XX.|
\-----/
Player X: 0 2
/-----\
|..X0.|
|....0|
|0....|
|.X...|
|.0...|
|.0X..|
|..XX.|
\-----/
Player 0: 3 0
/-----\
|..X0.|
|....0|
|0....|
|0X...|
|.0...|
|.0X..|
|..XX.|
\-----/
Player X: 1 3
/-----\
|..X0.|
|...X0|
|0....|
|0X...|
|.0...|
|.0X..|
|..XX.|
\-----/
Player 0: 4 0
/-----\
|..X0.|
|...X0|
|0....|
|0X...|
|00...|
|.0X..|
|..XX.|
\-----/
Player X: 3 4
/-----\
|..X0.|
|...X0|
|0....|
|0X..X|
|00...|
|.0X..|
|..XX.|
\-----/
Player 0: 2 4
/-----\
|..X0.|
|...X0|
|0...0|
|0X..X|
|00...|
|.0X..|
|..XX.|
\-----/
Player X: 4 4
/-----\
|..X0.|
|...X0|
|0...0|
|0X..X|
|00..X|
|.0X..|
|..XX.|
\-----/
Player 0: 2 3
/-----\
|..X0.|
|...X0|
|0..00|
|0X..X|
|00..X|
|.0X..|
|..XX.|
\-----/
Player X: 6 1
/-----\
|..X0.|
|...X0|
|0..00|
|0X..X|
|00..X|
|.0X..|
|.XXX.|
\-----/
Player 0: 1 2
/-----\
|..X0.|
|..0X0|
|0..00|
|0X..X|
|00..X|
|.0X..|
|.XXX.|
\-----/
/-----\
|..X0.|
|..0X0|
|0..00|
|0X..X|
|00..X|
|.0X..|
|.XXX.|
\-----/
Player 0 wins!
Thank you for playing nogo!
在游戏中保存游戏并再次加载的示例
$ cargo run c h 5 5
Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
Running `target/debug/nogo c h 5 5`
Welcome to nogo!
/-----\
|.....|
|.....|
|.....|
|.....|
|.....|
\-----/
Player 0: 2 0
/-----\
|.....|
|.....|
|0....|
|.....|
|.....|
\-----/
Player X> 1 0
/-----\
|.....|
|X....|
|0....|
|.....|
|.....|
\-----/
Player 0: 4 1
/-----\
|.....|
|X....|
|0....|
|.....|
|.0...|
\-----/
Player X> 3 1
/-----\
|.....|
|X....|
|0....|
|.X...|
|.0...|
\-----/
Player 0: 0 1
/-----\
|.0...|
|X....|
|0....|
|.X...|
|.0...|
\-----/
Player X> 3 0
/-----\
|.0...|
|X....|
|0....|
|XX...|
|.0...|
\-----/
Player 0: 0 2
/-----\
|.00..|
|X....|
|0....|
|XX...|
|.0...|
\-----/
Player X> wsave_file.gm
Finished saving current game state to file save_file.gm
Thank you for playing nogo!
$ cargo run save_file.gm
Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
Running `target/debug/nogo save_file.gm`
Welcome to nogo again!
/-----\
|.00..|
|X....|
|0....|
|XX...|
|.0...|
\-----/
Player X> 2 1
/-----\
|.00..|
|X....|
|0X...|
|XX...|
|.0...|
\-----/
/-----\
|.00..|
|X....|
|0X...|
|XX...|
|.0...|
\-----/
Player X wins!
Thank you for playing nogo!