Marching squares is a computer graphics algorithm that generates contours for a two-dimensional scalar field (rectangular array of individual numerical values).It is used in cave generation .The algorihm is implemented using python and matplotlib library
-wiki
def get_coord(char,i,j):
function takes a char as an input,along with the x and y coordinate of bottom left corner.All the different cases of lookup table contour lines can be made by selection of 6 lines.these lines are denoted by char which is passed in get_coord function. These are-