def start_ai(self): ''' Start to play "Five or more" game for human ''' Nx, Ny, channel = self.state_shape self.gameboard = Board(board_shape=(Nx, Ny)) self.gameboard.init() board = self.gameboard.get_board() self.boards.append(board) self.update_states() state = self.get_state() availables = self.gameboard.get_availables() action = self.ai.play(state, availables) if self.verbose: print("Initiating UI...") from ui import UI, init_ui app = init_ui() self.ui = UI(pressaction=self.pressaction_ai, board=self.gameboard.get_board(), sizeunit=50) app.exec_()
def __init__(self, vs, args): setup_definitions(self, vs, args) init_ui(self) self.open_main_view() print("self.cpu_type : ",self.cpu_type) if self.cpu_type == 0: self.top_label_cpu_text.set("CPU") if self.cpu_type == 1: self.top_label_cpu_text.set("VPU") if self.cpu_type == 2: self.top_label_cpu_text.set("GPU") self.root.wm_title("ThinkerFarm") self.root.wm_protocol("WM_DELETE_WINDOW", self.on_close) print("cuda list :",cuda.get_num_devices())
def start(self): ''' Start to play "Five or more" game for human ''' Nx, Ny, channel = self.state_shape self.gameboard = Board(board_shape=(Nx, Ny)) self.gameboard.init() if self.verbose: print("Initiating UI...") from ui import UI, init_ui app = init_ui() self.ui = UI(pressaction=self.pressaction, board=self.gameboard.get_board(), sizeunit=50) app.exec_()
#!/usr/bin/env python3 import numpy as np #Seemingly only required for windows import tkinter as tk import game import ui t48 = game.Twenty48() ui.init_ui(t48) print(np.matrix(t48.board)) while True: ui.update_ui(t48) ui.window.update_idletasks() ui.window.update() if t48.hasLost: break # Final update to show most recent move ui.update_ui(t48) tk.Label(ui.window, text="You lost").grid(row=t48.size, column=1) # Make sure window doesn't freeze while True: ui.window.update_idletasks() ui.window.update()
def __init__(self): self.game_instance = game.Twenty48() ui.init_ui(self.game_instance) self.inv_move = 0
t_stamp[0] = t_stamp[1] key = ui.get_key() if key: perform_key_action(key) if __name__ == '__main__': valid_keys = NORMAL_KEYS # publisher publisher = zmq_pubsub.ZmqPublisher(ZMQ_PUBLISH_ENDPOINT, ZMQ_PUBLISH_ID) # ui ui.init_ui() # publish pub_piece_func = register_publish_encoder(codec.encode_piece) pub_board_func = register_publish_encoder(codec.encode_board) pub_score_func = register_publish_encoder(codec.encode_score) # signal piece.status_changed.connect(pub_piece_func) piece.status_changed.connect(ui.update_focus) # 方塊位置變更 board.status_changed.connect(pub_board_func) score.value_changed.connect(pub_score_func) # 第一個piece ui.new_focus() piece.rand_new_piece()
def main(): db.DBconnect() ui.init_ui() db.DBclose()