Everything might work, except for quad, that might be bugged.
This commit is contained in:
parent
a266293ecd
commit
d14e6c5994
31
app.py
31
app.py
|
@ -29,7 +29,7 @@ def calc_move_sets(from_board, roll, player):
|
||||||
sets = []
|
sets = []
|
||||||
total = 0
|
total = 0
|
||||||
for r in roll:
|
for r in roll:
|
||||||
print("Value of r:", r)
|
# print("Value of r:", r)
|
||||||
sets.append([Board.calculate_legal_states(board, player, [r, 0]), r])
|
sets.append([Board.calculate_legal_states(board, player, [r, 0]), r])
|
||||||
total += r
|
total += r
|
||||||
sets.append([Board.calculate_legal_states(board, player, [total, 0]), total])
|
sets.append([Board.calculate_legal_states(board, player, [total, 0]), total])
|
||||||
|
@ -45,9 +45,9 @@ def tmp_name(from_board, to_board, roll, player, total_moves, is_quad=False):
|
||||||
# print(to_board)
|
# print(to_board)
|
||||||
# print(board_set)
|
# print(board_set)
|
||||||
if to_board in board_set[0]:
|
if to_board in board_set[0]:
|
||||||
print("To board:", to_board)
|
# print("To board:", to_board)
|
||||||
print(board_set[0])
|
# print(board_set[0])
|
||||||
print(board_set[1])
|
# print(board_set[1])
|
||||||
total_moves -= board_set[1]
|
total_moves -= board_set[1]
|
||||||
# if it's not the sum of the moves
|
# if it's not the sum of the moves
|
||||||
if idx < (4 if is_quad else 2):
|
if idx < (4 if is_quad else 2):
|
||||||
|
@ -57,18 +57,12 @@ def tmp_name(from_board, to_board, roll, player, total_moves, is_quad=False):
|
||||||
return_board = to_board
|
return_board = to_board
|
||||||
break
|
break
|
||||||
|
|
||||||
print("Return board!:\n",return_board)
|
# print("Return board!:\n",return_board)
|
||||||
return total_moves, roll, return_board
|
return total_moves, roll, return_board
|
||||||
|
|
||||||
def calc_move_stuff(from_board, to_board, roll, player):
|
def calc_move_stuff(from_board, to_board, roll, player, total_roll, is_quad):
|
||||||
|
|
||||||
is_quad = roll[0] == roll[1]
|
total_moves, roll, board = tmp_name(from_board, to_board, list(roll), player, total_roll, is_quad)
|
||||||
|
|
||||||
total_moves = roll[0] + roll[1] if not is_quad else int(roll[0]) * 4
|
|
||||||
if is_quad:
|
|
||||||
roll = [roll[0]] * 4
|
|
||||||
|
|
||||||
total_moves, roll, board = tmp_name(from_board, to_board, list(roll), player, total_moves, is_quad)
|
|
||||||
return board, total_moves, roll
|
return board, total_moves, roll
|
||||||
|
|
||||||
|
|
||||||
|
@ -97,9 +91,9 @@ def bot_move():
|
||||||
board = [int(x) for x in data['board'].split(',')]
|
board = [int(x) for x in data['board'].split(',')]
|
||||||
|
|
||||||
roll = (random.randrange(1,7), random.randrange(1,7))
|
roll = (random.randrange(1,7), random.randrange(1,7))
|
||||||
print(roll)
|
# print(roll)
|
||||||
board, _ = network.make_move(tuple(board), roll, 1)
|
board, _ = network.make_move(tuple(board), roll, 1)
|
||||||
print("Boards!:",board)
|
# print("Boards!:",board)
|
||||||
|
|
||||||
return ",".join([str(x) for x in list(board)])
|
return ",".join([str(x) for x in list(board)])
|
||||||
|
|
||||||
|
@ -115,13 +109,14 @@ def post_board():
|
||||||
board = [int(x) for x in data['board'].split(',')]
|
board = [int(x) for x in data['board'].split(',')]
|
||||||
prev_board = [int(x) for x in data['prev_board'].split(',')]
|
prev_board = [int(x) for x in data['prev_board'].split(',')]
|
||||||
roll = [int(x) for x in data['roll'].split(',')]
|
roll = [int(x) for x in data['roll'].split(',')]
|
||||||
|
quad = data['quad'] == "true"
|
||||||
|
|
||||||
|
|
||||||
print(board)
|
# print(board)
|
||||||
|
|
||||||
total_roll = int(data['total_roll'])
|
total_roll = int(data['total_roll'])
|
||||||
|
print("total roll is:", total_roll)
|
||||||
return_board, total_moves, roll = calc_move_stuff(tuple(prev_board), tuple(board), tuple(roll), player)
|
return_board, total_moves, roll = calc_move_stuff(tuple(prev_board), tuple(board), tuple(roll), player, total_roll, quad)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user