def __init__(self, visible=True, map_class=map_parser.map_parser(), delete_subgoals=True): self.visible = visible self.delete_subgoals = delete_subgoals self.robot_position = [None, None] # self.game_logic = game_fsm.Collect_Ball_Simple() self.game_logic = game_fsm.three_steps_game() self.time_counter = 0 self.map_class = map_class self.nb_action = 4 self.game_state = game_state.RobotStatus() self.robot_agent = agents.AgentRandom(nb_actions=4) self.game_over = False self.game_score = 0 # Load the map self.map_class.read_map() self.game_state.unique_elements = self.map_class.unique_elements
import agents import time import gym_2048 import gym import numpy from common.Game2048Wrapper import * path = "models/game2048_dqn_a/" env = gym.make("2048-v0") #env = gym.make("Tiny2048-v0") env = Game2048Wrapper(env, 4) env.reset() obs_shape = env.observation_space.shape actions_count = env.action_space.n print("observation shape ", obs_shape) print("actions count ", actions_count) print("observation\n", env.observation_space) agent = agents.AgentRandom(env) while True: agent.main() env.render() print("\n\n") time.sleep(0.01)
print("Select gamemode") print("0: Training") print("1: Single player") print("2: Multi player") print("3: Competing agents") gamemode = input("? ") #Initialize the game game = bs.Battleship(gamemode) if(gamemode==0): agent1 = None agent2 = None if(gamemode==1): agent1 = agents.AgentReal() agent2 = agents.AgentRandom() elif(gamemode==2): agent1 = agents.AgentReal() agent2 = agents.AgentReal() elif(gamemode==3): agent1 = agents.AgentRandom() agent2 = agents.AgentRandom() game.players[0].getShotLocation = agent1.getShotLocation game.players[1].getShotLocation = agent2.getShotLocation #Initialize the grids grid1 = game.loadShipMatrixFromFile('shipmatrix1.txt') game.players[0].placeShipsFromMatrix(grid1) #game.players[0].placeShipsRandom()