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


Python Board.Board类代码示例

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


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

示例1: __init__

 def __init__(self, setup=False, lboard=None):
     if setup is True:
         Board.__init__(self,
                        setup=self.asymmetricrandom_start(),
                        lboard=lboard)
     else:
         Board.__init__(self, setup=setup, lboard=lboard)
开发者ID:bboutkov,项目名称:pychess,代码行数:7,代码来源:asymmetricrandom.py

示例2: __init__

 def __init__(self, setup=True):
     fen = SETUPSTART if setup is True else setup
     # add all kind if piece to holdings (except king)
     parts = fen.split()
     parts[0] += "/prnsqPRNSQ"
     fen = " ".join(parts)
     Board.__init__(self, setup=fen)
     self._ply = 0
开发者ID:sally0813,项目名称:pychess,代码行数:8,代码来源:setupposition.py

示例3: __init__

 def __init__(self, setup=True):
     fenstr = SETUPSTART if setup is True else setup
     # add all kind if piece to holdings
     parts = fenstr.split()
     parts[0] += "/prnsqkPRNSQK"
     fenstr = " ".join(parts)
     Board.__init__(self, setup=fenstr)
     self._ply = 0
开发者ID:bboutkov,项目名称:pychess,代码行数:8,代码来源:setupposition.py

示例4: test2

 def test2(self):
     """ Test analyzing in promotion situations """
     
     board = Board('5k2/PK6/8/8/8/6P1/6P1/8 w - - 1 48')
     self.analyzerA.setBoardList([board],[])
     self.analyzerI.setBoardList([board],[])
     
     self._testLine(self.engineA, self.analyzerA, board,
                    "9. 1833 23 43872584     a8=Q+ Kf7 Qa2+ Kf6 Qd2 Kf5 g4+",
                    ['a8=Q+','Kf7','Qa2+','Kf6','Qd2','Kf5','g4+'], 1833, "9.")
     
     self._testLine(self.engineI, self.analyzerI, board.switchColor(),
                    "10. -1883 59 107386433     Kf7 a8=Q Ke6 Qa6+ Ke5 Qd6+ Kf5",
                    ['Kf7','a8=Q','Ke6','Qa6+','Ke5','Qd6+','Kf5'], -1883, "10.")
开发者ID:Alex-Linhares,项目名称:pychess,代码行数:14,代码来源:analysis.py

示例5: test1

 def test1(self):
     """ Test analyzing in forced mate situations """
     
     board = Board('B1n1n1KR/1r5B/6R1/2b1p1p1/2P1k1P1/1p2P2p/1P2P2P/3N1N2 w - - 0 1')
     self.analyzerA.setBoardList([board],[])
     self.analyzerI.setBoardList([board],[])
     
     self._testLine(self.engineA, self.analyzerA, board,
                    "1. Mat1 0 1     Bxb7#",
                    ['Bxb7#'], MATE_VALUE, "1.")
     
     # Notice, in the opposite situation there is no forced mate. Black can
     # do Bxe3 or Ne7+, but we just emulate a stupid analyzer not
     # recognizing this.
     self._testLine(self.engineI, self.analyzerI, board.switchColor(),
                    "10. -Mat 2 35 64989837     Bd4 Bxb7#",
                    ['Bd4','Bxb7#'], -MATE_VALUE, "10.")
开发者ID:Alex-Linhares,项目名称:pychess,代码行数:17,代码来源:analysis.py

示例6: __onReadyForMoves

 def __onReadyForMoves (self, self_):
     # If we are an analyzer, this signal was already called in a different
     # thread, so we can safely block it.
     if self.mode in (ANALYZING, INVERSE_ANALYZING):
         if not self.board:
             self.board = Board(setup=True)
         self.__sendAnalyze(self.mode == INVERSE_ANALYZING)
     
     self.readyMoves = True
     semisynced(lambda s:None)(self)
开发者ID:btrent,项目名称:knave,代码行数:10,代码来源:CECPEngine.py

示例7: __init__

    def __init__(self, subprocess, color, protover, md5):
        ProtocolEngine.__init__(self, subprocess, color, protover, md5)

        self.ids = {}
        self.options = {}
        self.optionsToBeSent = {}

        self.wtime = 60000
        self.btime = 60000
        self.incr = 0
        self.timeHandicap = 1

        self.moveLock = RLock()
        # none of the following variables should be changed or used in a
        # condition statement without holding the above self.moveLock
        self.ponderOn = False
        self.pondermove = None
        self.ignoreNext = False
        self.waitingForMove = False
        self.needBestmove = False
        self.readyForStop = False  # keeps track of whether we already sent a 'stop' command
        self.multipvSetting = conf.get("multipv", 1
                                       )  # MultiPV option sent to the engine
        self.multipvExpected = 1  # Number of PVs expected (limited by number of legal moves)
        self.commands = collections.deque()

        self.gameBoard = Board(setup=True)  # board at the end of all moves played
        self.board = Board(setup=True)  # board to send the engine
        self.uciPosition = "startpos"
        self.uciPositionListsMoves = False
        self.analysis = [None]

        self.returnQueue = Queue()
        self.line_cid = self.engine.connect("line", self.parseLine)
        self.died_cid = self.engine.connect("died", self.__die)
        self.invalid_move = None

        self.cids = [
            self.connect("readyForOptions", self.__onReadyForOptions_before),
            self.connect_after("readyForOptions", self.__onReadyForOptions),
            self.connect_after("readyForMoves", self.__onReadyForMoves),
        ]
开发者ID:ME7ROPOLIS,项目名称:pychess,代码行数:42,代码来源:UCIEngine.py

示例8: __onReadyForMoves

 def __onReadyForMoves (self, self_):
     self.returnQueue.put("ready")
     self.readyMoves = True
     self._newGame()
     
     # If we are an analyzer, this signal was already called in a different
     # thread, so we can safely block it.
     if self.mode in (ANALYZING, INVERSE_ANALYZING):
         if not self.board:
             self.board = Board(setup=True)
         self.putMove(self.board, None, None)
开发者ID:jskurka,项目名称:PyChess-Learning-Module,代码行数:11,代码来源:UCIEngine.py

示例9: __init__

    def __init__(self, subprocess, color, protover, md5):
        ProtocolEngine.__init__(self, subprocess, color, protover, md5)

        self.ids = {}
        self.options = {}
        self.optionsToBeSent = {}

        self.wtime = 60000
        self.btime = 60000
        self.incr = 0
        self.moves = 0
        self.timeHandicap = 1

        self.ponderOn = False
        self.pondermove = None
        self.ignoreNext = False
        self.waitingForMove = False
        self.needBestmove = False
        self.bestmove_event = asyncio.Event()
        self.readyForStop = False  # keeps track of whether we already sent a 'stop' command
        self.multipvSetting = 1  # MultiPV option sent to the engine
        self.multipvExpected = 1  # Number of PVs expected (limited by number of legal moves)
        self.commands = collections.deque()

        self.gameBoard = Board(setup=True)  # board at the end of all moves played
        self.board = Board(setup=True)  # board to send the engine
        self.uciPosition = "startpos"
        self.uciPositionListsMoves = False
        self.analysis = [None]
        self.analysis_depth = None

        self.queue = asyncio.Queue()
        self.parse_line_task = asyncio.async(self.parseLine(self.engine))
        self.died_cid = self.engine.connect("died", lambda e: self.queue.put_nowait("die"))
        self.invalid_move = None

        self.cids = [
            self.connect_after("readyForOptions", self.__onReadyForOptions),
            self.connect_after("readyForMoves", self.__onReadyForMoves),
        ]
开发者ID:teacoffee2017,项目名称:pychess,代码行数:40,代码来源:UCIEngine.py

示例10: __init__

 def __init__(self, setup=False, lboard=None):
     if setup == True:
         Board.__init__(self, setup=self.shuffle_start(), lboard=lboard)
     else:
         Board.__init__(self, setup=setup, lboard=lboard)
开发者ID:jcoffee,项目名称:pychess,代码行数:5,代码来源:fischerandom.py

示例11: CECPEngine

