-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Itertools like class in gdscript - to aid procedural generation #9264
Comments
Looking at itertools, this is how the product function there looks like:
|
For the record, I came up with a solution to this in godot, but it is kind of ugly. Another users suggested a better solution, but it is still quite a long function. In any case, it would be awesome if somebody implements this in c++ as a built in function in godot. I hope that these code snipets help |
Another solution:
|
Woudnt it be great to have a built in function- to help with procedural
generation :D
Thank you for sharing these great examples btw. I came up with a solution
last week, but ended up with using one of the suggested ones instead of
mine, because the code was slightly cleaner
On 28 Jun 2017 10:08, "hubbyist" <notifications@github.com> wrote:
Another option:
extends SceneTree
func _init():
var a = ['a1','a2','a3']
var b = ['b1','b2']
var c = ['c1','c2','c3']
var d = ['d1','d2','d3']
var arrays = [a,b,c,d]
print(arrays)
for combination in array_combinations(arrays):
print(combination)
quit()
func array_combinations(arrays):
var combinations = []
var first = arrays.front()
arrays.pop_front()
for item in first:
combinations.push_back([item])
for array in arrays:
var products = [];
for item in array:
for combination in combinations:
var product = combination + [item]
products.push_back(product)
combinations = products;
return combinations
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#9264 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGMbVa7MNTfQoic8FAZwuuv6mYbZVPC3ks5sIhf0gaJpZM4N9-rX>
.
|
First of all thank you for your report and sorry for the delay. We released Godot 3.0 in January 2018 after 18 months of work, fixing many old issues either directly, or by obsoleting/replacing the features they were referring to. We still have hundreds of issues whose relevance/reproducibility needs to be checked against the current stable version, and that's where you can help us. For bug reports, please also make sure that the issue contains detailed steps to reproduce the bug and, if possible, a zipped project that can be used to reproduce it right away. This greatly speeds up debugging and bugfixing tasks for our contributors. Our Bugsquad will review this issue more in-depth in 15 days, and potentially close it if its relevance could not be confirmed. Thanks in advance. Note: This message is being copy-pasted to many "stale" issues (90+ days without activity). It might happen that it is not meaningful for this specific issue or appears oblivious of the issue's context, if so please comment to notify the Bugsquad about it. |
As there was no update since the previous post, we close this issue. If it is still relevant in the way it was described and discussed above, please comment to ask for it to be reevaluated. If it is only partly relevant, or if the original issue has changed, it would be better to open a new issue (potentially referring to this one) focused on the current state. |
I believe this is still relevant, reopen? |
This proposal was discussed a lot a few months ago, as it had slipped into our ideas list for the Google Summer of Code. After much discussion, we could not really see a lot of use cases that would warrant integrating it directly in GDScript, so we removed it from our ideas list. We try to keep GDScript as simple as possible, which means cutting on "sometimes useful" features to focus on what is really needed. Since this can't satisfy everyone of course, the best approach would be to implement such features as a GDScript or GDNative plugin, and usage will speak for itself. If many users use such plugin extensively in their games, then it might be considered to be included in the core for convenience. |
Is it possible that a class with custom iterators would work for this usecase? (I know this issue is closed, this is mostly for people in the future looking for iterator-related solutions) |
curious about this too, anyway to use custom iterators to do number permutations |
Or I'll just use a decent programming language with a broad range of libraries ;) |
Please don't comment on old issues if you don't have anything constructive to add. |
Basically I stumbled on an issue that requires me to return an array that holds all possible combinations of a sequence.
I filed it as a question here:
https://godotengine.org/qa/15813/function-that-returns-all-possible-combinations-sequence
That functionality is available in python - as a module called itertools.
Trying to write a function that does what I want in gdscript is proving to be dificult without the product itertools module.
Doing that in python would be as simple as:
That module would be incredibly useful when you want to automatically generate enemies with different types of armor for example - as it can create an array with all possible combinations of boots + helmets + chest for example
In my case, I am very close to writing a tool for godot that can aid artists and my tool needs that functionality. But I can see this being useful for games too
The text was updated successfully, but these errors were encountered: