Refactored generate_map. Instead of a monolith, it's a series of components, making it friendlier for interactive use.