Jump to content

Preventing Cascading Worldgen with Large, Randomized Structures


TheXFactor117

Recommended Posts

In one of my projects, I have a simple procedurally generating dungeon algorithm which generates the mod's dungeons. I've recently decided to rewrite to be more complex and accommodate more features than before. Before I do this though, I wanted to generate it in a way that it won't cause cascading world generation, which the current algorithm doesn't prevent. Right now it works kind of like this: I'll generate a structure on the surface somewhere, which will spawn staircases underneath it. From there, rooms can branch off of these staircases, and each room can generate new rooms off of it and so on until it reaches the maximum amount of "tries". This is done through recursion which is simple enough to do.

 

So I've been trying to come up with a way to prevent the cascading generation from happening because it's not as simple as just adding an offset. I won't know how many chunks the dungeon will take up until after I generate it. I'm wondering about what the easiest solution to this would be. Could I generate all of the parts of the structure that are in loaded chunks only and then generate the others once those chunks have been loaded? I think that's the fundamental solution but how would you go about knowing/storing where a structure should be, and then generating that structure when the chunk is loaded? Maybe this isn't entirely right and there is another way around it, I'm not sure. Anyways, any help on solving this issue would be much appreciated.

Developer of Levels and Lost Eclipse

Link to comment
Share on other sites

In theory, when an event is fired to which your generator is subscribed to, you should be able to get chunk's X an Y. Then while you generate the structure, you have to continuously check whether the next generated block will trigger generation of new chunk. If the blockpos is within current chunk, proceed generation; if not, then store this blockpos and maybe chunkpos in a map, perhaps. Then on next event you check whether the new chunkpos corresponds to any of the stored chunk positions and proceed generation if it does.

You can also find a way to track current chunkpos of player and based on it, pick chunks from the loaded ones and do your thing more safely - still, will have to start checking once the chunk positions are close to the border.

Link to comment
Share on other sites

3 hours ago, Alexiy said:

In theory, when an event is fired to which your generator is subscribed to, you should be able to get chunk's X an Y. Then while you generate the structure, you have to continuously check whether the next generated block will trigger generation of new chunk.

Actually....

You want [inside the current chunk] + (8,8)

Due to the way Minecraft generates chunks, you want to always offset by 8 blocks in the positive X and positive Z directions. The next chunk in that direction are guaranteed to already exist. 

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I don't think that's the best solution, at least in terms of what I'm trying to do.

 

I've been digging around in vanilla world generation (Stronghold/Village generation) to figure out how they generate structures without causing runaway chunk generation. It looks like vanilla generation (say a Stronghold) will generate the positions of the Stronghold and store them somehow (MapGenStronghold#generatePositions looks like it does this, but I don't see how this works fully). Somehow the Stronghold's StructureStart gets a list of components to be generated and builds them out. Anyways, I think my conclusion is vanilla world generation is a mess and is hard to trace and track down how everything works.

 

As for how to fix this, I'm thinking the easiest thing is to generate a "virtual" dungeon through the algorithm, but not to build anything during this time and storing each structure in a map. Then I would generate it when chunks are loaded and everything is ok for it to generate. The problem is, how would I go about generating it this way? Is it even possible?

Developer of Levels and Lost Eclipse

Link to comment
Share on other sites

Potential solution: When I go to generate the dungeon, instead of building each individual room during generation, I'm thinking I can just generate the positions of each individual structure and store the position and template into a map. If the bounding box of the structure intersects with the current chunk (which has an offset), generate the corresponding room. If it's outside of the currently generated chunks, it won't generate. As new chunks are generated through the WorldGenerator, I'm thinking about looping through all the pending structures, checking to see if the bounding box of the structure intersects with the current chunk and if it does, generate it and remove it from the map.

 

I'm not sure if this will work properly, so if anyone happens to find a flaw in it, I'd like to hear it before I try and implement it. If it sounds good, I'll work on implementing it.

Developer of Levels and Lost Eclipse

Link to comment
Share on other sites

7 hours ago, Alexiy said:

Have you looked at mineshaft code? Might give some hints, too.

It's kind of difficult to abstractly imagine how your algorithm would work, so just do it and we'll see how it goes.

