Git Product home page Git Product logo

Comments (12)

mxgmn avatar mxgmn commented on April 29, 2024 1

@tomprogrammer Nice change for foundation, but it's almost always -1 anyways, and if your sample has flower roots near (0, SMY - 1), then this method won't work. So I'll leave it as it is.

from wavefunctioncollapse.

nanodeath avatar nanodeath commented on April 29, 2024

I'm not really sure what the full ramifications of this are, BUT appending .OrderBy(x => x) to Keys still seems to work, and doing the equivalent enables the Kotlin/JVM version to function as well. You don't have to do this, but the order should be well-defined one way or another.


Update: correction, it always works for some of them (like City), but not for others (like Flowers). With this change, Flowers always yields CONTRADICTION in both this repo and my Kotlin version. So blindly sorting is apparently not the solution 😸

from wavefunctioncollapse.

nanodeath avatar nanodeath commented on April 29, 2024

Yeah pretty sure messing with the weights order also messes up the foundation index value. The output of Platform looks messed up (almost as if there's no foundation set at all; multiple strata instead of just the one), and as semi-mentioned before, the given foundation value doesn't work for Flowers anymore.

from wavefunctioncollapse.

nanodeath avatar nanodeath commented on April 29, 2024

Sorry for all the updates, but on the JVM side, using LinkedHashMap (which preserves insertion order as iteration order) to store the weights seemed to do the trick -- foundation is working and all the samples are working. I tried switching your C# version over to OrderedDictionary, but frankly was having some trouble getting the thing to cooperate, due to using integers as keys (it has an Item[Int32] method in addition to Item[Object] -- go figure).


Update: OrderedDictionary works fine if you cast all your lookup indexes to object to force it to use Item[Object], i.e.

if (weights.Contains(ind)) weights[(object)ind] = (int)weights[(object)ind] + 1;
else weights.Add(ind, 1);

Granted, it's quite the eyesore, but it works and I'm not sure there's another way while using the (non-generic) OrderedDictionary.

from wavefunctioncollapse.

nanodeath avatar nanodeath commented on April 29, 2024

I think this is a pretty serious issue, so I'll send a pull request your way tonight. I'll try to wrap the OrderedDictionary ugliness in extension methods so as not to pollute the code.

from wavefunctioncollapse.

tomprogrammer avatar tomprogrammer commented on April 29, 2024

The C# code actually returns the patterns and stationary weights in a deterministic order (on Mono Stable 4.6.1.3/abb06f1, LLVM disabled).

I discovered, that the foundation pattern just describes the bottom boundary.
Examples from the C# code:

City:   Flowers:   Platformer:   Platformer:
4 4 4    3 3 3         3 3          3 3 3
0 0 0    0 0 0         0 0          0 0 0
0 0 0    0 0 0                      0 0 0

I use that to calculate the pattern from the sample using the coordinates (0, SMY - 1) and finding the index of this pattern in the pattern/stationary list. This keeps the implementation details (the indices) internal to OverlappingModel and frees the caller from supplying the correct foundation value.

from wavefunctioncollapse.

nanodeath avatar nanodeath commented on April 29, 2024

Yes, "foundation" as in, the bottom. It's been renamed to "ground" just today, actually, which is a bit clearer.

And that's a good idea -- you're passing in the coordinates that you want to be the ground, and then this gets mapped back into the index transparently, right? For completeness, you might also allow the caller to provide reflection and rotation information, symmetry-providing.


It's still iterating over keys of an unsorted dictionary and inserting them into an array -- that that works with any amount of predictability is a bit miraculous. So this still needs to be fixed πŸ˜…

from wavefunctioncollapse.

mxgmn avatar mxgmn commented on April 29, 2024

@nanodeath Somehow I always assumed that foreach for dict.Keys goes through it in the order of filling, and it has always worked. But yeah, it's risky. I can change it to List<Tuple<int, int>>, or you already prepared a PR?

from wavefunctioncollapse.

nanodeath avatar nanodeath commented on April 29, 2024

I still think OrderedDictionary might be better -- if it's a list, you have to scan through it a lot to see if that subimage has already been detected. On the other hand, OrderedDictionary's API is pretty rough πŸ˜‰

I haven't started on a PR, but I was just about to. I can hold off if you'd rather do it yourself.

from wavefunctioncollapse.

mxgmn avatar mxgmn commented on April 29, 2024

@nanodeath Yeah, I'll do it. I prefer sticking to basic data types when possible.

from wavefunctioncollapse.

mxgmn avatar mxgmn commented on April 29, 2024

@nanodeath There was a simpler solution =).

from wavefunctioncollapse.

nanodeath avatar nanodeath commented on April 29, 2024

@mxgmn Ah, glad to hear it.

from wavefunctioncollapse.

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.