def __init__(self): #init parent class -> environment interface env.Env.__init__(self) #dimensions 1x10x10 self.width = 20 self.height = 16 self.depth = 1 #init state, as 1D vector (tensor with size depth*height*width) self.observation_init() #4 actions for movements self.actions_count = 2 self.player_size = 5 self.reset() self.gui = gl_gui.GLVisualisation() self.size_ratio = self.width / self.height self.player_0_score = 0 self.player_1_score = 0
def __init__(self): #init parent class -> environment interface env.Env.__init__(self) #dimensions 1x1x2 self.width = 1 self.height = 1 self.depth = 2 self.time = 1 #init state, as 1D vector (tensor with size depth*height*width) self.observation_init() #4 actions for movements self.actions_count = 3 self.velocity_min = -0.07 self.velocity_max = 0.07 self.position_min = -1.2 self.position_max = 0.6001 self.move_old = 0 self.move_to_top = 0 self.reset() self.games_count = 0 self.gui = gl_gui.GLVisualisation()
def __init__(self, size=16): #init parent class -> environment interface env.Env.__init__(self) self.width = size self.height = size self.depth = 1 self.time = 1 #init state, as 1D vector (tensor with size depth*height*width) self.observation_init() #4 actions for movements self.actions_count = 3 self.player_size = 3 self.player_0_points = 0.0 self.player_1_points = 0.0 self.game_idx = 0 self.reset() self.gui = gl_gui.GLVisualisation() self.size_ratio = self.width / self.height
def __init__(self, name): libs_env.Env.__init__(self) self.gym_env = gym.make(name) self.gym_env.reset() self.width_scale = 3 self.height_scale = 2 self.raw_width = numpy.shape(self.gym_env.observation_space)[0] self.raw_height = numpy.shape(self.gym_env.observation_space)[1] self.raw_depth = numpy.shape(self.gym_env.observation_space)[2] self.time_steps = 4 self.colors_count = 3 self.width = 96 self.height = 96 self.depth = self.colors_count * self.time_steps self.actions_count = self.gym_env.action_space.n size = self.colors_count * self.height * self.width self.state_vec_frame_0 = numpy.zeros(size) self.state_vec_frame_1 = numpy.zeros(size) self.state_vec_frame_2 = numpy.zeros(size) self.state_vec_frame_3 = numpy.zeros(size) self.observation_init() self.gui = libs_gl_gui.GLVisualisation() self.game_number = 0
def __init__(self): #init parent class -> environment interface libs_env.Env.__init__(self) #dimensions self.width = 16 self.height = 20 self.depth = 3 #init state, as 1D vector (tensor with size depth*height*width) self.observation = numpy.zeros(self.get_size()) #3 actions for movements self.actions_count = 3 #player paddle size self.player_size = 3 #init game self.reset() self.__update_state() self.gui = libs_gl_gui.GLVisualisation() self.size_ratio = self.width / self.height self.moves_old = 0 self.game_idx = 0 self.moves_to_win = 1000
def __init__(self): env.Env.__init__(self) self.width = 1 self.height = 1 self.depth = 2 self.actions_count = 2 self.observation_init() self.reset() self.gui = gl_gui.GLVisualisation()
def __init__(self): env.Env.__init__(self) self.width = 1 self.height = 1 self.depth = 2 self.actions_count = 2 self.observation = numpy.zeros(self.get_size()) self.reset() self.gui = gl_gui.GLVisualisation()
def __init__(self): libs.libs_env.env.Env.__init__(self) self.game = gym_super_mario_bros.make('SuperMarioBros-v0') self.game = JoypadSpace(self.game, SIMPLE_MOVEMENT) #self.game.set_sound_enabled(True) self.game.reset() state, reward, done, info = self.game.step(0) self.raw_state_shape = numpy.shape(state) self.reset() self.actions_count = 7 self.time_steps = 4 self.colors_count = 3 self.width_scale = 4 self.height_scale = 3 self.width_scaled = self.raw_state_shape[1] // self.width_scale self.height_scaled = self.raw_state_shape[0] // self.height_scale self.width = self.width_scaled self.height = self.height_scaled self.depth = self.colors_count * self.time_steps self.observation_init() print("raw state shape ", self.raw_state_shape[1], self.raw_state_shape[0]) print("scaling factor ", self.width_scale, self.height_scale) print("rescaled state ", self.width_scaled, self.height_scaled) print("state ", self.width, self.height) self.set_no_terminal_state() self.game_idx = 0 size = self.colors_count * self.height * self.width self.state_vec_frame_0 = numpy.zeros(size) self.state_vec_frame_1 = numpy.zeros(size) self.state_vec_frame_2 = numpy.zeros(size) self.state_vec_frame_3 = numpy.zeros(size) self.size_ratio = self.width / self.height self.gui = libs_gl_gui.GLVisualisation() self.window_name = "super mario"
def __init__(self, seed=0, convolution_mode=False): #init parent class -> environment interface libs_env.Env.__init__(self) self.map_size = 64 prime = 60013 if convolution_mode: self.features_count = 4 + (seed * prime) % 8 self.state_size = 8 #state planar size 8x8 else: self.features_count = 8 + (seed * prime) % 24 self.state_size = 1 #state planar size 1x1 #state dimensions self.width = self.state_size self.height = self.state_size self.depth = self.features_count #init state, as 1D vector (tensor with size depth*height*width) self.observation = numpy.zeros(self.get_size()) #4 actions for movements self.actions_count = 4 #random permutate actions - to prevent hardcoding bots self.actions_ids = numpy.random.permutation(self.actions_count) self.agent_position_x = self.map_size // 2 self.agent_position_y = self.map_size // 2 #create feature maps self.maps = [] for i in range(0, self.features_count): init_seed_x = (seed + i) * 61057 init_seed_y = (seed + i) * 62141 map = libs_black_box_map.BlackBoxMap(self.map_size, self.map_size, init_seed_x, init_seed_y) self.maps.append(map) #compute reward by averaging and thresholding feature maps self.rewards = self.__make_rewards() self.fields_occupation = numpy.zeros((self.map_size, self.map_size)) #gui for visualisation self.gui = gl_gui.GLVisualisation() self.time = 0.0
def __init__(self): env.Env.__init__(self) self.width = 4 self.height = 4 self.depth = 1 self.time = 1 self.actions_count = 4 self.observation_init() self.reset() self.gui = gl_gui.GLVisualisation() self.max_value = 0.0 self.max_score_log = rysy.Log("2048_max_score.log")
def __init__(self): libs_env.Env.__init__(self) self.size = 16 self.max_depth = 16 self.width = self.size self.height = self.size self.depth = 2 self.observation_init() self.actions_count = 2 self.reset() self.angle = 0.0 self.gui = libs_gl_gui.GLVisualisation()
def __init__(self): #init parent class -> environment interface env.Env.__init__(self) #dimensions 10x9x1 self.width = 9 self.height = 10 self.depth = 1 self.observation_init() self.actions_count = 6 self.moves_to_win = 200 self.game_moves = 0.0 self.reset() self.gui = gl_gui.GLVisualisation()
def __init__(self, size=32): #init parent class -> environment interface libs_env.Env.__init__(self) self.time_steps = 4 self.colors_count = 3 #dimensions self.width = size self.height = size self.depth = self.colors_count self.time = self.time_steps #init state, as 1D vector (tensor with size depth*height*width) self.observation_init() self.actions_count = 2 self.game_screen = numpy.zeros( (self.colors_count, self.height, self.width)) size = self.colors_count * self.height * self.width self.state_vec_frame_0 = numpy.zeros(size) self.state_vec_frame_1 = numpy.zeros(size) self.state_vec_frame_2 = numpy.zeros(size) self.state_vec_frame_3 = numpy.zeros(size) self.iterations = 0 self.game_idx = 0 self.size_ratio = self.width / self.height self.gui = libs_gl_gui.GLVisualisation() self.window_name = "game interface" self.update_state()
def __init__(self): #init parent class -> EnvCliff libs_env_cliff.EnvCliff.__init__(self) self.gui = libs_gl_gui.GLVisualisation()
def __init__(self, mode="basic"): libs.libs_env.env.Env.__init__(self) self.game = DoomGame() self.mode = mode self.positive_reward_factor = 1.0 self.negative_reward_factor = 1.0 if self.mode == "basic": self.positive_reward_factor = 0.1 self.negative_reward_factor = 0.1 self.game.load_config("scenarios/basic.cfg") left = [1, 0, 0] right = [0, 1, 0] attack = [0, 0, 1] self.actions = [left, right, attack] if self.mode == "health_gathering": self.positive_reward_factor = 0.02 self.negative_reward_factor = 0.1 self.game.load_config("scenarios/health_gathering.cfg") turn_left = [1, 0, 0] turn_right = [0, 1, 0] move_forward = [0, 0, 1] self.actions = [turn_left, turn_right, move_forward] if self.mode == "defend_the_center": self.positive_reward_factor = 5.0 self.negative_reward_factor = 10.0 self.game.load_config("scenarios/defend_the_center.cfg") turn_left = [1, 0, 0] turn_right = [0, 1, 0] attack = [0, 0, 1] self.actions = [turn_left, turn_right, attack] if self.mode == "defend_the_line": self.positive_reward_factor = 1.0 self.negative_reward_factor = 10.0 self.game.load_config("scenarios/defend_the_line.cfg") left = [1, 0, 0] right = [0, 1, 0] attack = [0, 0, 1] self.actions = [left, right, attack] if self.mode == "deadly_corridor": self.positive_reward_factor = 1.0 self.negative_reward_factor = 0.5 self.game.load_config("scenarios/deadly_corridor.cfg") move_left = [1, 0, 0, 0, 0, 0, 0] move_right = [0, 1, 0, 0, 0, 0, 0] attack = [0, 0, 1, 0, 0, 0, 0] move_forward = [0, 0, 0, 1, 0, 0, 0] move_backward = [0, 0, 0, 0, 1, 0, 0] turn_left = [0, 0, 0, 0, 0, 1, 0] turn_right = [0, 0, 0, 0, 0, 0, 1] self.actions = [ move_left, move_right, attack, move_forward, move_backward, turn_left, turn_right ] if self.mode == "multi": self.positive_reward_factor = 0.1 self.negative_reward_factor = 0.1 self.game.load_config("scenarios/multi.cfg") turn_left = [1, 0, 0, 0, 0, 0, 0, 0, 0] turn_right = [0, 1, 0, 0, 0, 0, 0, 0, 0] attack = [0, 0, 1, 0, 0, 0, 0, 0, 0] move_right = [0, 0, 0, 1, 0, 0, 0, 0, 0] move_left = [0, 0, 0, 0, 1, 0, 0, 0, 0] move_forward = [0, 0, 0, 0, 0, 1, 0, 0, 0] move_backward = [0, 0, 0, 0, 0, 0, 1, 0, 0] turn_left_right_delta = [0, 0, 0, 0, 0, 0, 0, 1, 0] move_left_right_delta = [0, 0, 0, 0, 0, 0, 0, 0, 1] self.actions = [ turn_left, turn_right, attack, move_right, move_left, move_forward, move_backward, turn_left_right_delta, move_left_right_delta ] if self.mode == "deathmatch": self.positive_reward_factor = 1.0 self.negative_reward_factor = 1.0 self.game.load_config("scenarios/deathmatch.cfg") attack = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] strafe = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] move_right = [ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] move_left = [ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] move_forward = [ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] move_backward = [ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] turn_left = [ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] turn_right = [ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] select_weapon_1 = [ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] select_weapon_2 = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] select_weapon_3 = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 ] select_weapon_4 = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ] select_weapon_5 = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ] select_weapon_6 = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 ] select_next_weapon = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ] select_prev_weapon = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ] look_up_down_delta = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ] turn_left_right_delta = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ] move_left_right_delta = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ] self.actions = [ attack, strafe, move_right, move_left, move_forward, move_backward, turn_left, turn_right, select_weapon_1, select_weapon_2, select_weapon_3, select_weapon_4, select_weapon_5, select_weapon_6, select_next_weapon, select_prev_weapon, look_up_down_delta, turn_left_right_delta, move_left_right_delta ] #self.game.add_available_game_variable(GameVariable.KILLCOUNT) #self.game.add_available_game_variable(GameVariable.DEATHCOUNT) #self.game.set_sound_enabled(True) self.game.init() self.game.new_episode() self.reset() self.raw_state_shape = self.game.get_state().screen_buffer.shape buffer_size = 64 self.time_steps = 8 self.colors_count = 3 self.width = 80 self.height = 80 self.depth = self.colors_count * self.time_steps self.time = 1 self.width_scale = 5 self.height_scale = 5 self.width_scaled = self.raw_state_shape[2] // self.width_scale self.height_scaled = self.raw_state_shape[1] // self.height_scale self.width_crop = self.raw_state_shape[ 2] // self.width_scale - self.width self.height_crop = self.raw_state_shape[ 1] // self.height_scale - self.height print("raw state shape ", self.raw_state_shape[2], self.raw_state_shape[1]) print("scaling factor ", self.width_scale, self.height_scale) print("rescaled state ", self.width_scaled, self.height_scaled) print("crop ", self.width_crop, self.height_crop) self.actions_count = len(self.actions) self.observation_init() self.game_idx = 0 self.frame_buffer = frame_buffer.FrameBuffer(self.width, self.height, self.colors_count, buffer_size) self.size_ratio = self.width / self.height self.gui = libs_gl_gui.GLVisualisation() self.window_name = "DOOM - " + self.mode