Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

RandomTable.roll() returning None fairly freqently.

オープン
#205 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
rust
領域
game-dev

調査の方向性

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 を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

amethyst/rustrogueliketutorial のほかの issue

amethyst/rustrogueliketutorial の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。