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.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.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.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