I'm doing a RogueLike game with Python and I use a DungeonGenerator.py. In my game I read the dungeons from a .txt file.
The problem is I can't write the dungeon I make with the DungeonGenerator.py on a .txt file because is a matrix of strings.
This is an example of the result of DungeonGenerator.py:
I try with:
return tiles
file = open ("Dungeon.txt", "w")
file.write(tiles)
file.close()
Obiously tiles isn't a string.
Thanks in advice!
What you want to do is called object serialization.
The pickle module should work just fine for you.