コード例 #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
コード例 #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
コード例 #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
コード例 #4
0
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
コード例 #5
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
            mc.sendCommand('craft iron_ingot')
            mc.sendCommand('craft iron_ingot')
            mc.sendCommand('craft iron_pickaxe')
            break
        pickaxe = mc.filterInventoryItem('stone_pickaxe')
        if mc.isInventoryAvailable() and pickaxe == []:
            break


video_producer = mb.VideoProducer(width=320, height=240)
agent_handler = mb.AgentHandlers(video_producer=video_producer)
agent_section = mb.AgentSection(agenthandlers=agent_handler)
miss = mb.MissionXML(agentSections=[agent_section])
miss.setWorld(
    mb.flatworld(
        "3;7,25*1,3*3,2;1;stronghold,biome_1,village,decoration,dungeon,lake,mineshaft,lava_lake",
        forceReset="true"))
miss.serverSection.initial_conditions.allowedmobs = "Pig Sheep Cow Chicken Ozelot Rabbit Villager"
mc = MalmoConnector(miss)
mc.safeStart()
# fixing bug with falling through while reconnecting
sleep(2)
mc.sendCommand("jump 1")
sleep(0.1)
mc.sendCommand("jump 0")

lookDir(mc, 0, 0)

getSticks(mc)

mc.sendCommand('craft wooden_pickaxe')
コード例 #7
0
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()