玩bobail标准游戏的库
bobail的Python项目详细描述
一个可以用来玩bobail游戏的Python3库。这只是一组可以在代码中使用的类,它不是游戏的交互式shell。在
假设
使用的规则来自BoardGameAreana(http://en.doc.boardgamearena.com/Gamehelpbobail)。这意味着5x5板。在
棋盘上的每个位置编号为1到25。每一次移动都被表示为一个数组,其中有两个值:起始位置和结束位置。因此,如果你要开始一个新游戏,其中一个可用的移动是[22, 7]
玩家1。在
每个回合(第一回合除外)将是一系列的两个移动。先移动保龄球,然后是球员代币。在
使用
创建新游戏:
frombobail.gameimportGamegame=Game()
看看轮到谁了:
^{pr2}$采取可能的行动:
game.get_possible_moves()#[[9, 13], [9, 14], [10, 14], [10, 15], [11, 15], [11, 16], [12, 16]]
行动起来:
game.move([9,13])
检查游戏是否结束:
game.is_over()#True or False
找出谁赢了:
game.get_winner()#None or 1 or 2
查看移动历史记录:
game.moves#[[int, int], [int, int], ...]
复习黑板上的内容:
forpieceingame.board.pieces:piece.player#1 or 2piece.other_player#1 or 2piece.bobail#True or Falsepiece.captured#True or Falsepiece.position#1-25piece.get_possible_moves()#[[int, int], [int, int], ...]
测试
从根目录运行python3 -m unittest discover
。在
- 项目
标签: