当前位置: 首页>>代码示例>>Python>>正文


Python Board.random_start方法代码示例

本文整理汇总了Python中pychess.Utils.Board.Board.random_start方法的典型用法代码示例。如果您正苦于以下问题:Python Board.random_start方法的具体用法?Python Board.random_start怎么用?Python Board.random_start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pychess.Utils.Board.Board的用法示例。


在下文中一共展示了Board.random_start方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _

# 需要导入模块: from pychess.Utils.Board import Board [as 别名]
# 或者: from pychess.Utils.Board.Board import random_start [as 别名]
                 "* Exactly one king of each color\n" +
                 "* Pieces placed randomly behind the pawns\n" +
                 "* No castling\n" +
                 "* Black's arrangement mirrors white's")
    name = _("Random")
    cecp_name = "unknown"
    need_initial_board = True
    standard_rules = True
    variant_group = VARIANTS_SHUFFLE

    def __init__ (self, setup=False, lboard=None):
        if setup is True:
            Board.__init__(self, setup=self.random_start(), lboard=lboard)
        else:
            Board.__init__(self, setup=setup, lboard=lboard)

    def random_start(self):        
        tmp = random.sample(('r', 'n', 'b', 'q')*16, 7)
        tmp.append('k')
        random.shuffle(tmp)
        tmp = ''.join(tmp)
        tmp = tmp + '/pppppppp/8/8/8/8/PPPPPPPP/' + tmp.upper() + ' w - - 0 1'
        
        return tmp


if __name__ == '__main__':
    Board = RandomBoard(True)
    for i in range(10):
        print(Board.random_start())
开发者ID:Alex-Linhares,项目名称:pychess,代码行数:32,代码来源:randomchess.py

示例2: random_start

# 需要导入模块: from pychess.Utils.Board import Board [as 别名]
# 或者: from pychess.Utils.Board.Board import random_start [as 别名]
    def random_start(self):        
        tmp = random.sample(('r', 'n', 'b', 'q')*16, 7)
        tmp.append('k')
        random.shuffle(tmp)
        tmp = ''.join(tmp)
        tmp = tmp + '/pppppppp/8/8/8/8/PPPPPPPP/' + tmp.upper() + ' w - - 0 1'
        
        return tmp


class RandomChess:
    __desc__ = _("FICS wild/3: http://www.freechess.org/Help/HelpFiles/wild.html\n" +
                 "* Randomly chosen pieces (two queens or three rooks possible)\n" +
                 "* Exactly one king of each color\n" +
                 "* Pieces placed randomly behind the pawns\n" +
                 "* No castling\n" +
                 "* Black's arrangement mirrors white's")
    name = _("Random")
    cecp_name = "unknown"
    board = RandomBoard
    need_initial_board = True
    standard_rules = True
    variant_group = VARIANTS_SHUFFLE


if __name__ == '__main__':
    Board = RandomBoard(True)
    for i in range(10):
        print Board.random_start()
开发者ID:btrent,项目名称:knave,代码行数:31,代码来源:randomchess.py


注:本文中的pychess.Utils.Board.Board.random_start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。