def calculate(self): try: self.status.setText("В рвботе") text = self.input.toPlainText() g = self.parse(text) game = Game(g) res = game.play() final = list() for i in res: tmp = list() for j in i: tmp.append(j+1) final.append(f"{tmp}") self.status.setText(f"{', '.join(final)} ∈ NE") except BaseException: self.status.setText("Произошла ошибка!")
# State 8 # game.import_board([" ", " ", " ", " ", " ", " ", " ", " ", "X"]) # state_num = 8 # gs = GameState(game, False, 0) # Import list of pre-processed states # in_file = open(load_path.joinpath("states_0.obj"), "rb") # loaded_states = pickle.load(in_file) # # for state in loaded_states: # # state.state_score = None # root_node = loaded_states[-1] # mm = MiniMax(loaded_states) # mm = MiniMax(GameState.game_states) # root_node = GameState.game_states[-1] # # (Pre-processing) Score all leaf nodes # for state_node in GameState.game_states: # if state_node.leaf_node: # mm.score_node(state_node) # # (Pre-processing) Run minimax to assign a score to all nodes # mm.rank_states(root_node) # # (Pre-processing) Save states to .obj # outfile = open(load_path.joinpath("states_" + str(state_num) + ".obj"), "wb") # pickle.dump(GameState.game_states, outfile) game.play()