-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Generate random tiles from a seed #3818
Comments
I'm not so sure "seeding" would accomplish what you're looking for - seeds set the initial condition, but the output can still vary if the inputs are different or are processed in a slightly different order. You can already accomplish this style of random generation by having rules that will randomly replace rocks with other rocks, etc, and some "initial" rules that will only generate random rocks on non-rock tiles if the input is clean (so you'd need to differentiate between Automapping output used as input and manual input - for example, you could use the untransformed solid green tile as your manual grass input, and have Automapping always output that solid green tile flipped - looks identical, but is distinct). |
Just to add a little more context—this is actually how LDtk works by default. You don't set the seed value explicitly, it's chosen for you. But you can click a "randomize" button to automatically pick a new seed and re-shuffle everything. I know the way it handles tile generation is a little different in general, but there's certainly at least a couple different ways that random values can be made to be deterministic for a given x and y coordinate. A table could be pre-generated with random values for each coordinate, then when a random number is needed to make a decision for that tile, just index the table. Alternatively, a seed could be hashed together with the tile coordinates (maybe the layer ID too), then the resulting hash could be used as the real seed to generate a random value for that tile. Evaluation order wouldn't necessarily matter in either of these solutions. I can probably use the tile flipping solution as workaround for now. I've also considered creating a layer with random noise and using that as another input. But to me it just seems intuitive that automapping would always yield the same output for a given input. And I think map designers might appreciate having the output feel more predictable while they're actively iterating and working on it, rather than feeling like it's a moving target unless they come up with a custom solution. |
Automapping's "tool" for deterministic output is to not randomise the output in the first place, or to randomise it within a narrow range xP Between the modulo options and specialised inputs (such as the flipped tile workaround, noise/guide layers, and any other context), I think non-random variation is already pretty easy to achieve, and in a manner much more controllable than seeding would be. Another technique you may want to consider is to output to a separate output layer, and to only output tiles to empty cells (i.e. have an input_outputLayer checking for Empty). So, automapping a map once would fill that output layer, and Automapping again would not change anything. If you want to reroll some tiles, you'd erase the parts you want to change from the output later and Automap again. All that said, looking at your example GIF, I'm a little confused as to how you expect seeding to work, and maybe I just don't understand what you're trying to do. Are you aiming to seed the output of a rule (in which case, the rocks would never change at all), or whether a rule runs at all (in which case, the positions in which rules run would be locked, but the output would be random each time)? Seeding the rule probability does sound pretty interesting, and it's not something that can be conveniently achieved by existing mechanisms. |
Ah, I see! I misinterpreted your request, I thought the GIF was an example of what you were trying to do, not a demonstration of the existing undesirable behaviour. So, I was describing approaches for the wrong goal xP |
Is your feature request related to a problem? Please describe.
It would be great if randomly generated tiles didn't completely reshuffle whenever automapping rules are reapplied. For example, once I get the distribution of rocks and flower tiles more or less where I want them, I might want them to regenerate in the same locations, even as I continue to work on the level and add new rules and new rule maps.
Describe the solution you'd like
A custom property that can be added to a layer that allows the user to supply a seed to the random number generator so that it generates the same series of random values every time. If the property is omitted, current behavior is preserved.
Ideally, the same random value would be generated for a given index in the grid whether the user applies the automap rules all at once or uses the brush with automap while drawing enabled.
Describe alternatives you've considered
The Automap While Drawing feature partially solves this, as I can draw over new areas while keeping old areas in place. But there are still scenarios where I might need to reapply the entire map at once; like if I add several new complex rules or new rule maps. Additionally, if I have the automap radius property set while using the brush, I may end up accidentally reshuffling the rocks and grass in the vicinity, when I only meant to add a couple new tiles.
Another workaround is that I could output each terrain type to a different layer, and lock the layers that have random variations. But this adds a lot of complexity and forces me to use a lot of layers and/or separate tiles with random variants onto different layers from those that don't.
Edit: The gif below is just to demonstrate how the random distribution of tiles changes whenever I hit cmd+M
The text was updated successfully, but these errors were encountered: