if gui_active: win.updateSprites(state) win.refresh() if verbose > 0: state.printGrid(game.grid_size) return state if __name__ == "__main__": if len(sys.argv) > 1: max_iter = int(sys.argv[1]) else: max_iter = None minimax_agent = MinimaxAgent(depth=lambda s,a: 2) alphabeta_agent = AlphaBetaAgent(depth=lambda s,a: survivorDfunc(s, a, 4, 0.5), evalFn=greedyEvaluationFunction) expectimax_agent = ExpectimaxAgent(depth=lambda s,a: cowardCenterDepthFunction(s, a, 2), evalFn=greedyEvaluationFunction) strategies = [smartGreedyStrategy, opportunistStrategy, alphabeta_agent.getAction] # add a human player # strategies = [humanStrategy, smartGreedyStrategy, opportunistStrategy, alphabeta_agent.getAction] # add an RL agent featureExtractor = FeatureExtractor(len(strategies), grid_size = 20, radius_ = 10) rlStrategy = load_rl_strategy("nn-nn1-r10-1b.p", strategies, featureExtractor, discount = 0.9, q_type = "nn") strategies.append(rlStrategy) controller(strategies, 20, max_iter = max_iter, gui_active = True, verbose = 0, game_speed = 10)
state.printGrid(game.grid_size) return state if __name__ == "__main__": human_player = False if len(sys.argv) > 1 and sys.argv[1] == "h": human_player = True max_iter = None minimax_agent = searchAgent("minimax", depth=lambda s, a: 2) alphabeta_agent = searchAgent( "alphabeta", depth=lambda s, a: survivorDfunc(s, a, 4, 0.5), evalFn=greedyEvaluationFunction) expectimax_agent = searchAgent( "expectimax", depth=lambda s, a: cowardCenterDepthFunction(s, a, 2), evalFn=greedyEvaluationFunction) strategies = [alphabeta_agent] # strategies = [SmartGreedyAgent, OpportunistAgent] # strategies = [SmartGreedyAgent, OpportunistAgent, alphabeta_agent] # add an RL agent rl_hp = load_from(config.filename + ".p") # rl_hp = load_from("rl-ql-linear-r6-1000.p") featureExtractor = FeatureExtractor(len(strategies), grid_size=20,
win.refresh() if verbose > 0: state.printGrid(game.grid_size) return state if __name__ == "__main__": human_player = False if len(sys.argv) > 1 and sys.argv[1] == "h": human_player = True max_iter = None minimax_agent = searchAgent("minimax", depth = lambda s,a : 2) alphabeta_agent = searchAgent("alphabeta", depth = lambda s,a : survivorDfunc(s, a, 4, 0.5), evalFn = greedyEvaluationFunction) expectimax_agent = searchAgent("expectimax", depth = lambda s,a : cowardCenterDepthFunction(s, a, 2), evalFn = greedyEvaluationFunction) # strategies = [SmartGreedyAgent, OpportunistAgent] strategies = [SmartGreedyAgent, OpportunistAgent, alphabeta_agent] # add an RL agent rl_hp = load_from(config.filename + ".p") # rl_hp = load_from("rl-ql-linear-r6-1000.p") featureExtractor = FeatureExtractor(len(strategies), grid_size = 20, radius_ = rl_hp.radius) rlStrategy = load_rl_strategy(rl_hp, strategies, featureExtractor) # rlStrategy = load_rl_strategy(rl_hp, strategies, featureExtractor) # esStrategy = load_es_strategy("es-linear-r4-50.p", strategies, featureExtractor, discount = 0.9) strategies.append(rlStrategy)