Moved gen_21_rolls into the 2-ply method, so it can be correctly used like the good helper method that it is

This commit is contained in:
Alexander Munch-Hansen 2018-04-23 00:45:31 +02:00
parent e5cc54d3e0
commit 349ad718f1

View File

@ -142,19 +142,6 @@ class Network:
return best_move_pair return best_move_pair
def gen_21_rolls(self):
"""
Calculate all possible rolls, [[1,1], [1,2] ..]
:return: All possible rolls
"""
a = []
for x in range(1,7):
for y in range(1,7):
if not [x,y] in a and not [y,x] in a:
a.append([x,y])
return a
def calculate_2_ply(self, sess, board, roll, player): def calculate_2_ply(self, sess, board, roll, player):
""" """
Find the best move based on a 2-ply look-ahead. First the best move is found for a single ply and then an Find the best move based on a 2-ply look-ahead. First the best move is found for a single ply and then an
@ -168,6 +155,18 @@ class Network:
""" """
def gen_21_rolls():
"""
Calculate all possible rolls, [[1,1], [1,2] ..]
:return: All possible rolls
"""
a = []
for x in range(1, 7):
for y in range(1, 7):
if not [x, y] in a and not [y, x] in a:
a.append([x, y])
return a
init_legal_states = Board.calculate_legal_states(board, player, roll) init_legal_states = Board.calculate_legal_states(board, player, roll)
zero_ply_moves_and_scores = [(move, self.eval_state(sess, self.board_trans_func(move, player))) for move in init_legal_states] zero_ply_moves_and_scores = [(move, self.eval_state(sess, self.board_trans_func(move, player))) for move in init_legal_states]
@ -177,7 +176,7 @@ class Network:
best_fifteen.reverse() best_fifteen.reverse()
best_fifteen_boards = [x[0] for x in best_fifteen[:15]] best_fifteen_boards = [x[0] for x in best_fifteen[:15]]
all_rolls = self.gen_21_rolls() all_rolls = gen_21_rolls()
all_rolls_scores = [] all_rolls_scores = []
for a_board in best_fifteen_boards: for a_board in best_fifteen_boards: