# Roguelike Map Structure [duplicate]

I'm working on a roguelike and would like to know how to structure my map data. I suppose this question could also be extended to any sort of top down 2d game. Anyways! My game will contain object types like terrain, doors, switches, monsters, and items. How should the objects be stored within a map?

Some ideas I've gathered online:

1. The map is a 2d array. Each cell in the array can store multiple references to objects occupying it.
2. The map contains several layers of 2d arrays, and each layer stores references to objects of a specific type.
3. Like 1. but only store static terrain information in the 2d array. The rest of the objects are dynamic and stored in lists for each type.
• It sounds like you already know how to make a tilemap. There is not really a definitive answer, it's up to you how you want to build the map. – Lasse Nov 14 '13 at 19:26
• – MichaelHouse Nov 14 '13 at 19:31
• Any of the three approaches is valid. Which one will work best for you depends on how objects in the same cell interact with each other and with the terrain. – Philipp Nov 14 '13 at 22:31

The only thing you need for objects in the map is a fast way to query "give me everything at position (X,Y). Using some kind of map/dictionary/table works perfectly.