def gtp_clear(self, args): """ Clear the game board. """ self.game = gamestate(self.game.size) self.agent.set_gamestate(self.game) return (True, "")
def __init__(self, agent): """ Initilize the list of available commands, binding appropriate names to the funcitons defined in this file. """ commands={} commands["name"] = self.gtp_name commands["version"] = self.gtp_version commands["protocol_version"] = self.gtp_protocol commands["known_command"] = self.gtp_known commands["list_commands"] = self.gtp_list commands["quit"] = self.gtp_quit commands["boardsize"] = self.gtp_boardsize commands["size"] = self.gtp_boardsize commands["clear_board"] = self.gtp_clear commands["play"] = self.gtp_play commands["genmove"] = self.gtp_genmove commands["showboard"] = self.gtp_show commands["print"] = self.gtp_show commands["set_time"] = self.gtp_time commands["winner"] = self.gtp_winner commands["occupied"] = self.gtp_occupied commands["valid"] = self.gtp_valid self.commands = commands self.game = gamestate(8) self.agent = agent self.agent.set_gamestate(self.game) self.move_time = 10 self.next_move = None self.moveslist = None
def __init__(self, agent): """ Initilize the list of available commands, binding appropriate names to the funcitons defined in this file. """ commands = {} commands["name"] = self.gtp_name commands["version"] = self.gtp_version commands["protocol_version"] = self.gtp_protocol commands["known_command"] = self.gtp_known commands["list_commands"] = self.gtp_list commands["quit"] = self.gtp_quit commands["boardsize"] = self.gtp_boardsize commands["size"] = self.gtp_boardsize commands["clear_board"] = self.gtp_clear commands["play"] = self.gtp_play commands["genmove"] = self.gtp_genmove commands["showboard"] = self.gtp_show commands["print"] = self.gtp_show commands["set_time"] = self.gtp_time commands["winner"] = self.gtp_winner commands["hexgui-analyze_commands"] = self.gtp_analyze self.commands = commands self.game = gamestate(8) self.agent = agent self.agent.set_gamestate(self.game) self.move_time = 10
def reset(self, event): """ By clicking on the Reset button game board would be cleared for a new game """ self.game = gamestate(self.game.size) self.agent.set_gamestate(self.game) self.set_size(event) self.game_turn_value.set(1)
def __init__(self, graphics, level, players, inputqueue, options): self.graphics = graphics self.inputqueue = inputqueue graphics.load(level.objectsUsed) # initialize events events = event.events() events.token = event.event("token") # arguments: none events.timeout = event.event("timeout") # arguments: gamestate, object that timed out events.collision = event.event("collision") # arguments: gamestate, object1, object2 events.playerkilled = event.event("playerkilled") # arguments: gamestate, bomberman, explosion events.playerspawned = event.event("playerspawned") # arguments: bomberman events.bombexplode = event.event("bombexplode") # arguments: bombcoordinate, bombrange events.poweruppickup = event.event("poweruppickup") # arguments: bombcoordinate, bombrange events.eMouseEvent = event.event("eMouseEvent") # emits as data: the message as a string, player_id as an integer. events.eChtMessage = event.event("eChtMessage") # these all emit as data: player_id as an integer. events.eAcceForwOn = event.event("eAcceForwOn") events.eAcceBackOn = event.event("eAcceBackOn") events.eStepLeftOn = event.event("eStepLeftOn") events.eStepRghtOn = event.event("eStepRghtOn") events.eDropBombOn = event.event("eDropBombOn") events.ePowerup1On = event.event("ePowerup1On") events.ePowerup2On = event.event("ePowerup2On") events.ePowerup3On = event.event("ePowerup3On") events.eMinimapTOn = event.event("eMinimapTOn") events.eAcceForwOff = event.event("eAcceForwOff") events.eAcceBackOff = event.event("eAcceBackOff") events.eStepLeftOff = event.event("eStepLeftOff") events.eStepRghtOff = event.event("eStepRghtOff") events.eDropBombOff = event.event("eDropBombOff") events.ePowerup1Off = event.event("ePowerup1Off") events.ePowerup2Off = event.event("ePowerup2Off") events.ePowerup3Off = event.event("ePowerup3Off") events.eMinimapTOff = event.event("eMinimapTOff") events.eNeatQuit = event.event("eNeatQuit") events.token.register(engine.play) time = options.get("time", 120) # TODO: tijd (timeleft in dit geval dacht ik) goed regelen level.createLevel(self, players) level.loadScripts(events) self.graphics.initEvents(events) self.gamestate = gamestate.gamestate(self, level, players, events, 10, time) # TODO: framerate fixen graphics.buildLists(self.gamestate) self.inputqueuehandler = testqhandlers.QReaderEventWriter(inputqueue, self.gamestate)
def run_game(blackAgent, whiteAgent, boardsize, time, verbose = False): game = gamestate(boardsize) time = time winner = None timeout = False moves = [] blackAgent.sendCommand("clear_board") whiteAgent.sendCommand("clear_board") while(True): t = moveThread(game, blackAgent, "black") t.start() t.join(time+0.5) moves.append(t.move) if verbose: print(blackAgent.name+" v.s. "+whiteAgent.name) print(game) #if black times out white wins if(t.isAlive()): timeout = True t.timeout_flag[0] = True winner = game.PLAYERS["white"] blackAgent.reconnect() blackAgent.sendCommand("boardsize "+str(boardsize)) blackAgent.sendCommand("set_time "+str(time)) break if(game.winner() != game.PLAYERS["none"]): winner = game.winner() break sys.stdout.flush() t = moveThread(game, whiteAgent, "white") t.start() t.join(time+0.5) moves.append(t.move) if verbose: print(blackAgent.name+" v.s. "+whiteAgent.name) print(game) #if white times out black wins if(t.isAlive()): timeout = True t.timeout_flag[0] = True winner = game.PLAYERS["black"] whiteAgent.reconnect() whiteAgent.sendCommand("boardsize "+str(boardsize)) whiteAgent.sendCommand("set_time "+str(time)) break if(game.winner() != game.PLAYERS["none"]): winner = game.winner() break sys.stdout.flush() winner_name = blackAgent.name if winner == game.PLAYERS["black"] else whiteAgent.name loser_name = whiteAgent.name if winner == game.PLAYERS["black"] else blackAgent.name print("Game over, " + winner_name+ " ("+game.PLAYER_STR[winner]+") " + "wins against "+loser_name+(" by timeout." if timeout else ".")) print(game) print(" ".join(moves)) return winner
def gtp_undo(self,args): "Undo the last move." try: self.history.pop() self.game = gamestate(self.game.size) for (move, player) in self.history: self.game.set_turn(player) self.game.play(move) self.agent.set_gamestate(self.game) except ValueError: print self.history return(False, "Undo failed!") return (True, "")
def gtp_undo(self, args): "Undo the last move." try: self.history.pop() self.game = gamestate(self.game.size) for (move, player) in self.history: self.game.set_turn(player) self.game.play(move) self.agent.set_gamestate(self.game) except ValueError: print self.history return (False, "Undo failed!") return (True, "")
def __init__(self, state = gamestate(13)): self.state = copy(state) f = file(os.path.dirname(os.path.realpath(__file__))+"/network.save", 'rb') network = cPickle.load(f) f.close() input_state = T.tensor3('input_state') self.evaluator = theano.function( [input_state], network.output[0], givens={ network.input: input_state.dimshuffle('x', 0, 1, 2), } )
def run_game(blackAgent1, blackAgent2, whiteAgent1, whiteAgent2, num_moves, boardsize, verbose = False): game = gamestate(boardsize) winner = None moves = [] mohex.sendCommand("clear_board") neurohex.sendCommand("clear_board") move_count = 0 while(True): move_count +=1 if(move_count <= num_moves): move = blackAgent1.sendCommand("genmove black").strip() blackAgent2.sendCommand("play black "+move) else: move = blackAgent2.sendCommand("genmove black").strip() blackAgent1.sendCommand("play black "+move) if( move == "resign"): winner = game.PLAYERS["white"] return winner moves.append(move) game.place_black(move_to_cell(move)) whiteAgent1.sendCommand("play black "+move) whiteAgent2.sendCommand("play black "+move) if verbose: print(blackAgent1.name+" and "+blackAgent2.name+" v.s. "+whiteAgent1.name+" and "+whiteAgent2.name) print(game) if(game.winner() != game.PLAYERS["none"]): winner = game.winner() break sys.stdout.flush() if(move_count <= num_moves): move = whiteAgent1.sendCommand("genmove white").strip() whiteAgent2.sendCommand("play white "+move) else: move = whiteAgent1.sendCommand("genmove white").strip() whiteAgent1.sendCommand("play white "+move) if( move == "resign"): winner = game.PLAYERS["black"] return winner moves.append(move) game.place_white(move_to_cell(move)) blackAgent1.sendCommand("play white "+move) blackAgent2.sendCommand("play white "+move) if verbose: print(blackAgent1.name+" and "+blackAgent2.name+" v.s. "+whiteAgent1.name+" and "+whiteAgent2.name) print(game) if(game.winner() != game.PLAYERS["none"]): winner = game.winner() break sys.stdout.flush()
def set_size(self, event): """ It changes the board size and reset the whole game. """ self.canvas.delete('all') self.size = self.game_size_value.get() self.game = gamestate(self.size) self.agent.set_gamestate(self.game) self.board = self.game.board self.board = np.int_(self.board).tolist() self.hex_board.clear() self.array_to_hex(self.board) self.black_side() self.white_side()
def __init__(self, state = gamestate(13)): self.state = copy(state) self.root = node() f = file(os.path.dirname(os.path.realpath(__file__))+"/network.save", 'rb') network = cPickle.load(f) f.close() input_state = T.tensor3('input_state') self.evaluator = theano.function( [input_state], network.output[0], givens={ network.input: input_state.dimshuffle('x', 0, 1, 2), } )
def gtp_boardsize(self, args): """ Set the size of the game board (will also clear the board). """ if (len(args) < 1): return (False, "Not enough arguments") try: size = int(args[0]) except ValueError: return (False, "Argument is not a valid size") if size < 1: return (False, "Argument is not a valid size") self.game = gamestate(size) self.agent.set_gamestate(self.game) return (True, "")
def gtp_boardsize(self, args): """ Set the size of the game board (will also clear the board). """ if(len(args)<1): return (False, "Not enough arguments") try: size = int(args[0]) except ValueError: return (False, "Argument is not a valid size") if size<1: return (False, "Argument is not a valid size") self.game = gamestate(size) self.agent.set_gamestate(self.game) return (True, "")
def __init__(self, agent): """ Initilize the list of available commands, binding appropriate names to the funcitons defined in this file. """ commands = {} commands["list_commands"] = self.gtp_list commands["size"] = self.gtp_boardsize commands["reset"] = self.gtp_clear commands["play"] = self.gtp_play commands["genmove"] = self.gtp_genmove commands["set_time"] = self.gtp_time commands["winner"] = self.gtp_winner self.commands = commands self.game = gamestate(11) self.agent = agent self.agent.set_gamestate(self.game) self.move_time = 10
def run_game(blackAgent, whiteAgent, boardsize, verbose=False): game = gamestate(boardsize) winner = None moves = [] blackAgent.sendCommand("clear_board") whiteAgent.sendCommand("clear_board") while (True): move = blackAgent.sendCommand("genmove black").strip() if (move == "resign"): winner = game.PLAYERS["white"] return winner moves.append(move) game.place_black(move_to_cell(move)) whiteAgent.sendCommand("play black " + move) if verbose: print(blackAgent.name + " v.s. " + whiteAgent.name) print(game) if (game.winner() != game.PLAYERS["none"]): winner = game.winner() break sys.stdout.flush() move = whiteAgent.sendCommand("genmove white").strip() if (move == "resign"): winner = game.PLAYERS["black"] return winner moves.append(move) game.place_white(move_to_cell(move)) blackAgent.sendCommand("play white " + move) if verbose: print(blackAgent.name + " v.s. " + whiteAgent.name) print(game) if (game.winner() != game.PLAYERS["none"]): winner = game.winner() break sys.stdout.flush() winner_name = blackAgent.name if winner == game.PLAYERS[ "black"] else whiteAgent.name loser_name = whiteAgent.name if winner == game.PLAYERS[ "black"] else blackAgent.name print("Game over, " + winner_name + " (" + game.PLAYER_STR[winner] + ") " + "wins against " + loser_name) print(game) print(" ".join(moves)) return winner
def run_game(blackAgent, whiteAgent, boardsize, verbose = False): game = gamestate(boardsize) winner = None moves = [] blackAgent.sendCommand("clear_board") whiteAgent.sendCommand("clear_board") while(True): move = blackAgent.sendCommand("genmove black").strip() if( move == "resign"): winner = game.PLAYERS["white"] return winner moves.append(move) game.place_black(move_to_cell(move)) whiteAgent.sendCommand("play black "+move) if verbose: print(blackAgent.name+" v.s. "+whiteAgent.name) print(game) if(game.winner() != game.PLAYERS["none"]): winner = game.winner() break sys.stdout.flush() move = whiteAgent.sendCommand("genmove white").strip() if( move == "resign"): winner = game.PLAYERS["black"] return winner moves.append(move) game.place_white(move_to_cell(move)) blackAgent.sendCommand("play white "+move) if verbose: print(blackAgent.name+" v.s. "+whiteAgent.name) print(game) if(game.winner() != game.PLAYERS["none"]): winner = game.winner() break sys.stdout.flush() winner_name = blackAgent.name if winner == game.PLAYERS["black"] else whiteAgent.name loser_name = whiteAgent.name if winner == game.PLAYERS["black"] else blackAgent.name print("Game over, " + winner_name+ " ("+game.PLAYER_STR[winner]+") " + "wins against "+loser_name) print(game) print(" ".join(moves)) return winner
def __init__(self, agent_name="treeNet"): """ Initialize the list of available commands, binding appropriate names to the funcitons defined in this file. """ commands = {} commands["name"] = self.gtp_name commands["version"] = self.gtp_version commands["protocol_version"] = self.gtp_protocol commands["known_command"] = self.gtp_known commands["list_commands"] = self.gtp_list commands["quit"] = self.gtp_quit commands["boardsize"] = self.gtp_boardsize commands["size"] = self.gtp_boardsize commands["clear_board"] = self.gtp_clear commands["play"] = self.gtp_play commands["undo"] = self.gtp_undo commands["genmove"] = self.gtp_genmove commands["showboard"] = self.gtp_show commands["print"] = self.gtp_show commands["set_time"] = self.gtp_time commands["winner"] = self.gtp_winner commands["hexgui-analyze_commands"] = self.gtp_analyze commands["agent"] = self.gtp_agent self.commands = commands self.game = gamestate(13) self.agent_name = agent_name try: self.agent = self.AGENTS[agent_name]() except KeyError: print("Unknown agent defaulting to basic") self.agent_name = "basic" self.agent = self.AGENTS[agent_name]() self.agent.set_gamestate(self.game) self.move_time = 10 self.history = [] register = getattr(self.agent, "register", None) if callable(register): register(self)
def __init__(self, agent_name ="basic"): """ Initilize the list of available commands, binding appropriate names to the funcitons defined in this file. """ commands={} commands["name"] = self.gtp_name commands["version"] = self.gtp_version commands["protocol_version"] = self.gtp_protocol commands["known_command"] = self.gtp_known commands["list_commands"] = self.gtp_list commands["quit"] = self.gtp_quit commands["boardsize"] = self.gtp_boardsize commands["size"] = self.gtp_boardsize commands["clear_board"] = self.gtp_clear commands["play"] = self.gtp_play commands["undo"] = self.gtp_undo commands["genmove"] = self.gtp_genmove commands["showboard"] = self.gtp_show commands["print"] = self.gtp_show commands["set_time"] = self.gtp_time commands["winner"] = self.gtp_winner commands["hexgui-analyze_commands"] = self.gtp_analyze commands["agent"] = self.gtp_agent self.commands = commands self.game = gamestate(13) self.agent_name = agent_name try: self.agent = self.AGENTS[agent_name]() except KeyError: print("Unknown agent defaulting to basic") self.agent_name = "basic" self.agent = self.AGENTS[agent_name]() self.agent.set_gamestate(self.game) self.move_time = 10 self.history = [] register = getattr(self.agent, "register", None) if callable(register): register(self)
def main(): #Board Initilisation~~ bk = king.King() bqs = [queen.Queen()] brs = [rook.Rook(), rook.Rook()] bcs = [castle.Castle(), castle.Castle()] bhs = [knight.Knight(), knight.Knight()] bps = [] for i in range(0, 8): bps.append(pawn.Pawn()) wk = king.King() wqs = [queen.Queen()] wrs = [rook.Rook(), rook.Rook()] wcs = [castle.Castle(), castle.Castle()] whs = [knight.Knight(), knight.Knight()] wps = [] for i in range(0, 8): wps.append(pawn.Pawn()) bk.setup(0, 4, 0, "b") bqs[0].setup(0, 1, 0, "b") brs[0].setup(0, 0, 0, "b") brs[1].setup(0, 5, 0, "b") bcs[0].setup(1, 2, 1, "b") bcs[1].setup(1, 3, 0, "b") bhs[0].setup(1, 1, 0, "b") bhs[1].setup(1, 4, 0, "b") bps[0].setup(1, 0, 0, 1, 0, "b") bps[1].setup(1, 1, 1, 1, 0, "b") bps[2].setup(1, 4, 1, 1, 0, "b") bps[3].setup(5, 1, 0, 1, 0, "b") bps[4].setup(2, 1, 0, 1, 0, "b") bps[5].setup(2, 2, 0, 1, 0, "b") bps[6].setup(2, 3, 0, 1, 0, "b") bps[7].setup(2, 4, 0, 1, 0, "b") wk.setup(9, 4, 0, "w") wqs[0].setup(9, 1, 0, "w") wrs[0].setup(9, 0, 0, "w") wrs[1].setup(9, 5, 0, "w") wcs[0].setup(8, 2, 0, "w") wcs[1].setup(8, 3, 0, "w") whs[0].setup(8, 1, 0, "w") whs[1].setup(8, 4, 0, "w") wps[0].setup(8, 0, 0, -1, 0, "w") wps[1].setup(8, 1, 1, -1, 0, "w") wps[2].setup(8, 4, 1, -1, 0, "w") wps[3].setup(8, 5, 0, -1, 0, "w") wps[4].setup(7, 1, 0, -1, 0, "w") wps[5].setup(7, 2, 0, -1, 0, "w") wps[6].setup(7, 3, 0, -1, 0, "w") wps[7].setup(7, 4, 0, -1, 0, "w") players = ["User", "User"] game = gamestate.gamestate() game.setup( [[brs[0], bqs[0], "X", "X", bk, brs[1]], [bps[0], [bps[1], bhs[0]], bcs[0], bcs[1], [bps[2], bhs[1]], bps[3]], ["X", bps[4], bps[5], bps[6], bps[7], "X"], ["X", ["", ""], ["", ""], ["", ""], ["", ""], "X"], ["X", ["", ""], ["", ""], ["", ""], ["", ""], "X"], ["X", ["", ""], ["", ""], ["", ""], ["", ""], "X"], ["X", ["", ""], ["", ""], ["", ""], ["", ""], "X"], ["X", wps[4], wps[5], wps[6], wps[7], "X"], [wps[0], [wps[1], whs[0]], wcs[0], wcs[1], [wps[2], whs[1]], wps[3]], [wrs[0], wqs[0], "X", "X", wk, wrs[1]]], players) #~~~~~~~~~~~~~~~~~~~~~ #Game Loop~~~~~~~~~~~~ yn = True while yn: if game.getPlayers()[game.getTurn()] == "User": controlIfUser(game) elif game.getPlayers()[game.getTurn()] == "Bot": controlIfBot(game) else: print("Player " + str(game.getTurn() + 1) + " is unrecongised")
def __init__(self, state = gamestate(13)): self.state = copy(state) self.scores = None
if args.boardsize: boardsize = args.boardsize else: boardsize = 11 if args.time: time = args.time else: time = 10 agent = Program(args.program, False) agent.sendCommand("boardsize "+str(boardsize)) agent.sendCommand("set_time "+str(time)) human_game = gamestate(boardsize) game = gamestate(boardsize) winner = None moves = [] while(True): if(args.first): moves.append(get_human_move(game, human_game, "black")) if(game.winner() != game.PLAYERS["none"]): winner = game.winner() break print("waiting for opponent...") moves.append(make_valid_move(game, agent, "white").strip()) print("done") if(game.winner() != game.PLAYERS["none"]): winner = game.winner()
if args.boardsize: boardsize = args.boardsize else: boardsize = 11 if args.time: time = args.time else: time = 10 agent = Program(args.program, False) agent.sendCommand("boardsize " + str(boardsize)) agent.sendCommand("set_time " + str(time)) human_game = gamestate(boardsize) game = gamestate(boardsize) winner = None moves = [] while (True): if (args.first): moves.append(get_human_move(game, human_game, "black")) if (game.winner() != game.PLAYERS["none"]): winner = game.winner() break print("waiting for opponent...") moves.append(make_valid_move(game, agent, "white").strip()) print("done") if (game.winner() != game.PLAYERS["none"]): winner = game.winner()
def __init__(self, state=gamestate(8)): self.rootstate = deepcopy(state) self.root = node()
def __init__(self, graphics, level, players, inputqueue, options): self.graphics = graphics self.inputqueue = inputqueue graphics.load(level.objectsUsed) # initialize events events = event.events() events.token = event.event("token") #arguments: none events.timeout = event.event( "timeout") # arguments: gamestate, object that timed out events.collision = event.event( "collision") # arguments: gamestate, object1, object2 events.playerkilled = event.event( "playerkilled") # arguments: gamestate, bomberman, explosion events.playerspawned = event.event( "playerspawned") # arguments: bomberman events.bombexplode = event.event( "bombexplode") # arguments: bombcoordinate, bombrange events.poweruppickup = event.event( "poweruppickup") # arguments: bombcoordinate, bombrange events.eMouseEvent = event.event("eMouseEvent") # emits as data: the message as a string, player_id as an integer. events.eChtMessage = event.event("eChtMessage") # these all emit as data: player_id as an integer. events.eAcceForwOn = event.event("eAcceForwOn") events.eAcceBackOn = event.event("eAcceBackOn") events.eStepLeftOn = event.event("eStepLeftOn") events.eStepRghtOn = event.event("eStepRghtOn") events.eDropBombOn = event.event("eDropBombOn") events.ePowerup1On = event.event("ePowerup1On") events.ePowerup2On = event.event("ePowerup2On") events.ePowerup3On = event.event("ePowerup3On") events.eMinimapTOn = event.event("eMinimapTOn") events.eAcceForwOff = event.event("eAcceForwOff") events.eAcceBackOff = event.event("eAcceBackOff") events.eStepLeftOff = event.event("eStepLeftOff") events.eStepRghtOff = event.event("eStepRghtOff") events.eDropBombOff = event.event("eDropBombOff") events.ePowerup1Off = event.event("ePowerup1Off") events.ePowerup2Off = event.event("ePowerup2Off") events.ePowerup3Off = event.event("ePowerup3Off") events.eMinimapTOff = event.event("eMinimapTOff") events.eNeatQuit = event.event("eNeatQuit") events.token.register(engine.play) time = options.get( "time", 120) #TODO: tijd (timeleft in dit geval dacht ik) goed regelen level.createLevel(self, players) level.loadScripts(events) self.graphics.initEvents(events) self.gamestate = gamestate.gamestate(self, level, players, events, 10, time) #TODO: framerate fixen graphics.buildLists(self.gamestate) self.inputqueuehandler = testqhandlers.QReaderEventWriter( inputqueue, self.gamestate)
def __init__(self, root, agent): self.root = root self.root.geometry('1366x690+0+0') self.agent = agent self.game = gamestate(8) self.time = 1 self.agent.set_gamestate(self.game) self.root.configure(bg='#363636') self.colors = { 'white': '#ffffff', 'milk': '#e9e5e5', 'red': '#9c0101', 'orange': '#ee7600', 'yellow': '#f4da03', 'green': '#00ee76', 'cyan': '#02adfd', 'blue': '#0261fd', 'purple': '#9c02fd', 'gray1': '#958989', 'gray2': '#1c1c1c', 'black': '#000000' } global bg bg = self.colors['gray2'] self.frame_board = Frame(self.root) # main frame for the play board self.canvas = Canvas(self.frame_board, bg=bg) self.scroll_y = ttk.Scrollbar(self.frame_board, orient=VERTICAL) self.scroll_x = ttk.Scrollbar(self.frame_board, orient=HORIZONTAL) # the notebook frame which holds the left panel frames self.notebook = ttk.Notebook(self.frame_board, width=350) self.panel_game = Frame(self.notebook, highlightbackground=self.colors['white']) self.panel_tournament = Frame(self.notebook, highlightbackground=self.colors['white']) self.developers = Frame(self.notebook, highlightbackground=self.colors['white']) self.contact = Frame(self.notebook, highlightbackground=self.colors['white']) # Introduction of items in left panel ---> Game self.game_size_value = IntVar() self.game_time_value = IntVar() self.game_turn_value = IntVar() self.turn = {1: 'white', 2: 'black'} self.game_size = Scale(self.panel_game) self.game_time = Scale(self.panel_game) self.game_turn = Scale(self.panel_game) self.generate = Button(self.panel_game) self.reset_board = Button(self.panel_game) # Introduction of items in left panel ---> Tournament self.tournament_size_val = IntVar() self.tournament_time_val = IntVar() self.tournament_num_val = IntVar() # ----------------------------------------------- self.hex_board = [] # Holds the IDs of hexagons in the main board for implementing the click and play functions self.game_size_value.set(8) self.game_time_value.set(1) self.size = self.game_size_value.get() self.time = self.game_time_value.get() self.tournament_size = Scale(self.panel_tournament) self.tournament_time = Scale(self.panel_tournament) self.board = self.game.board self.board = np.int_(self.board).tolist() self.array_to_hex(self.board) # building the game board self.black_side() self.white_side() # Frame_header frame_header = Frame(self.root, bg=bg) frame_header.pack(fill=X) Label(frame_header, font=('Calibri', 40, 'bold'), fg='white', bg=bg, text='MB-Hex').pack(side=LEFT, padx=260, pady=10) # Frame_content self.frame_board.configure(width=1100, height=545, bg=bg) self.frame_board.pack(fill=X) self.notebook.add(self.panel_game, text=' Game ') self.notebook.add(self.panel_tournament, text=' Tournament ') self.notebook.add(self.developers, text=' Developers ') self.notebook.add(self.contact, text=' Contact ') self.notebook.pack(side=LEFT, fill=Y) self.canvas.configure(width=980, bg=bg, cursor='hand2') self.canvas.pack(side=LEFT, fill=Y) self.canvas.configure(yscrollcommand=self.scroll_y.set) self.scroll_y.configure(command=self.canvas.yview) self.scroll_x.configure(command=self.canvas.xview) self.scroll_y.place(x=387, y=482) self.scroll_x.place(x=370, y=500) # Frame_left_panel """ the left panel notebook ----> Game """ self.panel_game.configure(bg=bg) Label(self.panel_game, text=' Game ', font=('Calibri', 18, 'bold'), foreground='white', bg=bg, pady=5).pack(fill=X, side=TOP) Label(self.panel_game, text='Board size', font=('Calibri', 14, 'bold'), foreground='white', bg=bg, pady=30).pack(fill=X, side=TOP) # label ---> Board size self.game_size.configure(from_=3, to=20, tickinterval=1, bg=bg, fg='white', orient=HORIZONTAL, variable=self.game_size_value) self.game_size.pack(side=TOP, fill=X) Label(self.panel_game, text='Time', font=('Calibri', 14, 'bold'), foreground='white', bg=bg, pady=30).pack(side=TOP, fill=X) # label ---> Time self.game_time.configure(from_=1, to=20, tickinterval=1, bg=bg, fg='white', orient=HORIZONTAL, variable=self.game_time_value) self.game_time.pack(side=TOP, fill=X) Label(self.panel_game, text='Player', font=('Calibri', 14, 'bold'), foreground='white', bg=bg, pady=30).pack(side=TOP, fill=X) # label ---> Turn self.game_turn.configure(from_=1, to=2, tickinterval=1, bg=bg, fg='white', orient=HORIZONTAL, variable=self.game_turn_value) self.game_turn.pack(side=TOP) Label(self.panel_game, text=' ', font=('Calibri', 14, 'bold'), foreground='white', bg=bg).pack(side=TOP, fill=X) self.reset_board.configure(text='Reset Board', pady=10, cursor='hand2', width=22, font=('Calibri', 12, 'bold')) self.reset_board.pack(side=LEFT) self.generate.configure(text='Generate', pady=10, cursor='hand2', width=22, font=('Calibri', 12, 'bold')) self.generate.pack(side=LEFT) """ the left panel notebook ----> tournament """ self.panel_tournament.configure(bg=bg) Label(self.panel_tournament, text='Tournament', font=('Calibri', 18, 'bold'), foreground='white', bg=bg, pady=5).pack(side=TOP, fill=X) Label(self.panel_tournament, text='Board size', font=('Calibri', 14, 'bold'), foreground='white', bg=bg, pady=30).pack(side=TOP, fill=X) # label ---> Board size self.tournament_size.configure(from_=3, to=20, tickinterval=1, bg=bg, fg='white', orient=HORIZONTAL, variable=self.game_size_value) self.tournament_size.pack(side=TOP, fill=X) Label(self.panel_tournament, text='Time', font=('Calibri', 14, 'bold'), foreground='white', bg=bg, pady=30).pack(side=TOP, fill=X) # label ---> Time self.tournament_time.configure(from_=1, to=20, tickinterval=1, bg=bg, fg='white', orient=HORIZONTAL, variable=self.game_time_value) self.tournament_time.pack(side=TOP, fill=X) Label(self.panel_tournament, text='Game number', font=('Calibri', 14, 'bold'), foreground='white', bg=bg, pady=30).pack(side=TOP, fill=X) # label ---> Game number self.tournament_number = Scale(self.panel_tournament, from_=0, to=100, tickinterval=10, bg=bg, fg='white', orient=HORIZONTAL, variable=self.tournament_num_val) self.tournament_number.pack(side=TOP, fill=X) Label(self.panel_tournament, text=' ', font=('Calibri', 14, 'bold'), foreground='white', bg=bg).pack(side=TOP, fill=X) Button(self.panel_tournament, text=' START ', cursor='hand2', width=12, font=('Calibri', 12, 'bold'), pady=10).pack(side=TOP, fill=X) """ the left panel notebook ---> Developers """ self.developers.configure(bg=bg) Label(self.developers, text='Develped by:', font=('Calibri', 18, 'bold'), justify=LEFT, foreground='white', bg=bg, pady=20).pack(side=TOP, fill=X) Label( self.developers, text= 'Masoud Masoumi Moghadam\nNemat Rahmani\nMaster of science Students at', font=('Calibri', 15, 'bold'), wraplength=300, justify=LEFT, foreground='white', bg=bg, pady=10).pack(side=TOP, fill=X) Label(self.developers, text='Supervised by:', font=('Calibri', 18, 'bold'), wraplength=200, justify=LEFT, foreground='white', bg=bg, pady=20).pack(side=TOP, fill=X) Label(self.developers, text='Dr. Tahmouresnezhad', font=('Calibri', 15, 'bold'), wraplength=300, justify=LEFT, foreground='white', bg=bg, pady=10, padx=20).pack(side=TOP, fill=X) Label(self.developers, text=' ', bg=bg).pack(side=TOP, fill=X) Label(self.developers, text='Summer 2016', font=('Calibri', 18, 'bold'), wraplength=350, justify=LEFT, foreground='white', bg=bg, pady=40).pack(side=TOP, fill=X) """ the left panel notebook ---> Contact """ self.contact.configure(bg=bg) Label(self.contact, text='Masoud Masoumi Moghadam', font=('Calibri', 15, 'bold'), justify=LEFT, fg='white', bg=bg, pady=10).pack(side=TOP) Label(self.contact, text='*****@*****.**', font=('Calibri', 15, 'bold'), justify=LEFT, fg='white', bg=bg, pady=10).pack(side=TOP) Label(self.contact, text='Nemat Rahmani', font=('Calibri', 15, 'bold'), justify=LEFT, fg='white', bg=bg, pady=10).pack(side=TOP) Label(self.contact, text='*****@*****.**', font=('Calibri', 15, 'bold'), justify=LEFT, fg='white', bg=bg, pady=10).pack(side=TOP) Label(self.contact, text='Dr.Tahmoresnezhad', font=('Calibri', 15, 'bold'), justify=LEFT, fg='white', bg=bg, pady=10).pack(side=TOP) Label(self.contact, text='*****@*****.**', font=('Calibri', 15, 'bold'), justify=LEFT, fg='white', bg=bg, pady=10).pack(side=TOP) # Binding Actions """ Binding triggers for the actions defined in the class. """ self.canvas.bind('<1>', self.mouse_click) self.game_size.bind('<ButtonRelease>', self.set_size) self.tournament_size.bind('<ButtonRelease>', self.set_size) self.game_time.bind('<ButtonRelease>', self.set_time) self.tournament_time.bind('<ButtonRelease>', self.set_time) self.generate.bind('<ButtonRelease>', self.generate_move) self.reset_board.bind('<ButtonRelease>', self.reset)