Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ArthyShow · Oct 25, 2017 at 05:12 PM · storagechunksmap-generationendless

Best way to store large list

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<Coord, ChunkData>, and list all level on an other Dictionary: Dictionary<ChunkLevel, Dictionary<Coord, ChunkData>>

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<ChunkLevel, Dictionary<Coord, ChunkData>> chunks = new Dictionary<ChunkLevel, Dictionary<Coord, ChunkData>>();
 }
 // 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<Coord, ChunkData> 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<Coord, ChunkData>> worldChunks = new Dictionary<Coord, ChunkData>();
 }
 // Example : mapGenerator.worldChunks [coord][regionInWorldCoord][detailInregionCoord]

Thank everyone for reading/taking time.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

71 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Tilemap Per Chunk? 0 Answers

Data Storage Access 0 Answers

Fastest way to store huge amounts of data? 2 Answers

Storing and Accessing Abilities 2 Answers

chest items get added to inventory 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges