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...
a common enough feature that people want in their bots,
extremely low risk of actually causing issues since people aren't likely multi-rooming on the example bot unmodified, and
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.
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...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.