From c2118d05499b179ad52d768e36927f009adf2baa Mon Sep 17 00:00:00 2001 From: Alexander Munch-Hansen Date: Wed, 7 Feb 2018 15:31:05 +0100 Subject: [PATCH] Added network --- board.py | 8 ++++---- bot.py | 3 ++- game.py | 7 +++++-- hooman.py | 3 ++- network.py | 5 +++++ 5 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 network.py diff --git a/board.py b/board.py index d685fa4..092b10c 100644 --- a/board.py +++ b/board.py @@ -91,11 +91,11 @@ class Board: return """ - ------------------------------------------------------------- - |{12}|{11}|{10}|{9}|{8}|{7}|bar 1: {26} |{6}|{5}|{4}|{3}|{2}|{1}|end -1: {0}| + ------------------------------------------------------------ + |{12}|{11}|{10}|{9}|{8}|{7}|bar 1: {26} |{6}|{5}|{4}|{3}|{2}|{1}|end -1: {0}| |--|--|--|--|--|--|--------|--|--|--|--|--|--| - |{13}|{14}|{15}|{16}|{17}|{18}|bar -1: {27} |{19}|{20}|{21}|{22}|{23}|{24}|end 1: {25}| - ------------------------------------------------------------- + |{13}|{14}|{15}|{16}|{17}|{18}|bar -1: {27} |{19}|{20}|{21}|{22}|{23}|{24}|end 1: {25}| + ------------------------------------------------------------ """.format(*temp) def move_to_jail(self,sym): diff --git a/bot.py b/bot.py index d9e7a7f..02e56ed 100644 --- a/bot.py +++ b/bot.py @@ -3,10 +3,11 @@ import random class Bot: - def __init__(self, board, sym): + def __init__(self, board, sym, network): self.cup = Cup() self.board = board self.sym = sym + self.network = network def roll(self): print("{} rolled: ".format(self.sym)) diff --git a/game.py b/game.py index a0ec95d..dab9fb8 100644 --- a/game.py +++ b/game.py @@ -1,13 +1,16 @@ from hooman import Human from board import Board from bot import Bot +from network import Network class Game: def __init__(self): self.board = Board() - self.p1 = Human(self.board, 1) - self.p2 = Bot(self.board, -1) + self.network = Network() + self.p1 = Human(self.board, 1, self.network) + self.p2 = Bot(self.board, -1, self.network) + def play(self): while True: diff --git a/hooman.py b/hooman.py index d5d47e7..10df86f 100644 --- a/hooman.py +++ b/hooman.py @@ -5,8 +5,9 @@ class Human: global cup cup = Cup() - def __init__(self, board, sym): + def __init__(self, board, sym, network): self.cup = Cup() + self.network = network self.board = board self.sym = sym diff --git a/network.py b/network.py new file mode 100644 index 0000000..bae99ea --- /dev/null +++ b/network.py @@ -0,0 +1,5 @@ +class Network: + + def eval_state(self, state): + # Run state through a network + print("Network is evaluating")