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

Randomness and Cmd interaction #4

Closed
lemunozm opened this issue Sep 4, 2019 · 2 comments
Closed

Randomness and Cmd interaction #4

lemunozm opened this issue Sep 4, 2019 · 2 comments

Comments

@lemunozm
Copy link

@lemunozm lemunozm commented Sep 4, 2019

Hi! First of all, I love the idea of this repo, and I am using to learn elm :D

I am having problems getting randomness into my "game". I think that the problem is that game function doesn't allow me to modify the returned Cmd of the update function (this line), required in order to generate a random value.

Am I getting something wrong? Is there any workaround to getting access to the Cmd?

Thank you!

@evancz

This comment has been minimized.

Copy link
Owner

@evancz evancz commented Sep 5, 2019

That is exciting to hear! 😊

What are you wanting to use randomness for specifically? That can help a lot in designing features in the future.

For now, there is not a way to add randomness with the Random module. I wanted to keep it really minimal, and that API is pretty fancy for what I was going for here.

If I wanted to spawn spaceships at some unknown x coordinates, I would probably do something like cos (spin 0.1 time) whenever I wanted a new ship. It is "very predictable" and "not random at all" but it could seem unpredictable if it is happening on some user input.

@lemunozm

This comment has been minimized.

Copy link
Author

@lemunozm lemunozm commented Sep 25, 2019

Hi @evancz,

I am using the randomness for initializing a population of entities randomly in the map (their positions) and move them along their lives randomly, so I need for each frame some kind of randomness. Currently, I am using the Random.step (that does not need the interaction of the Cmd) and passing the generated seed to the next Random.step.

I like the idea you said of using the time for getting the first random seed in order to generate different populations each time you run the "game".

Thanks! :D

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.