def find_water_flow(self, world, water_path):
        """Find the flow direction for each cell in heightmap"""

        # iterate through each cell
        for x in range(world.width - 1):
            for y in range(world.height - 1):
                # search around cell for a direction
                path = self.find_quick_path([x, y], world)
                if path:
                    tx, ty = path
                    flow_dir = [tx - x, ty - y]
                    key = 0
                    for direction in DIR_NEIGHBORS_CENTER:
                        if direction == flow_dir:
                            water_path[y, x] = key
                        key += 1
def find_water_flow ( self , world , water_path ) : for x in range ( world . width - 1 ) : for y in range ( world . height - 1 ) : path = self . find_quick_path ( [ x , y ] , world ) if path : tx , ty = path flow_dir = [ tx - x , ty - y ] key = 0 for direction in DIR_NEIGHBORS_CENTER : if direction == flow_dir : water_path [ y , x ] = key key += 1
Find the flow direction for each cell in heightmap