From e5cc54d3e01dbd7cd860b7ee6e6ae0833f084f6a Mon Sep 17 00:00:00 2001 From: Pownie Date: Mon, 23 Apr 2018 00:35:25 +0200 Subject: [PATCH] Added a normalised version of quack --- board.py | 14 ++++++++++++++ network.py | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/board.py b/board.py index b3bd628..4bd586a 100644 --- a/board.py +++ b/board.py @@ -54,6 +54,20 @@ class Board: return np.array(board).reshape(1,-1) + # quack-fatter + @staticmethod + def board_features_quack_norm(board, player): + board = list(board) + positives = [x if x > 0 else 0 for x in board] + negatives = [x if x < 0 else 0 for x in board] + board[0] = board[0] / 2 + board[25] = board[25] / 2 + board = [board[x] / 15 for x in range(1,25)] + board.append(15 - sum(positives)) + board.append(-15 - sum(negatives)) + board += ([1, 0] if np.sign(player) > 0 else [0, 1]) + return np.array(board).reshape(1, -1) + # tesauro @staticmethod def board_features_tesauro(board, cur_player): diff --git a/network.py b/network.py index 5945eb9..0682fda 100644 --- a/network.py +++ b/network.py @@ -17,7 +17,8 @@ class Network: board_reps = { 'quack-fat' : (30, Board.board_features_quack_fat), 'quack' : (28, Board.board_features_quack), - 'tesauro' : (198, Board.board_features_tesauro) + 'tesauro' : (198, Board.board_features_tesauro), + 'quack-norm': (30, Board.board_features_quack_norm) } def custom_tanh(self, x, name=None):