本文整理汇总了Python中pychess.Utils.lutils.LBoard.LBoard.setColor方法的典型用法代码示例。如果您正苦于以下问题:Python LBoard.setColor方法的具体用法?Python LBoard.setColor怎么用?Python LBoard.setColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pychess.Utils.lutils.LBoard.LBoard
的用法示例。
在下文中一共展示了LBoard.setColor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PyChessCECP
# 需要导入模块: from pychess.Utils.lutils.LBoard import LBoard [as 别名]
# 或者: from pychess.Utils.lutils.LBoard.LBoard import setColor [as 别名]
#.........这里部分代码省略.........
self.print("piece F& [email protected]")
self.print("piece R& [email protected]")
self.print("piece K& [email protected]")
self.print("piece P& [email protected]")
elif lines[0] == "quit":
self.forced = True
self.__stopSearching()
sys.exit(0)
elif lines[0] == "random":
leval.random = True
elif lines[0] == "force":
if not self.forced and not self.analyzing:
self.forced = True
self.__stopSearching()
elif lines[0] == "go":
self.playingAs = self.board.color
self.forced = False
self.__go()
elif lines[0] == "playother":
self.playingAs = 1 - self.board.color
self.forced = False
# TODO: start pondering, if possible
elif lines[0] in ("black", "white"):
newColor = lines[0] == "black" and BLACK or WHITE
self.__stopSearching()
self.playingAs = 1 - newColor
if self.board.color != newColor:
self.board.setColor(newColor)
self.board.setEnpassant(None)
if self.analyzing:
self.__analyze()
elif lines[0] == "level":
self.movestogo = int(lines[1])
inc = int(lines[3])
minutes = lines[2].split(":")
# Per protocol spec, strip off any non-numeric suffixes.
for i in range(len(minutes)):
minutes[i] = re.match(r'\d*', minutes[i]).group()
self.basetime = int(minutes[0]) * 60
if len(minutes) > 1 and minutes[1]:
self.basetime += int(minutes[1])
self.clock[:] = self.basetime, self.basetime
self.increment = inc, inc
elif lines[0] == "st":
self.searchtime = float(lines[1])
elif lines[0] == "sd":
self.sd = int(lines[1])
# Unimplemented: nps
elif lines[0] == "time":
self.clock[self.playingAs] = float(lines[1]) / 100.
elif lines[0] == "otim":
self.clock[1 - self.playingAs] = float(lines[1]) / 100.
elif lines[0] == "usermove":
示例2: PyChessCECP
# 需要导入模块: from pychess.Utils.lutils.LBoard import LBoard [as 别名]
# 或者: from pychess.Utils.lutils.LBoard.LBoard import setColor [as 别名]
#.........这里部分代码省略.........
self.board.variant = SUICIDECHESS
elif lines[1] == "atomic":
self.board.variant = ATOMICCHESS
self.board.iniAtomic()
elif lines[0] == "quit":
self.forced = True
self.__stopSearching()
sys.exit(0)
elif lines[0] == "random":
leval.random = True
elif lines[0] == "force":
if not self.forced and not self.analyzing:
self.forced = True
self.__stopSearching()
elif lines[0] == "go":
self.playingAs = self.board.color
self.forced = False
self.__go()
elif lines[0] == "playother":
self.playingAs = 1-self.board.color
self.forced = False
# TODO: start pondering, if possible
elif lines[0] in ("black", "white"):
newColor = lines[0] == "black" and BLACK or WHITE
self.__stopSearching()
self.playingAs = 1-newColor
if self.board.color != newColor:
self.board.setColor(newColor)
self.board.setEnpassant(None)
if self.analyzing:
self.__analyze()
elif lines[0] == "level":
self.movestogo = int(lines[1])
inc = int(lines[3])
minutes = lines[2].split(":")
# Per protocol spec, strip off any non-numeric suffixes.
for i in xrange(len(minutes)):
minutes[i] = re.match(r'\d*', minutes[i]).group()
self.basetime = int(minutes[0])*60
if len(minutes) > 1 and minutes[1]:
self.basetime += int(minutes[1])
self.clock[:] = self.basetime, self.basetime
self.increment = inc, inc
elif lines[0] == "st":
self.searchtime = float(lines[1])
elif lines[0] == "sd":
self.sd = int(lines[1])
# Unimplemented: nps
elif lines[0] == "time":
self.clock[self.playingAs] = float(lines[1])/100.
elif lines[0] == "otim":
self.clock[1-self.playingAs] = float(lines[1])/100.
elif lines[0] == "usermove":
示例3: PyChessCECP
# 需要导入模块: from pychess.Utils.lutils.LBoard import LBoard [as 别名]
# 或者: from pychess.Utils.lutils.LBoard.LBoard import setColor [as 别名]
#.........这里部分代码省略.........
elif lines[0] == "quit":
sys.exit()
elif lines[0] == "result":
# We don't really care what the result is at the moment.
sys.exit()
elif lines[0] == "force":
if not self.forced and not self.analyzing:
self.forced = True
self.__stopSearching()
elif lines[0] == "go":
self.playingAs = self.board.color
self.forced = False
self.__go()
elif lines[0] == "undo":
self.__stopSearching()
self.board.popMove()
if self.analyzing:
self.__analyze()
elif lines[0] == "?":
self.__stopSearching()
elif lines[0] in ("black", "white"):
newColor = lines[0] == "black" and BLACK or WHITE
if self.playingAs != newColor:
self.__stopSearching()
self.playingAs = newColor
# It is dangerous to use the same table, when we change color
#lsearch.table.clear()
self.board.setColor(newColor)
# Concider the case:
# * White moves a pawn and creates a enpassant cord
# * Spy analyzer is not set back to white to analyze the
# position. An attackable enpassant cord now no longer makes
# sense.
# * Notice though, that when the color is shifted back to black
# to make the actual move - and it is an enpassant move - the
# cord won't be set in the lboard.
self.board.setEnpassant(None)
if self.analyzing:
self.__analyze()
elif lines[0] == "analyze":
self.playingAs = self.board.color
self.analyzing = True
self.__analyze()
elif lines[0] == "draw":
if self.scr <= 0:
print "offer draw"
elif lines[0] == "random":
leval.random = True
elif lines[0] == "variant":
if lines[1] == "fischerandom":
self.board.variant = FISCHERRANDOMCHESS
elif lines[0] == "setboard":
self.__stopSearching()
self.board.applyFen(" ".join(lines[1:]))
if self.analyzing:
self.__analyze()
elif lines[0] in ("xboard", "otim", "hard", "easy", "nopost", "post",
"accepted", "rejected"):
pass
else: print "Warning (unknown command):", line
def __stopSearching(self):
lsearch.searching = False
if self.worker:
self.worker.cancel()
glock.acquire()
self.worker.get()
glock.release()
self.worker = None
def __go (self):
self.worker = GtkWorker(lambda worker: PyChess._PyChess__go(self, worker))
def process (worker, messages): print "\n".join(messages)
self.worker.connect("published", process)
def ondone (worker, result):
if not result: return
self.board.applyMove(parseSAN(self.board,result))
print "move %s" % result
self.worker.connect("done", ondone)
self.worker.execute()
def __analyze (self):
self.worker = GtkWorker(lambda worker: PyChess._PyChess__analyze(self, worker))
def process (worker, messages): print "\n".join(messages)
self.worker.connect("published", process)
self.worker.execute()