Search code examples
objective-cdata-structuresroguelike

Data structure for roguelike map


I need a data structure for map in rogue like game

Each cell should contain array of objects. Map will have big dimensions, but contents of cell with specified coordinates should be accessible very fast. Map should be partially serializable (2kx4k map, I want to read only tiles from (3,4) to (40,20)).

Best option I have now is NSMutableDictionary with coords as keys and NSMutableSets as filler of non-empty cells. But I'm not sure about speed of very frequent operation: reading from this map portion of cells for drawing to screen. May be I should store pointers for neighborhood cells in each cell?

Target platform - Objective-C/iOS/Cocos2d

Is there any solutions on Objective-C (or may be even libraries for Cocos2d framework) about that?


Solution

  • I would not have 1 big map of 2k*4k, those dimensions are too big for mobile. Just define 'portals' between different maps that point to each other.

    As for the data structure, even full time roguelike developers are not sure, this discussion should shed some light:link to google groups r.g.r.d