class CECPEngine(ProtocolEngine):
    def __init__(self, subprocess, color, protover, md5):
        ProtocolEngine.__init__(self, subprocess, color, protover, md5)

        self.features = {
            "ping": 0,
            "setboard": 0,
            "playother": 0,
            "san": 0,
            "usermove": 0,
            "time": 1,
            "draw": 1,
            "sigint": 0,
            "sigterm": 0,
            "reuse": 0,
            "analyze": 0,
            "myname": ', '.join(self.defname),
            "variants": None,
            "colors": 1,
            "ics": 0,
            "name": 0,
            "pause": 0,
            "nps": 0,
            "debug": 0,
            "memory": 0,
            "smp": 0,
            "egt": '',
            "option": '',
            "exclude": 0,
            "done": None,
        }

        self.supported_features = [
            "ping", "setboard", "san", "usermove", "time", "draw", "sigint",
            "analyze", "myname", "variants", "colors", "pause", "done", "egt",
            "debug", "smp", "memory", "option"
        ]

        self.options = {}
        self.options["Ponder"] = {"name": "Ponder",
                                  "type": "check",
                                  "default": False}

        self.name = None

        self.board = Board(setup=True)

        # if self.engineIsInNotPlaying == True, engine is in "force" mode,
        # i.e. not thinking or playing, but still verifying move legality
        self.engineIsInNotPlaying = False
        self.engineIsAnalyzing = False
        self.movenext = False
        self.waitingForMove = False
        self.readyForMoveNowCommand = False
        self.timeHandicap = 1

        self.lastping = 0
        self.lastpong = 0

        self.queue = asyncio.Queue()
        self.parse_line_task = asyncio.async(self.parseLine(self.engine))
        self.died_cid = self.engine.connect("died", lambda e: self.queue.put_nowait("die"))
        self.invalid_move = None

        self.optionQueue = []
        self.undoQueue = []
        self.ready_moves_event = asyncio.Event()

        self.cids = [
            self.connect_after("readyForOptions", self.__onReadyForOptions),
            self.connect_after("readyForMoves", self.__onReadyForMoves),
        ]

    # Starting the game

    def prestart(self):
        print("xboard", file=self.engine)
        if self.protover == 1:
            # start a new game (CECPv1 engines):
            print("new", file=self.engine)

            # we are now ready for options:
            self.emit("readyForOptions")
        elif self.protover == 2:
            # start advanced protocol initialisation:
            print("protover 2", file=self.engine)

            # we don't start a new game for CECPv2 here,
            # we will do it after feature accept/reject is completed.

    def start(self, event=None):
        asyncio.async(self.__startBlocking(event))

    @asyncio.coroutine
    def __startBlocking(self, event):
        if self.protover == 1:
            self.emit("readyForMoves")
            return_value = "ready"

        if self.protover == 2:
#.........这里部分代码省略.........
开发者ID:bboutkov,项目名称:pychess,代码行数:101,代码来源:CECPEngine.py

示例12: __init__

 def __init__(self, setup=False, lboard=None):
     if setup is True:
         Board.__init__(self, setup=WILDCASTLESTART, lboard=lboard)
     else:
         Board.__init__(self, setup=setup, lboard=lboard)
开发者ID:CarbonFixer,项目名称:pychess,代码行数:5,代码来源:wildcastle.py

示例13: _

                 "* 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,代码行数:30,代码来源:randomchess.py

示例14: __init__

 def __init__(self, setup=False, lboard=None):
     if setup is True:
         Board.__init__(self, setup=UPSIDEDOWNSTART, lboard=lboard)
     else:
         Board.__init__(self, setup=setup, lboard=lboard)
开发者ID:jcoffee,项目名称:pychess,代码行数:5,代码来源:upsidedown.py

示例15: __init__

 def __init__ (self, setup=False, lboard=None):
     if setup is True:
         Board.__init__(self, setup=PAWNSPASSEDSTART, lboard=lboard)
     else:
         Board.__init__(self, setup=setup, lboard=lboard)
开发者ID:Alex-Linhares,项目名称:pychess,代码行数:5,代码来源:pawnspassed.py


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