コード例 #1
0
 def __init__(self,
              game_name,
              options,
              word_list,
              opengl_init=True,
              show_frame=False):
     """
     options: see test_xworld3d.py in XWorld for an example of options
     word_list: a list of words used in the language part
     """
     assert game_name == "xworld" or game_name == "xworld3d", \
         "Incorrect name provided!"
     options["x3_opengl_init"] = opengl_init
     self.env = Simulator.create(game_name, options)
     self.show_frame = show_frame
     self.dict_id2w = {id: word for id, word in enumerate(word_list)}
     self.dict_w2id = {v: k for k, v in self.dict_id2w.iteritems()}
     self.height, self.width, self.channels, self.contexts = \
                                     self.env.get_screen_out_dimensions()
     self.num_actions = self.env.get_num_actions()
     self.input_key1 = "screen"
     self.input_key2 = "sentence"
     self.input_key3 = "prev_action"
     self.action_key1 = "action"
     self.action_key2 = "pred_sentence"
     self.reward_key = "reward"
コード例 #2
0
ファイル: xworld.py プロジェクト: yuanpeng16/flare
 def __init__(self, game_name, options=None, word_list=None):
     """
     options: see test_xworld3d.py in XWorld for an example of options
     word_list: a list of words used in the language part
     """
     self.env = Simulator.create(game_name, options)
     self.dict_id2w = {id: word for id, word in enumerate(word_list)}
     self.dict_w2id = {v: k for k, v in self.dict_id2w.iteritems()}
     self.height, self.width, self.channels = \
                                     self.env.get_screen_out_dimensions()
コード例 #3
0
    return action


if __name__ == "__main__":

    print "Example: Language Learning in 3D"
    options = {
        "x3_conf": "../../confs/dialog3d.json",
        "context": 1,
        "pause_screen": True,
        "x3_training_img_width": 64,
        "x3_training_img_height": 64,
        "x3_big_screen": True,
        "x3_task_mode": "arxiv_interactive"
    }
    x3d = Simulator.create("xworld3d", options)
    x3d.reset_game()

    num_actions = x3d.get_num_actions()

    reward = 0
    for i in range(1000):
        game_over_str = x3d.game_over()
        states = x3d.get_state()
        action = compute_speak_action(states, num_actions, True)
        r = x3d.take_actions({"pred_sentence": action}, 1, True)

        if game_over_str != "alive":
            print "game over because of ", game_over_str
            x3d.reset_game()
            continue
コード例 #4
0
ファイル: test_xworld.py プロジェクト: ziyuli/XWorld
    return action


if __name__ == "__main__":

    print "Example 1: Navigation with language instruction (with curriculum)"
    options = {
        "xwd_conf_path": "../../confs/walls.json",
        "curriculum": 0.1,
        "task_mode": "lang_acquisition",
        "context": 1,
        "pause_screen": True,
        "task_groups_exclusive": False,
        "visible_radius": 0
    }
    xworld = Simulator.create("xworld", options)
    xworld.reset_game()

    num_actions = xworld.get_num_actions()

    reward = 0
    for i in range(100):
        game_over_str = xworld.game_over()
        if game_over_str != "alive":
            print "game over because of ", game_over_str
            xworld.reset_game()
            continue

        states = xworld.get_state()
        action = compute_action(states, num_actions)
        r = xworld.take_actions({
コード例 #5
0
#!/usr/bin/python

from py_simulator import Simulator
from random import randint
import os

if __name__ == "__main__":
    options = {
        "runfiles_path": os.environ["DEEPMIND_RUNFILES"],
        "level_script": "./test_map.lua",
        "context": 1
    }
    dm = Simulator.create("deepmind_lab", options)

    num_actions = dm.get_num_actions()
    act_rep = options["context"]

    reward = 0
    for i in range(100):
        game_over_str = dm.game_over()
        if game_over_str != "alive" and game_over_str != "lost_life":
            print "game over because of ", game_over_str
            dm.reset_game()
            continue

        dm.show_screen()

        states = dm.get_state()
        action = randint(0, num_actions - 1)
        r = dm.take_actions({"action": action}, act_rep)
        print r
コード例 #6
0
#!/usr/bin/python

from py_simulator import Simulator
from random import randint

if __name__ == "__main__":
    options = {
        "ale_rom": "/tmp/breakout.bin",
        "pause_screen": True,
        "context": 4
    }
    atari = Simulator.create("atari", options)

    num_actions = atari.get_num_actions()
    act_rep = options["context"]

    reward = 0
    print("\033[93mUse show_screen() to see the game. " \
          + "However, X server must be used; otherwise the code crashes\033[0m")
    for i in range(100):
        game_over_str = atari.game_over()
        if game_over_str != "alive" and game_over_str != "lost_life":
            print "game over because of ", game_over_str
            atari.reset_game()
            continue

#        atari.show_screen()

        states = atari.get_state()
        action = randint(0, num_actions - 1)
        r = atari.take_actions({"action": action}, act_rep)
コード例 #7
0
if __name__ == "__main__":
    options = {
        "pause_screen": False,
        "window_width": 480,
        "window_height": 480,
        "track_type": "straight",
        "track_width": 20.0,
        "track_length": 100.0,
        "track_radius": 30.0,
        "race_full_manouver": False,
        "random": False,
        "difficulty": "easy",
        "context": 1
    }
    sr = Simulator.create("simple_race", options)
    sr.reset_game()

    num_actions = sr.get_num_actions()
    act_rep = options["context"]

    reward = 0
    for i in range(100):
        game_over_str = sr.game_over()
        states = sr.get_state()
        action = randint(0, num_actions - 1)
        r = sr.take_actions({"action": action}, act_rep, False)

        if game_over_str != "alive":
            print "game over because of ", game_over_str
            sr.reset_game()
コード例 #8
0

if __name__ == "__main__":

    client = launch_client()

    options = {
        "conf_path": "./demo_conf.xml",
        "mission": "demo",
        "client_ip": "127.0.0.1",
        "client_port": client_port,
        "ms_per_tick": 10,
        "context": 1,
        "pause_screen": False
    }
    minecraft = Simulator.create("minecraft", options)

    num_actions = minecraft.get_num_actions()

    reward = 0
    for i in range(100):
        game_over_str = minecraft.game_over()
        if game_over_str != "alive":
            print "game over because of ", game_over_str
            minecraft.reset_game()
            continue

        minecraft.show_screen()

        minecraft.get_state()
        action = randint(0, num_actions - 1)
コード例 #9
0
#!/usr/bin/python

from py_simulator import Simulator
from random import randint

if __name__ == "__main__":
    options = {"array_size": 7}
    simple = Simulator.create("simple_game", options)
    simple.reset_game()

    num_actions = simple.get_num_actions()

    reward = 0
    for i in range(100):
        game_over_str = simple.game_over()
        states = simple.get_state()
        action = randint(0, num_actions - 1)
        r = simple.take_actions({"action": action}, 1, False)

        if game_over_str != "alive":
            print "game over because of ", game_over_str
            simple.reset_game()
            continue

        print r
        reward += r

    print "total reward ", reward