Well it is pretty easy actually. You do everything the algorithm normally would but you don't place any blocks and you store the position and individual structure into a map or whatever. Whenever new chunks are generated, you check to see if your positions of the structures are in it and you generate if so.

 

Seems to make since to me, so I'll try and implement this soon.

 

I think Minecraft does this by checking if a given structure is inside of the bounding box of the chunk, and if so, it generates. So that's the kinda check you would need.

Edited by TheXFactor117

Developer of Levels and Lost Eclipse

Link to comment
Share on other sites

If you don't mind having your world depend on the order of player exploration, then you could limit your code to generating only one complex at any given time (e.g. use a static field in one of your classes as a latch). Initialize it to "ready",  then check it before starting one of these structures. if "busy", then exit without starting a new complex. If "ready", then set it to "busy" and commence generation. Do the whole structure, loading as many chunks as it needs; any further would-be structures triggered would be suppressed by the field being set to "busy". When done, clear the field back to "ready".

 

Of course, if you're willing to do the work to map overlapping structures, then that's probably better (and repeatable).

 

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Slot Gacor >> Mudah Maxwin Bersama Djarum4D   Slot gacor adalah salah satu jenis permainan judi online yang sangat populer di Indonesia. Bermain slot gacor berarti bermain permainan slot dengan kemungkinan keluaran yang lebih tinggi daripada slot tradisional. Dalam artikel ini, kami akan membahas secara lengkap tentang slot gacor, mulai dari pengertian dasar, cara bermain, strategi pemain, serta aspek keamanan dan etika dalam bermain.
    • DAFTAR & LOGIN TAYO4D   Slot gacor online adalah permainan yang menarik dan menghasilkan keuntungan untuk banyak pemain di seluruh dunia. Dalam artikel ini, kita akan membahas tentang cara memilih dan memainkan slot gacor online terbaik.
    • Tayo4D : Bandar Online Togel Dan Slot Terbesar Di Indonesia     Pemain taruhan Tayo4D yang berkualitas memerlukan platform yang aman, terpercaya, dan mudah digunakan. Dalam era teknologi ini, banyak situs online yang menawarkan layanan taruhan togel 4D, tetapi memilih yang tepat menjadi tuntas. Berikut adalah cara untuk membuat artikel yang membahas tentang situs online terpercaya untuk permainan taruhan togel 4D.  
    • OLXTOTO: Platform Maxwin dan Gacor Terbesar Sepanjang Masa OLXTOTO telah menetapkan standar baru dalam dunia perjudian dengan menjadi platform terbesar untuk pengalaman gaming yang penuh kemenangan dan kegacoran, sepanjang masa. Dengan fokus yang kuat pada menyediakan permainan yang menghadirkan kesenangan tanpa batas dan peluang kemenangan besar, OLXTOTO telah menjadi pilihan utama bagi para pencinta judi berani di Indonesia. Maxwin: Mengejar Kemenangan Terbesar Maxwin bukan sekadar kata-kata kosong di OLXTOTO. Ini adalah konsep yang ditanamkan dalam setiap aspek permainan yang mereka tawarkan. Dari permainan slot yang menghadirkan jackpot besar hingga berbagai opsi permainan togel dengan hadiah fantastis, para pemain dapat memperoleh peluang nyata untuk mencapai kemenangan terbesar dalam setiap taruhan yang mereka lakukan. OLXTOTO tidak hanya menawarkan kesempatan untuk menang, tetapi juga menjadi wadah bagi para pemain untuk meraih impian mereka dalam perjudian yang berani. Gacor: Keberuntungan yang Tak Tertandingi Keberuntungan seringkali menjadi faktor penting dalam perjudian, dan OLXTOTO memahami betul akan hal ini. Dengan berbagai strategi dan analisis yang disediakan, pemain dapat menemukan peluang gacor yang tidak tertandingi dalam setiap taruhan. Dari hasil togel yang tepat hingga putaran slot yang menguntungkan, OLXTOTO memastikan bahwa setiap taruhan memiliki potensi untuk menjadi momen yang mengubah hidup. Inovasi dan Kualitas Tanpa Batas Tidak puas dengan prestasi masa lalu, OLXTOTO terus berinovasi untuk memberikan pengalaman gaming terbaik kepada para pengguna. Dengan menggabungkan teknologi terbaru dengan desain yang ramah pengguna, platform ini menyajikan antarmuka yang mudah digunakan tanpa mengorbankan kualitas. Setiap pembaruan dan peningkatan dilakukan dengan tujuan tunggal: memberikan pengalaman gaming yang tanpa kompromi kepada setiap pengguna. Komitmen Terhadap Kepuasan Pelanggan Di balik kesuksesan OLXTOTO adalah komitmen mereka terhadap kepuasan pelanggan. Tim dukungan pelanggan yang profesional siap membantu para pemain dalam setiap langkah perjalanan gaming mereka. Dari pertanyaan teknis hingga bantuan dengan transaksi keuangan, OLXTOTO selalu siap memberikan pelayanan terbaik kepada para pengguna mereka. Penutup: Mengukir Sejarah dalam Dunia Perjudian Daring OLXTOTO bukan sekadar platform perjudian berani biasa. Ini adalah ikon dalam dunia perjudian daring Indonesia, sebuah destinasi yang menyatukan kemenangan dan keberuntungan dalam satu tempat yang mengasyikkan. Dengan komitmen mereka terhadap kualitas, inovasi, dan kepuasan pelanggan, OLXTOTO terus mengukir sejarah dalam perjudian dunia berani, menjadi nama yang tak terpisahkan dari pengalaman gaming terbaik. Bersiaplah untuk mengalami sensasi kemenangan terbesar dan keberuntungan tak terduga di OLXTOTO - platform maxwin dan gacor terbesar sepanjang masa.
    • OLXTOTO - Bandar Togel Online Dan Slot Terbesar Di Indonesia OLXTOTO telah lama dikenal sebagai salah satu bandar online terkemuka di Indonesia, terutama dalam pasar togel dan slot. Dengan reputasi yang solid dan pengalaman bertahun-tahun, OLXTOTO menawarkan platform yang aman dan andal bagi para penggemar perjudian daring. DAFTAR OLXTOTO DISINI DAFTAR OLXTOTO DISINI DAFTAR OLXTOTO DISINI Beragam Permainan Togel Sebagai bandar online terbesar di Indonesia, OLXTOTO menawarkan berbagai macam permainan togel. Mulai dari togel Singapura, togel Hongkong, hingga togel Sidney, pemain memiliki banyak pilihan untuk mencoba keberuntungan mereka. Dengan sistem yang transparan dan hasil yang adil, OLXTOTO memastikan bahwa setiap taruhan diproses dengan cepat dan tanpa keadaan. Slot Online Berkualitas Selain togel, OLXTOTO juga menawarkan berbagai permainan slot online yang menarik. Dari slot klasik hingga slot video modern, pemain dapat menemukan berbagai opsi permainan yang sesuai dengan preferensi mereka. Dengan grafis yang memukau dan fitur bonus yang menggiurkan, pengalaman bermain slot di OLXTOTO tidak akan pernah membosankan. Keamanan dan Kepuasan Pelanggan Terjamin Keamanan dan kepuasan pelanggan merupakan prioritas utama di OLXTOTO. Mereka menggunakan teknologi enkripsi terbaru untuk melindungi data pribadi dan keuangan para pemain. Tim dukungan pelanggan yang ramah dan responsif siap membantu pemain dengan setiap pertanyaan atau masalah yang mereka hadapi. Promosi dan Bonus Menarik OLXTOTO sering menawarkan promosi dan bonus menarik kepada para pemainnya. Mulai dari bonus selamat datang hingga bonus deposit, pemain memiliki kesempatan untuk meningkatkan kemenangan mereka dengan memanfaatkan berbagai penawaran yang tersedia. Penutup Dengan reputasi yang solid, beragam permainan berkualitas, dan komitmen terhadap keamanan dan kepuasan pelanggan, OLXTOTO tetap menjadi salah satu pilihan utama bagi para pecinta judi online di Indonesia. Jika Anda mencari pengalaman berjudi yang menyenangkan dan terpercaya, OLXTOTO layak dipertimbangkan.
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.