def init_mission(cls, i, mc, start_x=None, start_y=None): miss = mb.MissionXML() video_producer = mb.VideoProducer(width=320 * 4, height=240 * 4, want_depth=cls.want_depth) obs = mb.Observations() obs = mb.Observations() obs.gridNear = [[-1, 1], [-2, 1], [-1, 1]] agent_handlers = mb.AgentHandlers(observations=obs, all_str=mission_ending) agent_handlers = mb.AgentHandlers(observations=obs, all_str=mission_ending, video_producer=video_producer) # a tree is at -18, 15 if start_x is None: center_x = -18 center_y = 15 start_x = center_x + random.choice(numpy.arange(-329, 329)) start_y = center_y + random.choice(numpy.arange(-329, 329)) logging.info('starting at ({0}, {1})'.format(start_x, start_y)) miss = mb.MissionXML(agentSections=[ mb.AgentSection( name='Cristina', agenthandlers=agent_handlers, # depth agentstart=mb.AgentStart([start_x, 30.0, start_y, 1])) ]) miss.setWorld( mb.flatworld( "3;7,25*1,3*3,2;1;stronghold,biome_1,village,decoration,dungeon,lake,mineshaft,lava_lake", seed='43', forceReset="false")) miss.serverSection.initial_conditions.allowedmobs = "Pig Sheep Cow Chicken Ozelot Rabbit Villager" # uncomment to disable passage of time: miss.serverSection.initial_conditions.time_pass = '******' miss.serverSection.initial_conditions.time_start = "1000" if mc is None: mc = MalmoConnector(miss) else: mc.setMissionXML(miss) return mc
def start_mission(): miss = mb.MissionXML() colourmap_producer = mb.ColourMapProducer(width=WIDTH, height=HEIGHT) video_producer = mb.VideoProducer(width=WIDTH, height=HEIGHT, want_depth=False) colourmap_producer = None obs = mb.Observations() agent_handlers = mb.AgentHandlers(observations=obs) agent_handlers = mb.AgentHandlers(observations=obs, colourmap_producer=colourmap_producer, video_producer=video_producer) miss = mb.MissionXML(agentSections=[mb.AgentSection(name='Cristina', agenthandlers=agent_handlers)]) # seed 28 - with a see world = mb.defaultworld( seed='28', forceReset="false") miss.setWorld(world) miss.serverSection.initial_conditions.allowedmobs = "Pig Sheep Cow Chicken Ozelot Rabbit Villager" # disable passage of time: miss.serverSection.initial_conditions.time_pass = '******' miss.serverSection.initial_conditions.time_start = "1000" mc = MalmoConnector(miss) obs1 = RobustObserverWithCallbacks(mc) return mc, obs1
def init_mission(cls, i, mc): miss = mb.MissionXML() video_producer = mb.VideoProducer(width=320, height=240, want_depth=cls.want_depth) obs = mb.Observations() agent_handlers = mb.AgentHandlers(observations=obs, all_str=mission_ending, video_producer=video_producer) # a tree is at -18, 15 # stay between tree and pond center_x = -23.5 center_y = 12.5 start_x = center_x + random.choice(numpy.arange(-2, 2)) start_y = center_y + random.choice(numpy.arange(-5, 5)) logging.info('starting at ({0}, {1})'.format(start_x, start_y)) miss = mb.MissionXML(agentSections=[mb.AgentSection(name='Cristina', agenthandlers=agent_handlers, # depth agentstart=mb.AgentStart([start_x, 30.0, start_y, 1]))]) miss.setWorld(mb.flatworld("3;7,25*1,3*3,2;1;stronghold,biome_1,village,decoration,dungeon,lake,mineshaft,lava_lake", seed='43', forceReset="false")) miss.serverSection.initial_conditions.allowedmobs = "Pig Sheep Cow Chicken Ozelot Rabbit Villager" if mc is None: mc = MalmoConnector(miss) else: mc.setMissionXML(miss) return mc
def init_mission(mc, start_x=None, start_y=None): want_depth = False video_producer = mb.VideoProducer(width=320 * 4, height=240 * 4, want_depth=want_depth) obs = mb.Observations() obs.gridNear = [[-1, 1], [-2, 1], [-1, 1]] agent_handlers = mb.AgentHandlers(observations=obs, video_producer=video_producer) print('starting at ({0}, {1})'.format(start_x, start_y)) #miss = mb.MissionXML(namespace="ProjectMalmo.microsoft.com", miss = mb.MissionXML(agentSections=[ mb.AgentSection( name='Cristina', agenthandlers=agent_handlers, # depth agentstart=mb.AgentStart([start_x, 74.0, start_y, 1])) ]) flat_json = { "biome": "minecraft:plains", "layers": [{ "block": "minecraft:diamond_block", "height": 1 }], "structures": { "structures": { "village": {} } } } flat_param = "3;7,25*1,3*3,2;1;stronghold,biome_1,village,decoration,dungeon,lake,mineshaft,lava_lake" flat_json = json.dumps(flat_json).replace('"', "%ESC") world = mb.defaultworld(seed='5', forceReuse="true", forceReset="false") flat_world = mb.flatworld( flat_json, seed='43', ) miss.setWorld(world) miss.serverSection.initial_conditions.allowedmobs = "Pig Sheep Cow Chicken Ozelot Rabbit Villager" # uncomment to disable passage of time: miss.serverSection.initial_conditions.time_pass = '******' miss.serverSection.initial_conditions.time_start = "1000" if mc is None: mc = MalmoConnector(miss) obs = RobustObserver(mc) else: mc.setMissionXML(miss) return mc, obs
def start_mission(): miss = mb.MissionXML() colourmap_producer = mb.ColourMapProducer(width=WIDTH, height=HEIGHT) video_producer = mb.VideoProducer(width=WIDTH, height=HEIGHT, want_depth=False) obs = mb.Observations() agent_handlers = mb.AgentHandlers(observations=obs) agent_handlers = mb.AgentHandlers(observations=obs, colourmap_producer=colourmap_producer, video_producer=video_producer) miss = mb.MissionXML(agentSections=[ mb.AgentSection( name='Cristina', agenthandlers=agent_handlers, ) ]) # agenthandlers=agent_handlers,)], namespace='ProjectMalmo.microsoft.com') # good point seed='2', x=-90, y=71, z=375 # good point seed='3', x=6, y=71, z=350 # good point seed='31' world = mb.defaultworld(seed='5', forceReset="true") world1 = mb.flatworld( "3;7,25*1,3*3,2;1;stronghold,biome_1,village,decoration,dungeon,lake,mineshaft,lava_lake", seed='43', forceReset="false") miss.setWorld(world) miss.serverSection.initial_conditions.allowedmobs = "Pig Sheep Cow Chicken Ozelot Rabbit Villager" # uncomment to disable passage of time: miss.serverSection.initial_conditions.time_pass = '******' miss.serverSection.initial_conditions.time_start = "1000" mc = MalmoConnector(miss) obs1 = RobustObserver(mc) return mc, obs1
def init_mission(i, mc): sp = '' # train on simple environment first if i < 200: p = random.choice([x for x in range(2, 8)]) else: p = random.choice([-2, -1] + [x for x in range(0, 12)]) if random.choice([True, False]): sp = spiral jump_block = -3 jump_block1 = random.choice(list(range(2, 11))) logging.debug('%i, %i', jump_block, jump_block1) current_xml = dec_xml.format( modify_blocks.format(p, jump_block, jump_block1), sp) handlers = mb.ServerHandlers( mb.flatworld("3;7,220*1,5*3,2;3;,biome_1"), alldecorators_xml=current_xml, bQuitAnyAgent=True) video_producer = mb.VideoProducer(width=320, height=240) obs = mb.Observations() obs.gridNear = [[-1, 1], [-2, 2], [-1, 1]] agent_handlers = mb.AgentHandlers(observations=obs, all_str=mission_ending) miss = mb.MissionXML(serverSection=mb.ServerSection(handlers), agentSections=[ mb.AgentSection(name='Cristina', agenthandlers=agent_handlers, agentstart=mb.AgentStart( [4.5, 46.0, 1.5, 30])) ]) if mc is None: mc = MalmoConnector(miss) else: mc.setMissionXML(miss) return mc
from tagilmo.utils.malmo_wrapper import MalmoConnector import tagilmo.utils.mission_builder as mb miss = mb.MissionXML() # just an empty flat world for testing miss.setWorld(mb.flatworld("")) miss.addAgent() # no observations in this example miss.setObservations(mb.Observations(bAll=False)) # we typically don't need this for real Minecraft agents, but this example just checks the connection to Minecraft miss.setTimeLimit(5000) mc = MalmoConnector(miss) # Note that we need two instances of Minecraft running mc.safeStart()
import tagilmo.utils.mission_builder as mb # we can specify separate parameters through nested constructors miss = mb.MissionXML(serverSection=mb.ServerSection( initial_conditions=mb.ServerInitialConditions(weather_string="rain"))) # we can use a nicer API, though miss.setWorld(mb.flatworld("")) miss.addAgent() miss.setObservations( mb.Observations(bAll=False, bRay=True, bFullStats=True, bHotBar=True)) # we can also set some parameters this way if they are lacking API miss.agentSections[0].agentstart.inventory = ["diamond_pickaxe", "wooden_axe"] print(miss.xml()) print("================\n") print(miss.getAgentNames())