def __load_bounds(self):
    """
    Attempts to load the persisted size/location details from the geometry
    settings files, and adjust the form's current state to match.
    """
    
    do_default_loc = True
    if self.__persist_size_key_s or self.__persist_loc_key_s:
       prefs = load_map(Resources.GEOMETRY_FILE)
       
       # grab the stored size value, if any, and apply it
       if self.__persist_size_key_s and self.__persist_size_key_s in prefs:
          try:
             size = prefs[self.__persist_size_key_s].split(',')
             self.Size = Size(int(size[0]), int(size[1]))
          except:
             # didn't work, just stick with the forms current size
             pass
          
       # grab the stored location value, if any, and apply it
       if self.__persist_loc_key_s and self.__persist_loc_key_s in prefs:
          try:
             loc = prefs[self.__persist_loc_key_s].split(',')
             loc = Point(int(loc[0]), int(loc[1]))
             self.Location = loc
             do_default_loc = False
          except:
             do_default_loc = True
    
    if do_default_loc:
       self.CenterToParent()          
示例#2
0
    def __init__(self, map_file=''):
        if map_file == '':
            print "No map file name supplied with map_class"
            sys.exit()
            
        self.map = utils.load_map(map_file+'_col.lvl')
        self.height = len(self.map)-1
        self.width = len(self.map[0])-1

        self.floor = 0
 def delegate():
    if self.__persist_size_key_s or self.__persist_loc_key_s:
       prefs = load_map(Resources.GEOMETRY_FILE)
       if self.__persist_loc_key_s:
          prefs[self.__persist_loc_key_s] =\
             sstr(self.Location.X) + "," + sstr(self.Location.Y)
       if self.__persist_size_key_s:
          prefs[self.__persist_size_key_s] =\
             sstr(self.Width) + "," + sstr(self.Height)
       persist_map(prefs, Resources.GEOMETRY_FILE)
示例#4
0
 def __init__(self, width, height, map_file=''):
     if map_file == '':
         self.width = width
         self.height = height
         self.totalArea = width*height
         self.map = []
         self.buildGrid(self.wall)
         self.fillGrid()  
     else:
         self.map = utils.load_map('level1_col.lvl')
         self.height = len(self.map)-1
         self.width = len(self.map[0])-1
         self.totalArea = width*height
示例#5
0
 def loadMapFile(self, map_file):
     # Load the tile images
     for infile in glob.glob( os.path.join('../data/images/tiles', '*.*') ):
         self.tiles[infile[len(infile)-5]] = pygame.image.load(infile).convert_alpha()   
     
     # Load the sprite images
     self.map_sprites = [pygame.image.load('../data/images/sprites/sprite%d.png' % n).convert_alpha() for n in range(6)]
     self.map_sprites_rd = [53, 0, 128, 128, 0, 0]
     self.map_sprites_list = []
     self.tileWidth, self.tileHeight = self.tiles['0'].get_size()
     
     # Load tiles
     self.map_file = map_file
     self.tileData1 = utils.load_char_map(self.map_file+'_layer1.lvl')
     self.tileData2 = utils.load_char_map(self.map_file+'_layer2.lvl')
     self.col_data = utils.load_map(self.map_file+'_col.lvl')
     self.map_size = len(self.tileData1[0])-1
     
     # Load up sprites
     self.spriteData = utils.load_map(self.map_file+'_sprites.lvl')
     for x in range(self.map_size):
         for y in range(self.map_size):
             if self.spriteData[y][x] is not 1: self.map_sprites_list.append((x,y,self.spriteData[y][x]))
