Example #1
0
    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
Example #2
0
def init_mission(mc,
                 start_x=None,
                 start_y=None,
                 use_video=False,
                 use_colormap=False):
    miss = mb.MissionXML()
    colourmap_producer = None
    if use_colormap:
        colourmap_producer = mb.ColourMapProducer(width=320 * 4,
                                                  height=240 * 4)
    video_producer = None
    if use_video:
        video_producer = mb.VideoProducer(width=320 * 4,
                                          height=240 * 4,
                                          want_depth=False)

    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,
                                      colourmap_producer=colourmap_producer,
                                      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]))
    ])
    world = 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"

    if mc is None:
        mc = MalmoConnector(miss)
    else:
        mc.setMissionXML(miss)
    obs1 = RobustObserver(mc)
    return mc, obs1
Example #3
0
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
Example #4
0
    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