samworld.py
def tile_type(tile_ref, level, ground_default, sky_default):
    """Returns the tile type at the given column and row in the level. 
       tile_ref is the column and row of a tile as a 2-item sequence
       level is the nested list of tile types representing the level map. 
       ground_default is the tile type to return if the tile_ref is below the bottom of the level. 
       sky_default is the tile type to return if the tile_ref is above, to the left of, or to the right of the bounds of
       the level."""
       
    #
    #           sky    
    #           default
    #         +--------+
    # sky     | level  | sky
    # default |        | default
    #    - - -+--------+- - -
    #           ground 
    #           default
    #
    
    # return default 'ground' tile if reference is off the bottom of the level
    if tile_ref[1] >= len(level):
        return ground_default
        
    # look up tile type in nested level list if reference is inside bounds of level
    elif len(level)>0 and 0 <= tile_ref[0] < len(level[0]) and 0 <= tile_ref[1] < len(level):
        return level[tile_ref[1]][tile_ref[0]]
        
    # otherwise reference is above, left of or right of the level bounds. return default 'sky' tile
    else:
        return sky_default
Returns the tile type at the given column and row in the level. 
       tile_ref is the column and row of a tile as a 2-item sequence
       level is the nested list of tile types representing the level map. 
       ground_default is the tile type to return if the tile_ref is below the bottom of the level. 
       sky_default is the tile type to return if the tile_ref is above, to the left of, or to the right of the bounds of
       the level.
Returns the tile type at the given column and row in the level.
tile_ref is the column and row of a tile as a 2-item sequence
level is the nested list of tile types representing the level map.
ground_default is the tile type to return if the tile_ref is below the bottom of the level.
sky_default is the tile type to return if the tile_ref is above, to the left of, or to the right of the bounds of
the level.
Returns the tile type at the given column and row in the level . tile_ref is the column and row of a tile as a 2 - item sequence level is the nested list of tile types representing the level map . ground_default is the tile type to return if the tile_ref is below the bottom of the level . sky_default is the tile type to return if the tile_ref is above to the left of or to the right of the bounds of the level .
def tile_type(tile_ref, level, ground_default, sky_default):
               sky    
               default
             +--------+
     sky     | level  | sky
     default |        | default
        - - -+--------+- - -
               ground 
               default
     return default 'ground' tile if reference is off the bottom of the level
    if tile_ref[1] >= len(level):
        return ground_default
     look up tile type in nested level list if reference is inside bounds of level
    elif len(level)>0 and 0 <= tile_ref[0] < len(level[0]) and 0 <= tile_ref[1] < len(level):
        return level[tile_ref[1]][tile_ref[0]]
     otherwise reference is above, left of or right of the level bounds. return default 'sky' tile
    else:
        return sky_default
def tile_type ( tile_ref , level , ground_default , sky_default ) : if tile_ref [ 1 ] >= len ( level ) : return ground_default elif len ( level ) > 0 and 0 <= tile_ref [ 0 ] < len ( level [ 0 ] ) and 0 <= tile_ref [ 1 ] < len ( level ) : return level [ tile_ref [ 1 ] ] [ tile_ref [ 0 ] ] else : return sky_default
Returns the tile type at the given column and row in the level.
Returns the tile type at the given column and row in the level .
"""Returns the tile type at the given column and row in the level. 
       tile_ref is the column and row of a tile as a 2-item sequence
       level is the nested list of tile types representing the level map. 
       ground_default is the tile type to return if the tile_ref is below the bottom of the level. 
       sky_default is the tile type to return if the tile_ref is above, to the left of, or to the right of the bounds of
       the level.""" # #           sky     #           default #         +--------+ # sky     | level  | sky # default |        | default #    - - -+--------+- - - #           ground  #           default # # return default 'ground' tile if reference is off the bottom of the level # look up tile type in nested level list if reference is inside bounds of level # otherwise reference is above, left of or right of the level bounds. return default 'sky' tile
tile_ref
level
ground_default
sky_default