示例#6
0
def main():
	parser = argparse.ArgumentParser()
	parser.add_argument('-t', '--test', help="A test directory containing map.pgm, measure.csv, control.csv, and ground.csv files", required=True)
	parser.add_argument('-s', '--states', help='The file containing the starting states to use')
	parser.add_argument('-v', '--visualizer', action='store_const', const=True, help='Add this flag to turn on the visualizer', default=False)
	parser.add_argument('-n', '--numstart', type=int, default=200)

	args = parser.parse_args()
	lmap = utils.load_map('tests/' + args.test + '/map.pgm')
	controls = utils.load_csv('tests/' + args.test + '/control.csv') #a Tx2 array of T (delta phi, velocity)'s
	measurements = utils.load_measurements('tests/' + args.test + '/measure.csv') #a TxMx2 array of T sets of M measurements containing a degree and a measured distance at that degree
	true_start = utils.load_csv('tests/' + args.test + '/ground.csv')
	if args.states:
		start_posns = utils.load_csv(args.states) #a Nx3 array of N (x,y,phi)'s
	else:
		start_posns = generate_init_states(lmap, args.numstart)

	print("Using particle_filter function...")
	particle_filter(start_posns, controls, measurements, lmap, true_start, args.visualizer)
   def load_defaults(self):
      ''' 
      Loads any settings that are saved in the user's settings files (if there 
      are any) and stores them in this Configuration object.
      '''

      # load the loaded dict out of the serialized file
      loaded = {}
      if File.Exists(Resources.SETTINGS_FILE):
         loaded = load_map(Resources.SETTINGS_FILE)
         
      # any settings that the serialized dict happens to contain
      if Configuration.__API_KEY in loaded:
         self.api_key_s = loaded[Configuration.__API_KEY]
         
      if Configuration.__UPDATE_SERIES in loaded:
         self.update_series_b = loaded[Configuration.__UPDATE_SERIES]
      
      if Configuration.__UPDATE_NUMBER in loaded:
         self.update_number_b = loaded[Configuration.__UPDATE_NUMBER]
         
      if Configuration.__UPDATE_PUBLISHED in loaded:
         self.update_published_b = loaded[Configuration.__UPDATE_PUBLISHED]
         
      if Configuration.__UPDATE_RELEASED in loaded:
         self.update_released_b = loaded[Configuration.__UPDATE_RELEASED]
         
      if Configuration.__UPDATE_TITLE in loaded:
         self.update_title_b = loaded[Configuration.__UPDATE_TITLE]
         
      if Configuration.__UPDATE_CROSSOVERS in loaded:
         self.update_crossovers_b = loaded[Configuration.__UPDATE_CROSSOVERS]
         
      if Configuration.__UPDATE_WRITER in loaded:
         self.update_writer_b = loaded[Configuration.__UPDATE_WRITER]

      if Configuration.__UPDATE_PENCILLER in loaded:
         self.update_penciller_b = loaded[Configuration.__UPDATE_PENCILLER]
         
      if Configuration.__UPDATE_INKER in loaded:
         self.update_inker_b = loaded[Configuration.__UPDATE_INKER]

      if Configuration.__UPDATE_COVER_ARTIST in loaded:
         self.update_cover_artist_b = loaded[Configuration.__UPDATE_COVER_ARTIST]

      if Configuration.__UPDATE_COLORIST in loaded:
         self.update_colorist_b = loaded[Configuration.__UPDATE_COLORIST]

      if Configuration.__UPDATE_LETTERER in loaded:
         self.update_letterer_b = loaded[Configuration.__UPDATE_LETTERER]

      if Configuration.__UPDATE_EDITOR in loaded:
         self.update_editor_b = loaded[Configuration.__UPDATE_EDITOR]
         
      if Configuration.__UPDATE_SUMMARY in loaded:
         self.update_summary_b = loaded[Configuration.__UPDATE_SUMMARY]
         

      if Configuration.__UPDATE_IMPRINT in loaded:
         self.update_imprint_b = loaded[Configuration.__UPDATE_IMPRINT]

      if Configuration.__UPDATE_PUBLISHER in loaded:
         self.update_publisher_b = loaded[Configuration.__UPDATE_PUBLISHER]
         
      if Configuration.__UPDATE_VOLUME in loaded:
         self.update_volume_b = loaded[Configuration.__UPDATE_VOLUME]

      if Configuration.__UPDATE_CHARACTERS in loaded:
         self.update_characters_b = loaded[Configuration.__UPDATE_CHARACTERS]

      if Configuration.__UPDATE_TEAMS in loaded:
         self.update_teams_b = loaded[Configuration.__UPDATE_TEAMS]
      
      if Configuration.__UPDATE_LOCATIONS in loaded:
         self.update_locations_b = loaded[Configuration.__UPDATE_LOCATIONS]
         
      if Configuration.__UPDATE_WEBPAGE in loaded:
         self.update_webpage_b = loaded[Configuration.__UPDATE_WEBPAGE]
         
      if Configuration.__OVERWRITE_EXISTING in loaded:
         self.ow_existing_b = loaded[Configuration.__OVERWRITE_EXISTING]

      if Configuration.__IGNORE_BLANKS in loaded:
         self.ignore_blanks_b = loaded[Configuration.__IGNORE_BLANKS]

      if Configuration.__CONVERT_IMPRINTS in loaded:
         self.convert_imprints_b = loaded[Configuration.__CONVERT_IMPRINTS]

      if Configuration.__AUTOCHOOSE_SERIES in loaded:
         self.autochoose_series_b = loaded[Configuration.__AUTOCHOOSE_SERIES]
         
      if Configuration.__CONFIRM_ISSUE in loaded:
         self.confirm_issue_b = loaded[Configuration.__CONFIRM_ISSUE]

      if Configuration.__DOWNLOAD_THUMBS in loaded:
         self.download_thumbs_b=loaded[Configuration.__DOWNLOAD_THUMBS]
         
      if Configuration.__PRESERVE_THUMBS in loaded:
         self.preserve_thumbs_b=loaded[Configuration.__PRESERVE_THUMBS]
         
      if Configuration.__FAST_RESCRAPE in loaded:
         self.fast_rescrape_b=loaded[Configuration.__FAST_RESCRAPE]
         
      if Configuration.__RESCRAPE_NOTES in loaded:
         self.rescrape_notes_b = loaded[Configuration.__RESCRAPE_NOTES]
         
      if Configuration.__RESCRAPE_TAGS in loaded:
         self.rescrape_tags_b = loaded[Configuration.__RESCRAPE_TAGS]
         
      if Configuration.__SUMMARY_DIALOG in loaded:
         self.summary_dialog_b = loaded[Configuration.__SUMMARY_DIALOG]
      
      # grab the contents of the advanced settings file, too   
      if File.Exists(Resources.ADVANCED_FILE): 
         self.advanced_settings_s = load_string(Resources.ADVANCED_FILE)
