本文整理汇总了Python中square.Square.from_x_and_y方法的典型用法代码示例。如果您正苦于以下问题:Python Square.from_x_and_y方法的具体用法?Python Square.from_x_and_y怎么用?Python Square.from_x_and_y使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类square.Square
的用法示例。
在下文中一共展示了Square.from_x_and_y方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: next
# 需要导入模块: from square import Square [as 别名]
# 或者: from square.Square import from_x_and_y [as 别名]
def next(self):
raw_entry = self.next_raw()
source_x = ((raw_entry[1] >> 6) & 077) & 0x7
source_y = (((raw_entry[1] >> 6) & 077) >> 3) & 0x7
target_x = (raw_entry[1] & 077) & 0x7
target_y = ((raw_entry[1] & 077) >> 3) & 0x7
promote = (raw_entry[1] >> 12) & 0x7
move = Move(
source=Square.from_x_and_y(source_x, source_y),
target=Square.from_x_and_y(target_x, target_y),
promotion="nbrq"[promote + 1] if promote else None)
# Replace the non standard castling moves.
if move.uci == "e1h1":
move = Move.from_uci("e1g1")
elif move.uci == "e1a1":
move = Move.from_uci("e1c1")
elif move.uci == "e8h8":
move = Move.from_uci("e8g8")
elif move.uci == "e8a8":
move = Move.from_uci("e8c8")
return {
"position_hash": raw_entry[0],
"move": move,
"weight": raw_entry[2],
"learn": raw_entry[3]
}
示例2: test_from_x_and_y
# 需要导入模块: from square import Square [as 别名]
# 或者: from square.Square import from_x_and_y [as 别名]
def test_from_x_and_y(self):
square = Square.from_x_and_y(0, 0 )
self.assertEqual('a1', str(square))