ttt.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:Chiaki-Nanami 作者: Ikusaba-san 项目源码 文件源码
def __init__(self, ctx, opponent):
        self.ctx = ctx
        self.board = Board(ctx._ttt_size)
        self.opponent = opponent

        xo = random.sample((Tile.X, Tile.O), 2)
        self.players = random.sample(list(map(Player, (self.ctx.author, self.opponent), xo)), 2)
        self._current = None
        self._runner = None

        size = self.ctx._ttt_size
        help_text = ('Type the column and the row in the format `column row` to make your move!\n'
                     'Or `quit` to stop the game (you will lose though).')
        player_field = '\n'.join(itertools.starmap('{1} = **{0}**'.format, self.players))
        self._game_screen = (discord.Embed(colour=0x00FF00)
                            .set_author(name=f'Tic-Tac-toe - {size} x {size}')
                            .add_field(name='Players', value=player_field)
                            .add_field(name='Current Player', value=None, inline=False)
                            .add_field(name='Instructions', value=help_text)
                            )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号