def __init__(self, opts): super(Game, self).__init__(opts) self.nblocks = int(opts.get('nblocks') or 0) self.nwater = int(opts.get('nwater') or 0) #these are decoys: self.nswitches = opts.get('nswitches') or 1 self.ncolors = opts.get('ncolors') or 3 info = gi.build_info_attr('go goal0') self.build_add_item(info) gi.build_big_random_wall(self) b = random.choice(self.items_bytype['block']) loc = b.attr['loc'] self.remove_item(b) s = gi.PushableBlock({'loc': loc}) self.add_prebuilt_item(s) gi.add_random_cycle_switches(self, self.nswitches, self.ncolors) # always goal0. fixme? gi.add_goal(self, self.sample_reachable_loc(ensure_empty=True), 0) gi.add_standard_items(self) self.agent = self.items_bytype['agent'][0] self.agent.replace_action('push_up', standard_grid_actions.push_up) self.agent.replace_action('push_down', standard_grid_actions.push_down) self.agent.replace_action('push_left', standard_grid_actions.push_left) self.agent.replace_action('push_right', standard_grid_actions.push_right) self.finished = False
def __init__(self, opts): super(Game, self).__init__(opts) self.nblocks = int(opts.get('nblocks') or 0) self.nwater = int(opts.get('nwater') or 0) #these are decoys: self.nswitches = opts.get('nswitches') or 0 self.ncolors = opts.get('ncolors') or 3 self.ngoals = opts['ngoals'] self.ngoals_active = min(opts['ngoals_active'], self.ngoals) self.ngoals_reached = 0 self.goal_order = [i for i in range(self.ngoals)] random.shuffle(self.goal_order) for i in range(self.ngoals): gi.add_goal(self, self.sample_reachable_loc(ensure_empty=True), i) for i in range(self.ngoals_active): objective = 'obj' + str(i) + ' go goal' + str(self.goal_order[i]) info = gi.build_info_attr(objective) self.build_add_item(info) self.current_goal = 'goal' + str(self.goal_order[0]) gi.add_random_cycle_switches(self, self.nswitches, self.ncolors) gi.add_standard_items(self) self.finished = False #TODO breadcrumb action self.flag_visited = False if opts['flag_visited'] == 1: self.flag_visited = True self.agent = self.items_bytype['agent'][0]
def __init__(self, opts): super(Game, self).__init__(opts) self.goal_reward = 3.0 self.nblocks = int(opts.get('nblocks') or 0) self.nwater = int(opts.get('nwater') or 0) self.nswitches = opts.get('nswitches') or 1 self.ncolors = opts.get('ncolors') or 3 info = gi.build_info_attr('go goal0') self.build_add_item(info) gi.build_big_random_wall(self) b = random.choice(self.items_bytype['block']) loc = b.attr['loc'] self.remove_item(b) s = gi.CycleSwitchOpenedDoor({'loc': loc}, color=random.randint(0, self.ncolors - 1)) self.add_prebuilt_item(s) gi.add_goal(self, self.sample_reachable_loc(ensure_empty=True), 0) gi.add_standard_items(self) # agent self.agent = self.items_bytype['agent'][0] self.agent.replace_action('toggle_close', standard_grid_actions.toggle_close) # whether switches added are reachable by the agent self.switch_reachable = gi.add_reachable_cycle_switches( self, self.nswitches, self.ncolors, self.agent.attr['loc']) #gi.add_random_cycle_switches(self, self.nswitches, self.ncolors) # always goal0. fixme? self.finished = False
def __init__(self, opts): super(Game, self).__init__(opts) self.goal_loc = self.sample_reachable_loc(ensure_empty=True) if opts.get('fixed_goal'): self.goal_loc = (0, 0) gi.add_goal(self, self.goal_loc, 0) self.nblocks = int(opts.get('nblocks') or 0) self.nwater = int(opts.get('nwater') or 0) gi.add_standard_items(self) self.agent = self.items_bytype['agent'][0] self.finished = False self.stat = dict() self.stat['success'] = 0
def __init__(self, opts): super(Game, self).__init__(opts) self.goal_loc = self.sample_reachable_loc(ensure_empty=True) if opts.get('fixed_goal'): self.goal_loc = (0,0) self.nblocks = int(opts.get('nblocks') or 0) self.nwater = int(opts.get('nwater') or 0) destination = 'ax' + str(self.goal_loc[0]) + 'y' + str(self.goal_loc[1]) info = gi.build_info_attr('obj0 go absolute ' + destination) self.build_add_item(info) gi.add_standard_items(self) self.agent = self.items_bytype['agent'][0] self.finished = False
def __init__(self, opts): super(Game, self).__init__(opts) self.nblocks = int(opts.get('nblocks') or 0) self.nwater = int(opts.get('nwater') or 0) gi.add_standard_items(self) self.agent = self.items_bytype['agent'][0] gi.add_cycle_switch(self, self.sample_reachable_loc(), 2) self.switch = self.items_bytype['cycle_switch'][0] if opts['test_mode']: self.switch.setc(0) self.agent.replace_action('toggle_close', standard_grid_actions.toggle_close) self.finished = False self.switch_prev_color = self.switch.color self.reset_stat()
def __init__(self, opts): super(Game, self).__init__(opts) self.door_x = random.randint(1, self.mapsize[0] - 2) self.door_y = random.randint(0, self.mapsize[1] - 1) self.door = gi.PickableKeyOpenedDoor( {'loc': (self.door_x, self.door_y)}, key=0) self.add_prebuilt_item(self.door) # add wall wall_x = self.door_x for wall_y in range(self.mapsize[1]): if wall_y != self.door_y: gi.add_block(self, loc=(wall_x, wall_y)) self.goal_loc = self.sample_reachable_loc(ensure_empty=True) gi.add_goal(self, self.goal_loc, 0) self.nblocks = int(opts.get('nblocks') or 0) self.nwater = int(opts.get('nwater') or 0) gi.add_standard_items(self) self.agent = self.items_bytype['agent'][0] # add switch opposite of goal key_y = random.randint(0, self.mapsize[1] - 1) if self.goal_loc[0] < wall_x: key_x = random.randint(wall_x + 1, self.mapsize[0] - 1) else: key_x = random.randint(0, wall_x - 1) self.key = gi.PickableKey({'loc': (key_x, key_y)}, 0) self.add_prebuilt_item(self.key) self.agent.replace_action('toggle_close', standard_grid_actions.toggle_close) # move agent opposite of goal agent_y = random.randint(0, self.mapsize[1] - 1) if self.goal_loc[0] < wall_x: agent_x = random.randint(wall_x + 1, self.mapsize[0] - 1) else: agent_x = random.randint(0, wall_x - 1) self.move_item(self.agent, (agent_x, agent_y)) self.finished = False self.reset_stat()
def __init__(self, opts): super(Game, self).__init__(opts) self.wrong_goal_cost = opts['wrong_goal_cost'] self.nblocks = int(opts.get('nblocks') or 0) self.nwater = int(opts.get('nwater') or 0) #these are decoys: self.nswitches = opts.get('nswitches') or 0 self.ncolors = opts.get('ncolors') or 3 self.ngoals = opts['ngoals'] self.ngoals_active = min(opts['ngoals_active'], self.ngoals) self.ngoals_reached = 0 self.goal_order = [i for i in range(self.ngoals)] random.shuffle(self.goal_order) for i in range(self.ngoals): gi.add_goal(self, self.sample_reachable_loc(ensure_empty=True), i) info = gi.build_info_attr('info visit all excluding') self.build_add_item(info) goals = self.items_bytype['goal'] self.finished_goals = {} for i in range(self.ngoals_active): self.finished_goals['goal' + str(self.goal_order[i])] = False for i in range(self.ngoals_active, self.ngoals): objective = 'info avoid goal' + str(self.goal_order[i]) info = gi.build_info_attr(objective) self.build_add_item(info) goals[i].attr['_touch_cost'] = self.wrong_goal_cost gi.add_random_cycle_switches(self, self.nswitches, self.ncolors) gi.add_standard_items(self) self.finished = False #TODO breadcrumb action self.flag_visited = False if opts['flag_visited'] == 1: self.flag_visited = True self.agent = self.items_bytype['agent'][0]
def __init__(self, opts): super(Game, self).__init__(opts) self.nblocks = int(opts.get('nblocks') or 0) self.nwater = int(opts.get('nwater') or 0) self.ncolors = opts.get('ncolors') or 3 self.nswitches = 1 gi.add_random_cycle_switches(self, self.nswitches, self.ncolors) color = self.items_bytype['cycle_switch'][0].attr['@color'] info = gi.build_info_attr('info push block onto ' + color + ' switch') self.build_add_item(info) loc = self.sample_reachable_loc(ensure_empty=True) s = gi.PushableBlock({'loc': loc}) self.add_prebuilt_item(s) gi.add_standard_items(self) self.agent = self.items_bytype['agent'][0] self.agent.replace_action('push_up', standard_grid_actions.push_up) self.agent.replace_action('push_down', standard_grid_actions.push_down) self.agent.replace_action('push_left', standard_grid_actions.push_left) self.agent.replace_action('push_right', standard_grid_actions.push_right) self.finished = False self.goal_loc = self.items_bytype['cycle_switch'][0].attr['loc']
def __init__(self, opts): super(Game, self).__init__(opts) self.ngoals = opts.get('ngoals') or 2 for i in range(self.ngoals): gi.add_goal(self, self.sample_reachable_loc(ensure_empty=True), i) self.ncolors = opts.get('ncolors') or 2 gi.add_random_cycle_switches(self, 1, self.ncolors) self.cmap = [] for s in range(self.ncolors): g = random.randint(0, self.ngoals - 1) self.cmap.append(g) info = gi.build_info_attr('if cycle_switch color ' + 'color' + str(s) + ' go goal' + str(g)) self.build_add_item(info) self.nblocks = int(opts.get('nblocks') or 0) self.nwater = int(opts.get('nwater') or 0) gi.add_standard_items(self) self.agent = self.items_bytype['agent'][0] self.agent.replace_action('toggle_close', standard_grid_actions.toggle_close) self.finished = False
def __init__(self, opts): super(Game, self).__init__(opts) self.nblocks = int(opts.get('nblocks') or 0) self.nwater = int(opts.get('nwater') or 0) self.ngoals = opts['ngoals'] self.goal_locs = [] for s in range(self.ngoals): loc = self.sample_reachable_loc(ensure_empty=True) destination = 'ax' + str(loc[0]) + 'y' + str(loc[1]) info = gi.build_info_attr('goal' + str(s) + ' at absolute ' + destination) self.build_add_item(info) #add actual goals to prevent duplicate locs as in original mb # don't really need this? self.goal_locs.append(loc) gi.add_goal(self, loc, s) self.items_bytype['goal'][s].attr['_invisible'] = True gid = random.randint(0, self.ngoals - 1) info = gi.build_info_attr('obj0 go goal' + str(gid)) self.build_add_item(info) gi.add_standard_items(self) self.agent = self.items_bytype['agent'][0] self.finished = False self.goal_loc = self.items_bytype['goal'][gid].attr['loc']
def __init__(self, opts): super(Game, self).__init__(opts) self.goal_reward = 3.0 self.goal_loc = self.sample_reachable_loc(ensure_empty=True) self.nblocks = int(opts.get('nblocks') or 0) self.nwater = int(opts.get('nwater') or 0) self.explicit = opts.get('explicit') or False self.nswitches = opts.get('nswitches') or 2 self.ncolors = opts.get('ncolors') or 2 if self.explicit: self.target_color = random.randint(0, self.ncolors) tcs = 'color' + str(self.target_color) else: self.target_color = -1 tcs = 'same' info = gi.build_info_attr('obj0 switch color ' + tcs) self.build_add_item(info) gi.add_random_cycle_switches(self, self.nswitches, self.ncolors) gi.add_standard_items(self) self.agent = self.items_bytype['agent'][0] self.agent.replace_action('toggle_close', standard_grid_actions.toggle_close) self.finished = False