RandomTable.roll() returning None fairly freqently.
まだ誰も着手していません。
評価
調査の方向性
RandomTable.roll() の実装を探し、issue に示されているループを調査してください。0 のロールと累積ウェイトに正確に一致するロールの境界動作を検証し、その後、第45章以降のランダムマップを実行して、有効なロールが None を返したり警告を生成したりしなくなったことを確認してください。
索引モデルが issue の本文から書いたものです。
説明
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() { ..
- 主要言語
- Rust
- スター
- 968
- フォーク
- 166
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトの環境構築ファイルはまだ確認していません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
amethyst/rustrogueliketutorial のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
-
難易度 1/5 1〜3時間 初心者へのやさしさ 45/100
amethyst/rustrogueliketutorial の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
bytecodealliance/wasmtime#14433 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信