Quantcast
Channel: Questions in topic: "endless"
Viewing all articles
Browse latest Browse all 123

Best way to store large list

$
0
0
Hi everyone, I'm working on a endless map generator and I don't know the best way to store large amount of data. First, my (simplified) world is chunked (because it's endless) and handled in 3 levels: - **World**: Largest chunks (10000x10000) - **Region**: Sub-world chunks (1000x1000) (So every World Chunk contain an array of [10x10] region Chunks) - **Details**: Sub-region chunks (100x100) (Same here, Region Chunk contain an array of [10x10] details) `public enum ChunkLevel:int {World=1, Region=2, Detail=3}` I load only chunks who need to be displayed on screen, but I must load every parent-chunks to get high-levels informations (in-game restriction). I'm a web-developer and I don't really know what's the best choices to store all ChunkData classes into my Generator. I came with 2 ideas: **A Dictionary of Dictionary** My first way was to store every same-level chunks on a `Dictionary`, and list all level on an other Dictionary: `Dictionary>` That way, I can easily get /set the ChunkData object but i'm concern about the size of the Detail Dictionary. If the game go long, it will be hudge ! And a lots of request'll search on it.. // Simple Chunk Data Class public class ChunkData { public Coord coord; public ChunkData(Coord _coord, ChunkLevel _chunkLevel) { this.coord = _coord; /* ... */ } } // MapGenerator public class mapGenerator: MonoBehaviour { // Chunks Dictionary> chunks = new Dictionary>(); } // Example : mapGenerator.chunks[ChunkLevel.Detail][coord] **Dictionary of World containing Array of child** Another way to do it is just to store into my Generator a `Dictionary` for World (higher parent), and add an array on it with (in this case) 100 chunks for child. It will be harder to get data (starting everytime on world and going through children to find the good ChunkData) but every avoid large Dictionary. // New ChunkData public class ChunkData { public Coord coord; public ChunkData[] children; public ChunkData(Coord _coord, ChunkLevel _chunkLevel) { this.coord = _coord; this.children = new ChunkData[100]; // This will create a big array even if I never call this.children[x] = new ChunkData() ??? } } // MapGenerator public class mapGenerator: MonoBehaviour { // World Chunks only Dictionary> worldChunks = new Dictionary(); } // Example : mapGenerator.worldChunks [coord][regionInWorldCoord][detailInregionCoord] Thank everyone for reading/taking time.

Viewing all articles
Browse latest Browse all 123

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>