def create_mission(ind,agent_host,start, dropoff, pickup): my_mission = MalmoPython.MissionSpec(GetMissionXML(start), True) my_mission_record = MalmoPython.MissionRecordSpec() my_mission.requestVideo(800, 500) my_mission.setViewpoint(1) # Attempt to start a mission: max_retries = 3 my_clients = MalmoPython.ClientPool() my_clients.add(MalmoPython.ClientInfo('127.0.0.1', 10000)) # add Minecraft machines here as available my_mission.drawBlock(int(pickup[0]), 1, int(pickup[1]), "redstone_block") my_mission.drawBlock(int(dropoff[0]), 1, int(dropoff[1]), "diamond_block") for retry in range(max_retries): try: agent_host.startMission( my_mission, my_clients, my_mission_record, 0, "%s-%d" % ('Herobrine', ind) ) break except RuntimeError as e: if retry == max_retries - 1: print("Error starting mission", ":",e) exit(1) else: time.sleep(2) world_state = agent_host.peekWorldState() while not world_state.has_mission_begun: time.sleep(0.1) world_state = agent_host.peekWorldState() for error in world_state.errors: print("Error:",error.text) time.sleep(1) return my_mission, world_state
def load_solo_mission(self, mission, agent): mission_record = MalmoPython.MissionRecordSpec() mission.setViewpoint(0) clients = MalmoPython.ClientPool() clients.add(MalmoPython.ClientInfo( '127.0.0.1', 10000)) # add Minecraft machines here as available #Quit from existing mission max_retries = 25 #Quit out of currently running mission agent.sendCommand("quit") # Attempt to start a mission: for retry in range(max_retries): try: agent.startMission(mission, clients, mission_record, 0, "") break except RuntimeError as e: if retry == max_retries - 1: print("Failed to start mission.") exit(1) else: time.sleep(2) # Loop until mission starts: print("Waiting for the mission to start ") world_state = agent.getWorldState() while not world_state.has_mission_begun: #sys.stdout.write(".") time.sleep(0.1) world_state = agent.getWorldState() for error in world_state.errors: print("Error:", error.text) print() print("Mission running.")
def init_malmo(self): """ Initialize new malmo mission. """ my_mission = MalmoPython.MissionSpec(self.GetMissionXML(), True) my_mission.forceWorldReset() #so it doesn't collect any past objects my_mission_record = MalmoPython.MissionRecordSpec() my_mission.requestVideo(800, 500) my_mission.setViewpoint(1) self.num_entities = self.num_entities_copy max_retries = 3 my_clients = MalmoPython.ClientPool() my_clients.add(MalmoPython.ClientInfo( '127.0.0.1', 10000)) # add Minecraft machines here as available for retry in range(max_retries): try: self.agent_host.startMission(my_mission, my_clients, my_mission_record, 0, "ZombieKiller") break except RuntimeError as e: if retry == max_retries - 1: print("Error starting mission:", e) exit(1) else: time.sleep(2) self.cobblestone_wall = 0 return self.agent_host
def init_malmo(agent_host): """ Initialize new malmo mission. """ my_mission = MalmoPython.MissionSpec(GetMissionXML(), True) my_mission_record = MalmoPython.MissionRecordSpec() my_mission.requestVideo(1200, 700) my_mission.setViewpoint(0) max_retries = 3 my_clients = MalmoPython.ClientPool() my_clients.add(MalmoPython.ClientInfo( '127.0.0.1', 10000)) # add Minecraft machines here as available for retry in range(max_retries): try: agent_host.startMission(my_mission, my_clients, my_mission_record, 0, "Dropper") break except RuntimeError as e: if retry == max_retries - 1: print("Error starting mission:", e) exit(1) else: time.sleep(2) return agent_host
def init_malmo(agent_host): my_mission = MalmoPython.MissionSpec( GetMissionXML(Hyperparameters.SIZE, Hyperparameters.OBS_SIZE, Hyperparameters.MAX_EPISODE_STEPS), True) my_mission_record = MalmoPython.MissionRecordSpec() my_mission.requestVideo(800, 500) my_mission.setViewpoint(1) max_retries = 3 my_clients = MalmoPython.ClientPool() my_clients.add(MalmoPython.ClientInfo( '127.0.0.1', 10000)) # add Minecraft machines here as available my_clients.add(MalmoPython.ClientInfo('127.0.0.1', 10001)) for retry in range(max_retries): try: agent_host.startMission(my_mission, my_clients, my_mission_record, 0, "MineGuyz") break except RuntimeError as e: if retry == max_retries - 1: print("Error starting mission:", e) exit(1) else: time.sleep(2) return agent_host
def init_malmo(self): """ Initialize new malmo mission. """ my_mission = MalmoPython.MissionSpec(self.get_mission_xml(), True) my_mission_record = MalmoPython.MissionRecordSpec() my_mission.requestVideo(800, 500) my_mission.setViewpoint(1) max_retries = 3 my_clients = MalmoPython.ClientPool() my_clients.add(MalmoPython.ClientInfo( '127.0.0.1', 10000)) # add Minecraft machines here as available for retry in range(max_retries): try: self.agent_host.startMission(my_mission, my_clients, my_mission_record, 0, 'DiamondCollector') break except RuntimeError as e: if retry == max_retries - 1: print("Error starting mission:", e) exit(1) else: time.sleep(2) world_state = self.agent_host.getWorldState() while not world_state.has_mission_begun: time.sleep(0.1) world_state = self.agent_host.getWorldState() for error in world_state.errors: print("\nError:", error.text) return world_state
def record_malmo_video(self, instructions, xml_file, seed): ''' Replays a set of instructions through Malmo using two players. The first player will navigate the specified mission based on the given instructions. The second player observes the first player's moves, which is captured in a video. ''' if not self.is_malmo_initialized: raise Exception('Malmo not initialized. Call init_malmo() first.') # Set up the mission my_mission = MalmoPython.MissionSpec(self._get_xml(xml_file, seed), True) bot_recording_spec = MalmoPython.MissionRecordSpec() camera_recording_spec = MalmoPython.MissionRecordSpec() recordingsDirectory = \ malmoutils.get_recordings_directory(self.agent_host_bot) if recordingsDirectory: camera_recording_spec.setDestination(recordingsDirectory + "//rollout_" + str(seed) + ".tgz") camera_recording_spec.recordMP4(MalmoPython.FrameType.VIDEO, 36, 2000000, False) # Start the agents self._start_mission(self.agent_host_bot, my_mission, bot_recording_spec, 0) self._start_mission(self.agent_host_camera, my_mission, camera_recording_spec, 1) self._wait_for_start([self.agent_host_camera, self.agent_host_bot]) # Teleport the camera agent to the required position self.agent_host_camera.sendCommand('tp -29 72 -6.7') instruction_index = 0 while self._is_mission_running(): command = instructions[instruction_index] instruction_index += 1 self.agent_host_bot.sendCommand(command) # Pause for half a second - change this for faster/slower videos time.sleep(0.5) if instruction_index == len(instructions): self.agent_host_bot.sendCommand("jump 1") time.sleep(2) self.agent_host_bot.sendCommand("quit") # Wait a little for Malmo to reset before the # next mission is started time.sleep(2) print("Video recorded.")
def _config_clients( clients: List[Tuple[str, int]] = None) -> Union[None, MalmoPython.ClientPool]: if clients is None: return None client_pool = MalmoPython.ClientPool() for client in clients: client_pool.add(MalmoPython.ClientInfo(client[0], client[1])) return client_pool
def load_duo_mission(self, mission, agents): #agen mission_record = MalmoPython.MissionRecordSpec() mission.setViewpoint(0) # Attempt to start a mission: max_retries = 25 #Quit out of currently running mission agents[0].sendCommand("quit") agents[1].sendCommand("quit") clients = MalmoPython.ClientPool() clients.add(MalmoPython.ClientInfo('127.0.0.1', 10001)) clients.add(MalmoPython.ClientInfo('127.0.0.1', 10002)) for retry in range(max_retries): try: agents[0].startMission(mission, clients, mission_record, 0, "") break except RuntimeError as e: print("Error starting mission", e) if retry == max_retries - 1: exit(1) else: time.sleep(2) for retry in range(max_retries): try: agents[1].startMission(mission, clients, mission_record, 1, "") break except RuntimeError as e: print("Error starting mission", e) if retry == max_retries - 1: exit(1) else: time.sleep(2) # Loop until mission starts: print("Waiting for the mission to start ") world_state = agents[0].getWorldState() error_ticks = 0 while not world_state.has_mission_begun: #sys.stdout.write(".") time.sleep(0.1) world_state = agents[0].getWorldState() for error in world_state.errors: print("Error:", error.text) if len(world_state.errors) > 0: error_ticks += 1 if error_ticks >= 5: return self.load_duo_mission(mission, agents) print() print("Mission running.")
def __init__(self, env_config): self.size = 21 self.obs_size = 21 self.max_episode_steps = 100 self.log_frequency = 10 self.action_dict = { 0: 'move 1', 1: 'move -1', 2: 'turn 1', 3: 'turn 0', 4: 'attack 1' } # self.action_space = Box(-1, 1, shape=(3,), dtype=np.float32) self.action_space = Discrete(len(self.action_dict)) self.observation_space = Box(0, 1, shape=(np.prod( [1, self.obs_size, self.obs_size]), ), dtype=np.int32) self.agent_host = MalmoPython.AgentHost() self.agentinf = agent() try: self.agent_host.parse(sys.argv) except RuntimeError as e: print('ERROR:', e) print(self.agent_host.getUsage()) exit(1) self.obs = None self.episode_step = 0 self.episode_return = 0 self.returns = [] self.steps = []
def __init__(self): self.agentHost = MalmoPython.AgentHost() try: self.agentHost.parse(sys.argv) except RuntimeError as e: print('ERROR:', e) print(self.agentHost.getUsage()) sys.exit(1)
def __init__(self, missionXML, validate, setup_mission=None): super() self.agent_host = MalmoPython.AgentHost() try: self.agent_host.parse(sys.argv) except RuntimeError as e: print('ERROR:', e) print(self.agent_host.getUsage()) exit(1) if self.agent_host.receivedArgument("help"): print(self.agent_host.getUsage()) exit(0) self.mission = MalmoPython.MissionSpec(missionXML, validate) self.mission_record = MalmoPython.MissionRecordSpec() if (setup_mission is not None): setup_mission(self.mission)
def __init__(self, env_config): # Static Parameters self.size_y = 25 self.size_x = 10 self.size_z = 20 # self.reward_density = .1 # self.penalty_density = .02 # self.obs_size = 5 # self.obs_size_x = 5 # self.obs_size_y = 5 # self.obs_size_z = 5 self.max_episode_steps = 100 #100 self.log_frequency = 1 #10 self.num_ghasts = 1 self.action_dict = { 0: 'movewest 1', # Move one block forward 1: 'moveeast 1', # Turn 90 degrees to the right 2: 'attack 1', # Destroy block } # Rllib Parameters # continuous self.action_space = Box(low=np.array([-1, 0]), high=np.array([1, 1])) # [move attack] # discrete # self.action_space = Discrete(len(self.action_dict)) self.observation_space = Box(-50, 50, shape=(self.num_ghasts * 1 * 3, ), dtype=np.float32) # Malmo Parameters self.agent_host = MalmoPython.AgentHost() try: self.agent_host.parse( sys.argv ) except RuntimeError as e: print('ERROR:', e) print(self.agent_host.getUsage()) exit(1) # GhastKiller Parameters self.obs = None self.allow_break_action = False self.episode_step = 0 self.episode_return = 0 self.returns = [] self.steps = [] self.ghasts = collections.defaultdict(dict) self.fireballs = collections.defaultdict(dict) self.agentState = {"pos": (0.5, 21, -9.5), "life": 20, "prevLife": 20} self.step_dodge = 0 self.episode_dodge = set() self.step_hitback = 0 self.episode_hitback = set() self.step_kill = 0
def init_malmo(agent_host, recordingsDirectory, video_width, video_height): my_mission = MalmoPython.MissionSpec( GetMissionXML(Hyperparameters.SIZE, Hyperparameters.OBS_SIZE, Hyperparameters.MAX_EPISODE_STEPS, video_width, video_height), True) my_mission.setViewpoint(0) agent_host.setObservationsPolicy( MalmoPython.ObservationsPolicy.LATEST_OBSERVATION_ONLY) agent_host.setVideoPolicy(MalmoPython.VideoPolicy.LATEST_FRAME_ONLY) my_mission_record = MalmoPython.MissionRecordSpec() if recordingsDirectory: my_mission_record.recordRewards() my_mission_record.recordObservations() my_mission_record.recordCommands() if agent_host.receivedArgument("record_video"): my_mission_record.recordMP4(24, 2000000) if recordingsDirectory: my_mission_record.setDestination(recordingsDirectory + "//" + "Mission_" + str(test + 1) + ".tgz") max_retries = 3 my_clients = MalmoPython.ClientPool() my_clients.add(MalmoPython.ClientInfo( '127.0.0.1', 10000)) # add Minecraft machines here as available my_clients.add(MalmoPython.ClientInfo('127.0.0.1', 10001)) for retry in range(max_retries): try: agent_host.startMission(my_mission, my_clients, my_mission_record, 0, "MineGuyz") break except RuntimeError as e: if retry == max_retries - 1: print("Error starting mission:", e) exit(1) else: time.sleep(2) return agent_host
def two_agent_init(self): # Create default Malmo objects: agent1 = MalmoPython.AgentHost() agent2 = MalmoPython.AgentHost() try: agent1.parse(sys.argv) agent2.parse(sys.argv) except RuntimeError as e: print('ERROR:', e) print(agent1.getUsage()) print(agent2.getUsage()) exit(1) if agent1.receivedArgument("help"): print(agent1.getUsage()) exit(0) if agent2.receivedArgument("help"): print(agent2.getUsage()) exit(0) return (agent1, agent2)
def __init__(self): super(MinecraftEnv, self).__init__() self.agent_host = MalmoPython.AgentHost() self.client_pool = None self.mc_process = None self.screen = None self.experiment_id = None self._turn = None self.load_mission_xml()
def create_malmo_obj(): agent_host = MalmoPython.AgentHost() try: agent_host.parse( sys.argv ) except RuntimeError as e: print('ERROR:',e) print(agent_host.getUsage()) exit(1) if agent_host.receivedArgument("help"): print(agent_host.getUsage()) exit(0) return agent_host
def one_agent_init(self): agent = MalmoPython.AgentHost() try: agent.parse(sys.argv) except RuntimeError as e: print('ERROR:', e) print(agent.getUsage()) exit(1) if agent.receivedArgument("help"): print(agent.getUsage()) exit(0) return agent
def __init__( self, missionXML, validate, setup_mission=None, ip="127.0.0.1", port=10000 ): super() self.agent_host = MalmoPython.AgentHost() self.clientPool = MalmoPython.ClientPool() self.clientPool.add(MalmoPython.ClientInfo(ip, port)) try: self.agent_host.parse(sys.argv) except RuntimeError as e: print("ERROR:", e) print(self.agent_host.getUsage()) exit(1) if self.agent_host.receivedArgument("help"): print(self.agent_host.getUsage()) exit(0) self.mission = MalmoPython.MissionSpec(missionXML, validate) self.mission_record = MalmoPython.MissionRecordSpec() if setup_mission is not None: setup_mission(self.mission)
def create_mission(ind, agent_host): my_mission = MalmoPython.MissionSpec(GetMissionXML(), True) my_mission_record = MalmoPython.MissionRecordSpec() my_mission.requestVideo(800, 500) my_mission.setViewpoint(1) # Attempt to start a mission: max_retries = 3 my_clients = MalmoPython.ClientPool() my_clients.add(MalmoPython.ClientInfo( '127.0.0.1', 10000)) # add Minecraft machines here as available for i in range(len(legalPosList)): if i == itemPosId: my_mission.drawBlock(legalPosList[itemPosId][0], 1, legalPosList[itemPosId][1], "emerald_block") elif i == destPosId: my_mission.drawBlock(legalPosList[destPosId][0], 1, legalPosList[destPosId][1], "diamond_block") else: my_mission.drawBlock(legalPosList[i][0], 1, legalPosList[i][1], "stone") for retry in range(max_retries): try: agent_host.startMission(my_mission, my_clients, my_mission_record, 0, "%s-%d" % ('Herobrine', ind)) break except RuntimeError as e: if retry == max_retries - 1: print("Error starting mission", ":", e) exit(1) else: time.sleep(2) world_state = agent_host.peekWorldState() while not world_state.has_mission_begun: time.sleep(0.1) world_state = agent_host.peekWorldState() for error in world_state.errors: print("Error:", error.text) time.sleep(1) return my_mission
def __init__(self, env_config): # Static Parameters self.size = 35 self.mobCount = 5 #amount of mobs per mob type # Malmo Parametersa self.agent_host = MalmoPython.AgentHost() world_state = self.init_malmo() try: self.agent_host.parse( sys.argv ) except RuntimeError as e: print('ERROR:', e) print(self.agent_host.getUsage()) exit(1)
def reset_world(agent_host, mission_xml_path, my_clients, agentID, expID, logger): reseted = False while not reseted: my_mission_record = MalmoPython.MissionRecordSpec() with open(mission_xml_path, 'r') as f: logger.info("Loading mission from %s" % mission_xml_path) mission_xml = f.read() my_mission = MalmoPython.MissionSpec(mission_xml, True) my_mission.removeAllCommandHandlers() my_mission.allowAllDiscreteMovementCommands() my_mission.setViewpoint(2) for retry in range(MAX_RETRIES): try: agent_host.startMission(my_mission, my_clients, my_mission_record, agentID, "%s" % (expID)) break except RuntimeError as e: if retry == MAX_RETRIES - 1: logger.info(f"Error starting mission: {e}") exit(1) else: time.sleep(2.5) world_state = agent_host.getWorldState() while not world_state.has_mission_begun: time.sleep(0.1) world_state = agent_host.getWorldState() agent_host.sendCommand("look -1") agent_host.sendCommand("look -1") while world_state.is_mission_running and all( e.text == '{}' for e in world_state.observations): world_state = agent_host.peekWorldState() reseted = len(world_state.observations) > 0 return world_state
def init_malmo(self, recordings_directory=DEFAULT_RECORDINGS_DIR): if self.is_malmo_initialized: return launch_minecraft_in_background('/app/MalmoPlatform/Minecraft', ports=[10000, 10001]) # Set up two agent hosts self.agent_host_bot = MalmoPython.AgentHost() self.agent_host_camera = MalmoPython.AgentHost() # Create list of Minecraft clients to attach to. The agents must # have been launched before calling record_malmo_video using # init_malmo() self.client_pool = MalmoPython.ClientPool() self.client_pool.add(MalmoPython.ClientInfo('127.0.0.1', 10000)) self.client_pool.add(MalmoPython.ClientInfo('127.0.0.1', 10001)) # Use bot's agenthost to hold the command-line options malmoutils.parse_command_line( self.agent_host_bot, ['--record_video', '--recording_dir', recordings_directory]) self.is_malmo_initialized = True
def __init__(self, env_config): # Static Parameters self.size = 50 self.reward_density = .1 self.penalty_density = .02 self.obs_size = 5 # todo: 100 steps self.max_episode_steps = 100 # todo: 10 frequency self.log_frequency = 10 self.action_dict = { 0: 'move 1', # Move one block forward 1: 'turn 1', # Turn 90 degrees to the right 2: 'turn -1', # Turn 90 degrees to the left 3: 'attack 1' # Destroy block } # Rllib Parameters self.action_space = Box(low=-1, high=1, shape=(3, )) # self.action_space = Discrete(len(self.action_dict)) self.observation_space = Box(0, 1, shape=(2 * self.obs_size * self.obs_size, ), dtype=np.float32) # Malmo Parameters self.agent_host = MalmoPython.AgentHost() try: self.agent_host.parse(sys.argv) except RuntimeError as e: print('ERROR:', e) print(self.agent_host.getUsage()) exit(1) # DiamondCollector Parameters self.obs = None self.allow_break_action = False self.episode_step = 0 self.episode_return = 0 self.returns = [] self.steps = [] self.pbar = tqdm(total=50000)
def __init__(self, env_config): # Static Parameters self.size = 50 self.reward_density = .1 self.penalty_density = .02 self.obs_size = 4 #changed from 5 self.max_episode_steps = 125 self.log_frequency = 10 self.action_dict = { 0: 'move 1', # Move one block forward 1: 'turn 1', # Turn 90 degrees to the right 2: 'turn -1', # Turn 90 degrees to the left 3: 'attack 1' # Destroy block } # Rllib Parameters self.action_space = Box( low=-1.0, high=1.0, shape=(2, ), dtype=np.float32) #CHANGED FROM DISCRETE TO BOX self.observation_space = Box( -1000, 1000, shape=(self.obs_size, ), dtype=np.float32) # Not sure what to do here # Malmo Parameters self.agent_host = MalmoPython.AgentHost() try: self.agent_host.parse(sys.argv) except RuntimeError as e: print('ERROR:', e) print(self.agent_host.getUsage()) exit(1) # Agent Parameters self.obs = np.zeros(self.obs_size) self.last_obs = np.zeros(self.obs_size) self.zstart = 81.5 self.zend = 96.5 self.xleft = 662.5 self.xright = 648.5 self.episode_step = 0 self.episode_return = 0 self.returns = [] self.steps = []
def __init__(self, env_config): # Static Parameters self.penalty_density = .02 self.obs_size = 5 self.log_frequency = 10 self.max_episode_steps = 400 self.action_dict = { 0: 'move 0', # Stop 1: 'strafe 1', # Move one block left 2: 'strafe -1', # Move one block right 3: 'attack 1', } # Rllib Parameters self.action_space = Discrete(len(self.action_dict)) self.observation_space = Box(0, 1, shape=(2 * self.obs_size * self.obs_size, ), dtype=np.float32) # Malmo Parameters self.agent_host = MalmoPython.AgentHost() try: self.agent_host.parse(sys.argv) except RuntimeError as e: print('ERROR:', e) print(self.agent_host.getUsage()) exit(1) # CallMePro Parameters self.obs = None self.face_brick_move = False self.face_gold_move = False self.face_diamond_move = False self.face_stone_move = False self.face_diamondblock_move = False self.face_coal_move = False self.episode_step = 0 self.episode_return = 0 self.returns = [] self.steps = []
def __init__(self, env_config): # Static Parameters self.size = 50 self.reward_density = .1 self.penalty_density = .02 self.obs_size = 3 self.depth = 30 self.max_episode_steps = 30 self.log_frequency = 10 self.num_episode = 0 self.xz_coordinate = 2.5, 2.5 self.action_dict = { 0: 'move 1', # Move one block forward 1: 'strafe -1', # Moves left 2: 'strafe 1', # Moves right 3: 'move -1', # Moves back 4: 'move 0' # Moves 0 } self.landInWater = False # Rllib Parameters self.action_space = Discrete(len(self.action_dict)) self.observation_space = Box( 0, 1, shape=(np.prod([self.depth, self.obs_size, self.obs_size]), ), dtype=np.int32) # Malmo Parameters self.agent_host = MalmoPython.AgentHost() try: self.agent_host.parse(sys.argv) except RuntimeError as e: print('ERROR:', e) print(self.agent_host.getUsage()) exit(1) # DiamondCollector Parameters self.obs = None self.episode_step = 0 self.episode_return = 0 self.returns = [] self.steps = []
def _start(host: OntoCraftAgentHost, mission: MalmoPython.MissionSpec, client_pool: MalmoPython.ClientPool = None, role: int = 0): record = MalmoPython.MissionRecordSpec() max_retries = 3 for retry in range(max_retries): try: if client_pool is None: host.startMission(mission, record) else: host.startMission(mission, client_pool, record, role, "") break except RuntimeError as e: if retry == max_retries - 1: print("Error starting mission:", e) exit(1) else: time.sleep(2.5)
def __init__(self, env_config): # Static Parameters self.size = 50 self.reward_density = .1 self.penalty_density = .02 self.obs_size = 5 self.max_episode_steps = 100 self.log_frequency = 10 self.action_dict = { 0: 'move 1', # Move one block forward 1: 'strafe -1', # strafe to the left 2: 'strafe 1', # strafe to the right #3: 'turn -1', # Turn 90 degrees to the left } # Rllib Parameters self.action_space = Discrete(len(self.action_dict)) #BACK TO DISCRETE FOR FINAL REPORT #self.observation_space = Box(-1000, 1000, shape=(self.obs_size,), dtype=np.float32) # Not sure what to do here self.observation_space = Box(0, 1, shape=(self.obs_size * self.obs_size, ), dtype=np.float32) # Malmo Parameters self.agent_host = MalmoPython.AgentHost() try: self.agent_host.parse( sys.argv ) except RuntimeError as e: print('ERROR:', e) print(self.agent_host.getUsage()) exit(1) # Agent Parameters self.obs = np.zeros(self.obs_size) self.last_obs = np.zeros(self.obs_size) self.zstart = 82.5 self.zend = 96.5 self.xstart = 655.5 self.xend = 648.5 self.episode_step = 0 self.episode_return = 0 self.returns = [] self.steps = []
def _retry_start_mission(self): self.my_mission_record = MalmoPython.MissionRecordSpec() # self.my_mission_record = malmoutils.get_default_recording_object(self.agent_host, # "Mission_" + str(len(self.scores)-1)) for retry in range(self.max_retries): try: # Attempt to start the mission: self.my_mission.forceWorldReset( ) # force world to reset for each iteration self.agent_host.startMission(self.my_mission, self.my_client_pool, self.my_mission_record, 0, "ZombieKiller") break except RuntimeError as e: if retry == self.max_retries - 1: print("Error starting mission", e) print("Is the game running?") exit(1) else: time.sleep(2) self._get_valid_worldstate()