本文整理汇总了Python中Board.is_solvable方法的典型用法代码示例。如果您正苦于以下问题:Python Board.is_solvable方法的具体用法?Python Board.is_solvable怎么用?Python Board.is_solvable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Board
的用法示例。
在下文中一共展示了Board.is_solvable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import Board [as 别名]
# 或者: from Board import is_solvable [as 别名]
def main():
domain = "http://localhost:8080" # domain al que nos vamos a conectar
pid = int(input("Ingrese el id del jugador: "))
name = input("Ingrese el nombre del jugador: ")
taquin.create_player(domain, pid, name)
option = int(input("1) Single player, 2) Resolver un reto (Multiplayer), 3) Retar a un jugador, -1) salir\n"))
while option != -1:
if option == 1:
size = int(input("Ingrese el tamaño N del tablero: "))
matrix = taquin.generate_matrix(size) # generamos una matriz de size * size
board = Board(matrix, size, size-1, size-1)
# -------------- PARA PROBAR 2x2 ------------
#matrix = [[3, 1],
# [2, None]]
#board = Board(matrix, 2, 1, 1)
# -------------------------------------------
# -------------- PARA PROBAR 3x3 ------------
#matrix = [[1, 3, 4],
# [2, 5, 6],
# [7, 8, None]]
#board = Board(matrix, 3, 2, 2)
# -------------------------------------------
while not board.is_solvable():
matrix = taquin.generate_matrix(size) # generamos una matriz de size * size
board = Board(matrix, size, size - 1, size - 1)
taquin.generateBoard(domain, matrix, size-1, size-1) # mandamos la matriz para que se display en la pagina
if board.is_solvable():
print("El tablero SI se puede resolver")
solver = Solver(board)
movements = solver.solve()
print("Movimientos: ", movements)
if len(movements) != 0:
send_movements(domain, pid, movements)
else:
print("El tablero NO se puede resolver")
elif option == 2: # todavia no sirve
taquin.get_challenge(domain, pid)
elif option == 3:
opponent = input("Ingrese el id del oponente: ")
opponent = int(opponent)
size = int(input("Ingrese el tamaño N del tablero: "))
matrix_challenge = taquin.generate_matrix(size)
taquin.challenge(domain, matrix_challenge, size-1, size-1, opponent)
print("Reto enviado: ")
print(matrix_challenge)
option = int(input("1) Single player, 2) Resolver un reto (Multiplayer), 3) Retar a un jugador, -1) salir\n"))