コード例 #1
1
    def __init__(self,  tiles):
        """Create a boggle board and its graphical depiction
        from a string of 16 characters.
        Args:
        self:  the board (to be initialized)
        tiles: A string of exactly 16 characters, each
               representing one tile.  Most characters
               represent a tile containing that character,
               but 'q' represents the pair 'qu' on a tile.
        Returns:  Nothing.  The board is encapsulated in this module.
        """

        assert(len(tiles) == 16)
        self.content = []
        self.results = []  # Added by Cole to reduce recursion load
        self.in_use = []
        grid.make(4, 4, 500, 500)     # Hack alert!
        for row in range(4):
            self.content.append([])
            self.in_use.append([])
            for col in range(4):
                char = tiles[4*row + col]
                if char == "q":
                    char = "qu"
                self.content[row].append(char)
                self.in_use[row].append(False)
                grid.fill_cell(row, col, grid.white)  # Hack alert!
                grid.label_cell(row, col, char)       # Hack alert!
コード例 #2
0
 def __init__(self, tiles):
     """
    Create a boggle board and its graphical depiction
    from a string of 16 characters.
    Args:
     self:  the board (to be initialized)
     tiles: A string of exactly 16 characters, each
            representing one tile.  Most characters
            represent a tile containing that character,
            but 'q' represents the pair 'qu' on a tile.
     Returns:  Nothing.  The board is encapsulated in this module.
     """
     assert (len(tiles) == 16)
     self.content = []
     self.in_use = []
     grid.make(4, 4, 500, 500)  # Hack alert!
     for row in range(4):
         self.content.append([])
         self.in_use.append([])
         for col in range(4):
             char = tiles[4 * row + col]
             if char == "q":
                 char = "qu"
             self.content[row].append(char)
             self.in_use[row].append(False)
             grid.fill_cell(row, col, grid.white)  # Hack alert!
             grid.label_cell(row, col, char)  # Hack alert!
コード例 #3
0
ファイル: run.py プロジェクト: davidbrochart/guyane
def main(reset, logfile, printout, keepgpm, login, fromdate, todate):
    if not os.path.exists('../data/grid.json'):
        grid.make()
    url = 'jsimpson.pps.eosdis.nasa.gov'
    # create tmp directory, in which there is log.txt where debugging information is written
    os.makedirs('tmp', exist_ok=True)
    shutil.rmtree('gpm_data', ignore_errors=True)
    os.makedirs('gpm_data', exist_ok=True)
    os.makedirs('gpm_csv', exist_ok=True)
    os.makedirs('gpm_ws', exist_ok=True)
    os.makedirs('p2d_1d', exist_ok=True)
    log = Log(logfile, printout)
    # create (if doesn't exist) or load "file_df.pkl", this file keeps track of GPM files that have been downloaded
    ftp_dst_dir = 'gpm_data/'
    p_day_nb = 30
    q_day_nb = 1024
    shrink_dir = 'gpm_shrink/'
    csv_dir = 'gpm_csv/'
    ws_dir = 'gpm_ws/'
    gr4j_x = {
        'Saut Sabbat': [
            2919.540841224371, -0.86168151155171913, 84.70999803176737,
            3.4981162284065435
        ],
        'Saut Bief': [
            3238.6514534172547, 0.33831940503407765, 74.518651431825504,
            2.511460578426322
        ],
        'Saut Athanase': [
            4438.1659870265757, 0.73540066060669718, 101.61011800978221,
            2.4594558605711621
        ],
        'Saut Maripa': [
            2581.211011708363, -0.32108302526110438, 115.03812899301911,
            3.3598618612404842
        ],
        'Maripasoula': [
            3003.1886179611165, -2.2929565882464029, 116.05308733707037,
            4.4106266442720621
        ],
        'Langa Tabiki': [
            2677.4118727879959, -1.7274632708443527, 136.1150157663804,
            4.6408104323814863
        ]
    }
    ws_names = list(gr4j_x.keys()) + ['Tapanahony']
    while True:  # program main loop
        if get_gpm(url, login, log, ftp_dst_dir, shrink_dir, keepgpm, fromdate,
                   todate, reset):
            make_p_csv(shrink_dir, csv_dir, p_day_nb)
            get_pe_ws(shrink_dir, ws_dir, ws_names, reset)
            get_q_ws(ws_dir, ws_names, gr4j_x)
            make_q_json(ws_dir, csv_dir, q_day_nb, ws_names)
            make_download_files(shrink_dir, ws_dir, csv_dir, ws_names,
                                fromdate)
        reset = False
        log.write('Now going to sleep...')
        sleep(1800)  # going to sleep for half an hour
コード例 #4
0
def display(cave):
    """Create a graphical representation of cave using the grid.
    This graphical representation can be further manipulated
    (e.g., filling cave cells with water of various colors)
    using the fill_cell method of module grid.
    
    Args: 
        cave: A matrix (list of lists) representing the cavern
    Returns: 
        Nothing, but has the side effect of creating a graphical 
        grid representation of the cavern in a 500x500 pixel window. 
    """
    nrows = len(cave)
    ncols = len(cave[0])
    grid.make(nrows, ncols, 500, 500)
    for row in range(nrows):
        for col in range(ncols):
            if cave[row][col] == STONE:
                grid.fill_cell(row, col, grid.black)
コード例 #5
0
ファイル: flood_cave.py プロジェクト: I-Dream-in-Code/CIS-210
def display(cave):
    """Create a graphical representation of cave using the grid.
    This graphical representation can be further manipulated
    (e.g., filling cave cells with water of various colors)
    using the fill_cell method of module grid.
    
    Args: 
        cave: A matrix (list of lists) representing the cavern
    Returns: 
        Nothing, but has the side effect of creating a graphical 
        grid representation of the cavern in a 500x500 pixel window. 
    """
    nrows = len(cave)
    ncols = len(cave[0])
    grid.make(nrows, ncols, 500, 500)
    for row in range(nrows):
        for col in range(ncols):
            if cave[row][col] == STONE :
                grid.fill_cell(row, col, grid.black)
コード例 #6
0
def display(board):
    """Create a display of a Sudoku board.
    Arguments: 
        board: an sdkboard.Board object
        
    Note an event handler (handle_events) will be attached 
    as a listener to each tile in the board. 
    """
    grid.make(9,9,500,500)
    grid.sub_grid_dim(3,3)
    for row in range(9):
        for col in range(9):
            # Direct access to tile of sdkboard is more Pythonic
            # than an access method. 
            # In Java and some other languages we'd need a getter. 
            tile = board.tiles[row][col]
            tile.register(handle_events)
            grid.fill_cell(row, col, grid.white)
            if (tile.symbol != sdkboard.OPEN):
                grid.label_cell(row, col, tile.symbol)
コード例 #7
0
ファイル: sdkdisplay.py プロジェクト: honglux/projects_works
def display(board):
    """Create a display of a Sudoku board.
    Arguments: 
        board: an sdkboard.Board object
        
    Note an event handler (handle_events) will be attached 
    as a listener to each tile in the board. 
    """
    grid.make(9,9,500,500)
    grid.sub_grid_dim(3,3)
    for row in range(9):
        for col in range(9):
            # Direct access to tile of sdkboard is more Pythonic
            # than an access method. 
            # In Java and some other languages we'd need a getter. 
            tile = board.tiles[row][col]
            tile.register(handle_events)
            grid.fill_cell(row, col, grid.white)
            if (tile.symbol != sdkboard.OPEN):
                grid.label_cell(row, col, tile.symbol)
コード例 #8
0
ファイル: rmgenerator.py プロジェクト: wallarelvo/racer
 def generate(self, num_points):
     gd = grid.make(self.width, self.height, self.width, self.height)
     rm = roadmap.make(gd, self.max_dist)
     return self.resample(rm, num_points)
コード例 #9
-8
 def __init__(self,  tiles):
     """
     Create a boggle board and its graphical depiction
     from a string of characters.
     Args:
      self:  the board (to be initialized)
      tiles: A string of characters, each
             representing one tile.  Most characters
             represent a tile containing that character,
             but 'q' represents the pair 'qu' on a tile.
      Returns:  Nothing.  The board is encapsulated in this module.
      """
     # To maintain desired functionality from the command line the board must 
     # square.  To ensure this and do math on the board square root is used
     # frequently.  
     assert(len(tiles)**.5 == int(len(tiles)**.5)) # To ensure board is quare.  
     self.content = [ ]
     self.in_use = [ ]
     self.board_height = int(len(tiles)**.5) 
     self.board_width = int(len(tiles)**.5)
     grid.make(self.board_height,self.board_width,500,500)     # Hack alert! 
     for row in range(self.board_height):
         self.content.append([ ])
         self.in_use.append([ ])
         for col in range(self.board_width):
             char = tiles[int(len(tiles)**.5)*row + col]
             if char == "q" :
                 char = "qu"
             self.content[row].append(char)
             self.in_use[row].append( False )
             grid.fill_cell(row,col,grid.white)  # Hack alert! 
             grid.label_cell(row,col,char)       # Hack alert!