RandomTable.roll() returning None fairly freqently.
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 45/100
Research direction
Search for the RandomTable.roll() implementation and inspect the loop shown in the issue. Verify the boundary behavior for rolls of 0 and exact cumulative weights, then exercise random maps from chapter 45 onward and confirm that valid rolls no longer return None or produce the warning.
Written by the indexing model from the issue text.
Description
To see the problem in action, get to a random map from chapter 45 on-wards.
The message "WARNING: We don't know how to spawn [None]!" should show up a number of times in the log.
Currently, whenever you roll 0, or exactly the sum of a number of item weights, nothing is spawned.
For example, if the first few items are weighted at [1,3,2,3,1...], then roll() would return "None" if the rng hits 0,1,4,6,9 or 10.
I'm assuming this is unintended behavior, but you can see pretty clearly why this happens in the code:
while roll > 0 {
if roll < self.entries[index].weight {
return self.entries[index].name.clone();
}
roll -= self.entries[index].weight;
index += 1;
}
There are two easy fixes that I can see. Both effectively just looping more:
while roll >= 0 { ...
or
while index < self.entries.len() { ..
- Dominant language
- Rust
- Stars
- 967
- Forks
- 166
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from amethyst/rustrogueliketutorial
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
Difficulty 1/5 1-3 hours Newbie friendliness 45/100
All issues in amethyst/rustrogueliketutorial
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
bug llm translation
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
skillfs: one malformed chat-log line aborts the entire skill-usage analysis (skill_usage_from_chat_logs.py)Possibly taken @zjncs claimed this today. Opencomponent:skillfs
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
agentic-os-org/ANOLISA#6116 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
indygreg/cryptography-rs#99 ·