Git Product home page Git Product logo

Comments (5)

Yaru2585 avatar Yaru2585 commented on June 15, 2024 1

Indeed, that does solve it!
Thank you very much for helping and for all your work on the generator!

from edgar-dotnet.

OndrejNepozitek avatar OndrejNepozitek commented on June 15, 2024

Unfortunately, there are situations where not all preconditions are checked and the algorithm ends up throwing a generic exception only after something goes wrong (there's an issue created to improve this).

From what I can see from your code, I'd say that there is a problem with your definition of the corridor room. You create a 1x1 square and then use the new OverlapMode(1, 1) door mode. By using that door mode, you tell the algorithm that you want all doors to be at least one "tile" from corners of the room shape. And as you use 1x1 square, there are no door positions that match your requirements. I'd suggest you to try using var corridor = new RoomDescription(GridPolygon.GetSquare(1), new OverlapMode(1, 0)); (note the 0 instead of 1). It will allow 4 door positions for that corridor room and should solve the issue.

This is absolutely something that should be handled by an exception with some useful message.

from edgar-dotnet.

Yaru2585 avatar Yaru2585 commented on June 15, 2024

Thank you for the quick response! Alas, the problem persists: I've tried setting the Overlapmode to (1,0), and to remove the corridors and change the generator to a LayoutGeneratorFactory.GetDefaultChainBasedGenerator<int>(), and even just copypasting the example shown here but it keeps throwing a NullReferenceException on the same line.

from edgar-dotnet.

OndrejNepozitek avatar OndrejNepozitek commented on June 15, 2024

I think that I've found the problem. When implementing the library, it took some time to solve all the big bugs in the core of the algorithm. And as the algorithm is stochastic, it sometimes happened that a bug showed up only when you were quite unlucky. To fix such bugs, you have to fix the seed of the random numbers generator so that you always get the same result and can debug the issue. So to prevent me from accidentally not setting the correct seed for the generator, I removed the default instance of the random generator. And that's exactly the problem you're encountering - a missing instance of the Random class.

I uploaded a newer version of the binaries that should have this issued fixed. But before downloading the newer version, please try a quick manual fix to make sure that it was the only problem. Before running the layout generator, please inject the random numbers generator like this:

layoutGenerator.InjectRandomGenerator(new Random());

from edgar-dotnet.

OndrejNepozitek avatar OndrejNepozitek commented on June 15, 2024

I'm glad that it worked! If you have any problems in the future, feel free to open another issue.

I'd also love to get any feedback on the library - either on the features of the algorithm or how usable it's for a programmer. So if you find anything that you feel is not very intuitive or if you miss a feature, just please let me know. There are quite a few places that I already know are not perfect, but it'd be great to hear from other people, too.

from edgar-dotnet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.