Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] is it possible to provide a pre-populated target image somehow? #3

Open
TLINDEN opened this issue Apr 22, 2024 · 4 comments

Comments

@TLINDEN
Copy link

TLINDEN commented Apr 22, 2024

In many examples on YT it is suggested to do this in order to force a certain structure. For example one could pre-populate a target image with floor tiles to mark a walkable way or where a certain room shall be.

Is that possible?

Oh, and while I'm at it: the library returns an image. However, in order to use this in a game I don't really need an image but a 2d map of tile types (e.g. walkable, walls/water/holes etc). So it would be required to pass in a list of tile properties along with the initial tileset to the function, which it keeps per every placed tile. Does that make sense?

thanks in advance,
Tom

@TLINDEN
Copy link
Author

TLINDEN commented Apr 22, 2024

Update: to show what I mean: This is what I'd need:

tilemap

So, I need (in this case) closed room[s]. Rooms maybe connected but if they are not, it's fine as well because in my game I have portals.

However, this is what I get currently:

1713800998972048693

1713800997667559958

1713800888055180949

How can I solve this?

TLINDEN pushed a commit to TLINDEN/go-wfc that referenced this issue Apr 23, 2024
@TLINDEN
Copy link
Author

TLINDEN commented Apr 23, 2024

So, I tried adding the feature myself, which might be a good opportunity to get deeper into WFC, see TLINDEN@c75a953

However, it's not working yet. I assume I got the slot population wrong somehow?

With this pre-populated output map:
default

And using this example I get:
1713873040680044960

:(

@TLINDEN
Copy link
Author

TLINDEN commented Apr 23, 2024

Ok, I compared the wave.PossibilitySpace contents after one successful example (examples/islands/) with the content of the pre-populated one:

  • Each pre-populated slot has 1 module
  • all 4 Adjacency checksums of those slots have the same value (since I pre-populated it with only water tiles)
  • all non-pre-populated slots have all 16 modules

I also added a dump function. With the unaltered island example I get this PossibilitySpace on startup: island startup and this one when done. In comparision, I get this space on startup with the island-pre example (which uses pre-population) and this result, which is clearly incomplete.

I really don't get it why it's not working.

Any idea? (example: https://github.com/TLINDEN/go-wfc/tree/main/examples/islands-pre)

@TLINDEN
Copy link
Author

TLINDEN commented Apr 26, 2024

Ah, there's the problem: I prepopulate wave.PossibilitySpace with the slots of the setup image. But I set all other slots to any, including the ones neighboring the prepopulated ones. And the loop doesn't look at the prepopulated slots, because they have entropy 1. So, I think, their neighbors do not get a chance to get propagated properly. So in order to get a correct starting map, the propagation needs to run over the whole map once before the actual collapse loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant