From 349ad718f1d4664bf4c5cecf29c2e99511223638 Mon Sep 17 00:00:00 2001 From: Pownie Date: Mon, 23 Apr 2018 00:45:31 +0200 Subject: [PATCH] Moved gen_21_rolls into the 2-ply method, so it can be correctly used like the good helper method that it is --- network.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/network.py b/network.py index 0682fda..9eff2a8 100644 --- a/network.py +++ b/network.py @@ -142,19 +142,6 @@ class Network: 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): """ 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) 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_boards = [x[0] for x in best_fifteen[:15]] - all_rolls = self.gen_21_rolls() + all_rolls = gen_21_rolls() all_rolls_scores = [] for a_board in best_fifteen_boards: