Java: What is a good data structure for storing a coordinate map for an infinite game world?

前端 未结 11 1340
心在旅途
心在旅途 2020-12-23 11:35

I am used to coding in PHP but I am not really proficient with Java and this has been a problem for some time now. I expect it to be a fairly easy solution, however I cannot

11条回答
  •  难免孤独
    2020-12-23 12:02

    I wrote a couple of experimental spare data structures in Java that you might be interested in.

    The most interesting one was the Octreap which is what I believe is a completely novel cross between a Treap and an Octree, which had the following features:

    • 60 bit world co-ordinates (aprox 1,000,000 * 1,000,000 * 1,000,000 grid)
    • Negative co-ordinates supported
    • Empty space requires no storage (supports highly sparse worlds)
    • Compresses volumes of identical cells (e.g. large blocks of the same material would get stored efficiently)
    • O(log n) for reads and writes

提交回复
热议问题