Moved the main loop into def main()
More importantly I got rid of the clunky list comprehensions, replacing them with much more readable definitions. In the process I changed how cell_values are set and read, making them much better to work with.
Rather than tuples of (x,y,value) they are now list[y][x] = value