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

Add example of getting random values, use them for creep name #36

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

shanemadden
Copy link
Collaborator

I finally bothered to get a proof of concept going of getting randomness the 'right' way within Screeps WASM - it's a little tricky since the js feature on the getrandom crate assumes we have interfaces we don't, so going down that path is a trap, and we need a custom randomness function.

This replaces the additional part of the creep name with a random value instead of an incrementor - arguably this makes the example bot worse since it risks failing to spawn a creep when it could before , but also it's...

  1. a common enough feature that people want in their bots,
  2. extremely low risk of actually causing issues since people aren't likely multi-rooming on the example bot unmodified, and
  3. a bit wordy to document the setup for since you're adding two crate dependencies (but one is only to turn on a feature) then calling a macro on the function with the right signature to register

..so it seems like having this as part of the example would be an overall good/not too much extra complexity.

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

Successfully merging this pull request may close these issues.

1 participant