示例#8
0
def main():
    parser = argparse.ArgumentParser(description="")
    parser.add_argument("-b", "--biom-file", help="An input biom file", required=True)
    parser.add_argument("-m", "--mapping-file", help="A mapping file", required=True)
    parser.add_argument("-c", "--class-label", help="Which data are we trying to analyze", required=True)
    parser.add_argument(
        "-d",
        "--subclass",
        action="append",
        help="Subselect only some of the data - if specified, this should appear at least twice with the adequate options. ex: -c SEX -d male -d female",
        required=False,
    )
    parser.add_argument("-o", "--output-folder", help="The folder to output our data to", required=True)
    parser.add_argument("-p", "--min-features", help="Minimum number of features to test", default=50, required=False)
    parser.add_argument("-q", "--max-features", help="Maximum number of features to test", default=150, required=False)
    parser.add_argument(
        "-s",
        "--step-size",
        help="Step size within the range of the number of features to be tested",
        default=1,
        required=False,
    )
    # parser.add_argument("-p", "--predictor", help="Classifier/Predictor used", default="nbc", required=False) # As of today, contains only nbc
    parser.add_argument(
        "-j",
        "--objective-function",
        help="Objective function for the feature selection algorithm",
        default="mim",
        required=False,
    )
    parser.add_argument(
        "-t",
        "--output-type",
        help="data output format. default: CSV options: csv, matlab, r, numpy",
        default="csv",
        required=False,
    )
    parser.add_argument(
        "-f",
        "--select-field",
        help="Field to extract a subset of the data. e.g. EN_BIOME, COUNTRY. The default considers the whole dataset",
        default=None,
        required=False,
    )
    parser.add_argument(
        "-g",
        "--value-field",
        action="append",
        help="When used with -f specifies the value of the field to filter - THIS IS REQUIRED IF -f if present",
        default=None,
        required=False,
    )
    parser.add_argument(
        "-k",
        "--cluster",
        action="append",
        help="Allows to subgroup some of the labels. Ex: -k 'Vegan Vegan+Seafood'. The different values are separated with semi colon. Requires at least two appearances. This cannot be used in conjunction with the -d option",
        default=None,
        required=False,
    )
    ## Need to be continued!!!!
    print "Definition of the arguments done"
    global output_type
    print "Start of the program"

    args = parser.parse_args()

    output_type = args.output_type.lower()

    # if our folder doesn't exist create it
    if not os.path.isdir(args.output_folder):
        os.mkdir(args.output_folder)

    nb_features = range(int(args.min_features), int(args.max_features) + 1, int(args.step_size))
    print "nb_features prepared"

    matrix, site_names, otu_ids, otu_phylo = utils.load_biom(args.biom_file)
    metadata = utils.load_map(args.mapping_file)
    class_labels = []
    for sample in site_names:
        class_labels.append(metadata[sample][args.class_label])

    print "class_labels loaded"

    interesting_samples = range(0, len(site_names))

    if args.select_field is not None:
        interesting_fields = [it.lower() for it in args.value_field]
        print interesting_fields
        subsample_habitat = [
            i
            for i, sample in enumerate(site_names)
            if metadata[sample][args.select_field].lower() in interesting_fields
        ]
        interesting_samples = list(set(interesting_samples).intersection(set(subsample_habitat)))

    if args.subclass is not None:
        target_labels = [it.lower() for it in args.subclass]
        subsamples = [i for i in xrange(0, len(class_labels)) if class_labels[i].lower() in target_labels]
        interesting_samples = list(set(interesting_samples).intersection(set(subsamples)))

    if (args.cluster is not None) and (args.subclass is None):
        print "In da cluster separation"
        clusters = [it for it in args.cluster]
        clusters_dict = {}
        print "Initial Dictionary created"
        for idx, a_cluster in enumerate(clusters):
            print "In da loop"
            # keys = a_cluster.split()
            keys = a_cluster.split(";")
            print keys
            for a_key in keys:
                clusters_dict[a_key.lower()] = idx

        subsamples = [i for i in xrange(0, len(class_labels)) if class_labels[i].lower() in clusters_dict]
        interesting_samples = list(set(interesting_samples).intersection(set(subsamples)))
        for i in subsamples:
            class_labels[i] = "cluster" + str(clusters_dict[class_labels[i].lower()])

    matrix = matrix[interesting_samples, :]
    class_labels = [class_labels[i] for i in interesting_samples]

    class_labels, labels_key = utils.discretize(class_labels)

    matrix = matrix + 1
    row_sums = matrix.sum(axis=1)

    matrix = matrix / row_sums[:, np.newaxis]
    matrix = np.ceil(matrix / matrix.min())

    # So far, we have the biom file open and the environment parameters
    # We can now launch our feature selection algorithm
    further_param = []  # This has to be adapted to the case we are using other objective functions

    nb_tests = 10
    nb_folds = 5

    launch_tests_feature_selection(
        matrix,
        np.array(map(int, class_labels)),
        site_names,
        otu_ids,
        otu_phylo,
        args.objective_function,
        nb_features,
        nb_tests,
        args.output_folder,
        nb_folds,
    )
    avg_consistency, max_consistency, min_consistency, std_consistency = get_consistencies(
        nb_features, len(otu_ids), nb_tests, args.output_folder
    )
    save_results(
        "consistency",
        os.path.join(args.output_folder, "consistencyresults.txt"),
        avg_consistency,
        max_consistency,
        min_consistency,
        std_consistency,
    )

    avg_accuracy_g, max_accuracy_g, min_accuracy_g, std_accuracy_g, avg_accuracy, max_accuracy, min_accuracy, std_accuracy = get_accuracies(
        nb_features, len(otu_ids), nb_tests, args.output_folder
    )
    save_results(
        "Accuracy",
        os.path.join(args.output_folder, "accuracyGaussianresults.txt"),
        avg_accuracy_g,
        max_accuracy_g,
        min_accuracy_g,
        std_accuracy_g,
    )
 def __init__(self):
    ''' Initializes a new Configuration object with default settings '''
    self.__prior_series_sl = set(utils.load_map(Resources.SERIES_FILE).keys())
示例#10
0
 def __init__(self):
    ''' Initializes a new Configuration object with default settings '''
    self.__prior_series_sl = set(utils.load_map(Resources.SERIES_FILE).keys())
示例#11
0
def runtest(mapfile, start, goal, verbose=True):
    # directory to save results
    result_dir = 'results'
    if not os.path.exists(result_dir):
        os.mkdir(result_dir)
    map_name = mapfile.split('.')[-2].split('/')[-1]
    plots_save_path = os.path.join(result_dir, map_name)
    if os.path.exists(plots_save_path):
        for file_name in os.listdir(plots_save_path):
            os.remove(os.path.join(plots_save_path, file_name))
        os.rmdir(plots_save_path)
    os.mkdir(plots_save_path)

    # display the environment
    boundary, blocks = load_map(mapfile)
    if verbose:
        fig, ax, hb, hs, hg = draw_map(boundary, blocks, start, goal, 'map')
        # mng = plt.get_current_fig_manager()
        # mng.resize(*mng.window.maxsize())
        plt.savefig(os.path.join(plots_save_path, 'result%04d.png' % 0))

    # instantiate a robot planner
    # RP = RobotPlannerGreedy(boundary, blocks)
    # RP = RobotPlannerRTAA(boundary, blocks)
    RP = RobotPlannerRRT(boundary,
                         blocks,
                         map_name,
                         display=True,
                         map_data=[fig, ax])

    # main loop
    robotpos = np.copy(start)
    numofmoves = 0
    max_time = 0
    total_time = 0
    trajectory = np.copy(start)
    while True:

        # call the robot planner
        newrobotpos, move_time = RP.plan(robotpos, goal)
        total_time += move_time
        max_time = max(move_time, max_time)
        movetime = max(1, np.ceil(move_time / 2.0))

        # check if the planner was done on time
        if movetime > 1:
            newrobotpos = robotpos - 0.5 + np.random.rand(3)
            print('\nWarning: move time exceeds limit.')

        # check if the commanded position is valid
        if not check(robotpos, newrobotpos, blocks, boundary):
            success = False
            break

        # make the move
        robotpos = newrobotpos
        numofmoves += 1
        trajectory = np.vstack((trajectory, robotpos))
        print('\rNum of moves: %04d, move time: %.2f s, max time: %.2f s' %
              (numofmoves, move_time, max_time),
              end='',
              flush=True)

        # update plot
        if verbose:
            hs[0].set_xdata(robotpos[0])
            hs[0].set_ydata(robotpos[1])
            hs[0].set_3d_properties(robotpos[2])
            ax.plot(trajectory[-2:, 0], trajectory[-2:, 1], trajectory[-2:, 2],
                    'r')
            fig.canvas.flush_events()
            plt.savefig(
                os.path.join(plots_save_path, 'result%05d.png' % numofmoves))

        # check if the goal is reached
        if sum((robotpos - goal)**2) <= 0.1:
            success = True
            break

        # exit if number of moves exceeds limit
        if numofmoves >= 9999:
            success = False
            break

    # calculate distance
    distance = np.sum(np.linalg.norm(trajectory[1:] - trajectory[:-1], axis=1))

    # save video & plot
    if verbose:
        print('\rSaving results...', end='', flush=True)
        result_name = os.path.join(result_dir, map_name)
        # save plot
        hs[0].set_xdata(start[0])
        hs[0].set_ydata(start[1])
        hs[0].set_3d_properties(start[2])
        ax.plot(trajectory[-2:, 0], trajectory[-2:, 1], trajectory[-2:, 2],
                'r')
        fig.canvas.flush_events()
        plt.savefig(result_name + '.png')
        save_gif(plots_save_path, result_name + '.gif')
        print('\rResults have been saved to \'' + result_name + '.gif|png\'.',
              end='',
              flush=True)
        plt.close(fig)

    return success, numofmoves, distance, total_time, max_time
   def load_defaults(self):
      ''' 
      Loads any settings that are saved in the user's settings files (if there 
      are any) and stores them in this Configuration object.
      '''

      # load the loaded dict out of the serialized file
      loaded = {}
      if File.Exists(Resources.SETTINGS_FILE):
         loaded = load_map(Resources.SETTINGS_FILE)
         
      # any settings that the serialized dict happens to contain
      if Configuration.__API_KEY in loaded:
         self.api_key_s = loaded[Configuration.__API_KEY]
         
      if Configuration.__UPDATE_SERIES in loaded:
         self.update_series_b = loaded[Configuration.__UPDATE_SERIES]
      
      if Configuration.__UPDATE_NUMBER in loaded:
         self.update_number_b = loaded[Configuration.__UPDATE_NUMBER]
         
      if Configuration.__UPDATE_PUBLISHED in loaded:
         self.update_published_b = loaded[Configuration.__UPDATE_PUBLISHED]
         
      if Configuration.__UPDATE_RELEASED in loaded:
         self.update_released_b = loaded[Configuration.__UPDATE_RELEASED]
         
      if Configuration.__UPDATE_TITLE in loaded:
         self.update_title_b = loaded[Configuration.__UPDATE_TITLE]
         
      if Configuration.__UPDATE_CROSSOVERS in loaded:
         self.update_crossovers_b = loaded[Configuration.__UPDATE_CROSSOVERS]
         
      if Configuration.__UPDATE_WRITER in loaded:
         self.update_writer_b = loaded[Configuration.__UPDATE_WRITER]

      if Configuration.__UPDATE_PENCILLER in loaded:
         self.update_penciller_b = loaded[Configuration.__UPDATE_PENCILLER]
         
      if Configuration.__UPDATE_INKER in loaded:
         self.update_inker_b = loaded[Configuration.__UPDATE_INKER]

      if Configuration.__UPDATE_COVER_ARTIST in loaded:
         self.update_cover_artist_b = loaded[Configuration.__UPDATE_COVER_ARTIST]

      if Configuration.__UPDATE_COLORIST in loaded:
         self.update_colorist_b = loaded[Configuration.__UPDATE_COLORIST]

      if Configuration.__UPDATE_LETTERER in loaded:
         self.update_letterer_b = loaded[Configuration.__UPDATE_LETTERER]

      if Configuration.__UPDATE_EDITOR in loaded:
         self.update_editor_b = loaded[Configuration.__UPDATE_EDITOR]
         
      if Configuration.__UPDATE_SUMMARY in loaded:
         self.update_summary_b = loaded[Configuration.__UPDATE_SUMMARY]
         

      if Configuration.__UPDATE_IMPRINT in loaded:
         self.update_imprint_b = loaded[Configuration.__UPDATE_IMPRINT]

      if Configuration.__UPDATE_PUBLISHER in loaded:
         self.update_publisher_b = loaded[Configuration.__UPDATE_PUBLISHER]
         
      if Configuration.__UPDATE_VOLUME in loaded:
         self.update_volume_b = loaded[Configuration.__UPDATE_VOLUME]

      if Configuration.__UPDATE_CHARACTERS in loaded:
         self.update_characters_b = loaded[Configuration.__UPDATE_CHARACTERS]

      if Configuration.__UPDATE_TEAMS in loaded:
         self.update_teams_b = loaded[Configuration.__UPDATE_TEAMS]
      
      if Configuration.__UPDATE_LOCATIONS in loaded:
         self.update_locations_b = loaded[Configuration.__UPDATE_LOCATIONS]
         
      if Configuration.__UPDATE_WEBPAGE in loaded:
         self.update_webpage_b = loaded[Configuration.__UPDATE_WEBPAGE]
         
      if Configuration.__OVERWRITE_EXISTING in loaded:
         self.ow_existing_b = loaded[Configuration.__OVERWRITE_EXISTING]

      if Configuration.__IGNORE_BLANKS in loaded:
         self.ignore_blanks_b = loaded[Configuration.__IGNORE_BLANKS]

      if Configuration.__CONVERT_IMPRINTS in loaded:
         self.convert_imprints_b = loaded[Configuration.__CONVERT_IMPRINTS]

      if Configuration.__AUTOCHOOSE_SERIES in loaded:
         self.autochoose_series_b = loaded[Configuration.__AUTOCHOOSE_SERIES]
         
      if Configuration.__CONFIRM_ISSUE in loaded:
         self.confirm_issue_b = loaded[Configuration.__CONFIRM_ISSUE]

      if Configuration.__DOWNLOAD_THUMBS in loaded:
         self.download_thumbs_b=loaded[Configuration.__DOWNLOAD_THUMBS]
         
      if Configuration.__PRESERVE_THUMBS in loaded:
         self.preserve_thumbs_b=loaded[Configuration.__PRESERVE_THUMBS]
         
      if Configuration.__FAST_RESCRAPE in loaded:
         self.fast_rescrape_b=loaded[Configuration.__FAST_RESCRAPE]
         
      if Configuration.__RESCRAPE_NOTES in loaded:
         self.rescrape_notes_b = loaded[Configuration.__RESCRAPE_NOTES]
         
      if Configuration.__RESCRAPE_TAGS in loaded:
         self.rescrape_tags_b = loaded[Configuration.__RESCRAPE_TAGS]
         
      if Configuration.__SUMMARY_DIALOG in loaded:
         self.summary_dialog_b = loaded[Configuration.__SUMMARY_DIALOG]
      
      # grab the contents of the advanced settings file, too   
      if File.Exists(Resources.ADVANCED_FILE): 
         self.advanced_settings_s = load_string(Resources.ADVANCED_FILE)
 while (game_state == "char_screen"):
     event_list = pygame.event.get()
     for event in event_list:
         if event.type == pygame.QUIT:
             pygame.quit()
             sys.exit()
         elif event.type == pygame.KEYDOWN:
             if event.key == pygame.K_s:
                 game_state = "cinematic_screen"
                 life = 3
                 jsonMap = "cave2.json"
                 initial_pos = (412, -1150)
                 shadow = 0
                 losing_time = 250
                 (x, y) = player.rect.x, player.rect.y
                 gameMap = load_map(jsonMap, initial_pos)
                 player_imgs = [
                     "dogefront.png", "dogeback.png", "dogeright.png",
                     "dogeleft.png"
                 ]
                 player = Player(player_imgs[0], screen_center)
                 player.setImage(player_imgs[0])
                 radius = 300
                 offset = 130
         elif event.type == pygame.MOUSEBUTTONDOWN:
             current_mouse_pos = pygame.mouse.get_pos()
             if (doge_portrait.pos.collidepoint(current_mouse_pos)):
                 print "Doge Character Selected"
                 game_state = "cinematic_screen"
                 doge_portrait.click = True
                 doge_portrait.state = "clicked"
    def __init__(
        self,
        map,
        robot_controller_class,
        init_position=None,
        steering_noise=0.01,
        sonar_noise=0.1,
        distance_noise=0.001,
        measurement_noise=0.2,
        speed=5.0,
        turning_speed=0.4 * pi,
        execution_cpu_time_limit=10.0,
        simulation_time_limit=10.0,
        simulation_dt=0.0,
        frame_dt=0.1,
        gps_delay=2.0,
        collision_threshold=50,
        iteration_write_frequency=1000,
        visualisation=True,
        print_robot=True,
        print_logger=False,
    ):
        """
            Initialize KrakrobotSimulator object
            @param steering_noise - variance of steering in move
            @param distance_noise - variance of distance in move
            @param measurement_noise - variance of measurement (GPS??)
            @param map - map for the robot simulator representing the maze or file to map
            @param init_position - starting position of the Robot (can be moved to map class) [x,y,heading]

            @param speed - distance travelled by one move action (cannot be bigger than 0.5, or he could traverse the walls)
            @param simulation_time_limit - limit in ms for whole robot execution (also with init)
            @param collision_threshold - maximum number of collisions after which robot is destroyed
            @param simulation_dt -  controlls simulation calculation intensivity

            @param frame_dt - save frame every dt
            @param robot - RobotController class that will be simulated in run procedure

        """

        if type(map) is str:
            grid, metadata = load_map(map)
            self.map_title = metadata["title"]
            self.grid = grid
            for row in grid:
                logger.info(row)
        else:
            self.grid = map
            self.map_title = ""

        self.N = len(self.grid)
        self.M = len(self.grid[0])

        self.iteration_write_frequency = iteration_write_frequency

        self.collision_threshold = collision_threshold

        if init_position is not None:
            self.init_position = tuple(init_position)
        else:
            for i in xrange(self.N):
                for j in xrange(self.M):
                    if self.grid[i][j] == MAP_START_POSITION:
                        self.init_position = (i, j, 0)

        self.speed = speed
        self.turning_speed = turning_speed
        self.simulation_dt = simulation_dt
        self.frame_dt = frame_dt
        self.robot_controller = robot_controller_class()
        self.print_robot = print_robot
        self.print_logger = print_logger

        self.visualisation = visualisation

        self.sonar_time = SONAR_TIME
        self.gps_delay = gps_delay
        self.light_sensor_time = FIELD_TIME

        self.tick_move = TICK_MOVE
        self.tick_rotate = TICK_ROTATE

        self.simulation_time_limit = simulation_time_limit
        self.execution_cpu_time_limit = execution_cpu_time_limit

        self.goal_threshold = 0.5  # When to declare goal reach

        self.sonar_noise = sonar_noise
        self.distance_noise = distance_noise
        self.measurement_noise = measurement_noise
        self.steering_noise = steering_noise
        self.reset()

        # TODO: Disable logger printing when needed
        if self.print_logger:
            logger.propagate = True
        else:
            logger.propagate = False

        for i in xrange(self.N):
            for j in xrange(self.M):
                if self.grid[i][j] == MAP_GOAL:
                    self.goal = (i, j)