Skip to content

Conversation

polyacetal
Copy link
Contributor

SSIA

オプションで指定された数で分割された小さいマップのアイテムと壁の数を指定するため, 出来上がるマップの総数は約4倍の数になる

@polyacetal polyacetal requested a review from noko1024 April 13, 2025 11:15
@polyacetal polyacetal self-assigned this Apr 13, 2025
@polyacetal
Copy link
Contributor Author

オプションにクソデカ数字を入れられた時の処理を追加する

Copy link
Member

@noko1024 noko1024 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

argsで渡される値と実際のマップで得られる状態に乖離があるので
入力された値/4などでケアしてあげるほうが優しいと思います!

実装上の都合で要件が若干複雑なのでテストコードも書きましょう
値のバリデーションも忘れずに!

if not os.path.exists(file_path):
os.makedirs(file_path)
with open(f"{file_path}{file_name}.map", "w") as f:
with open(f"{file_path}/{file_name}.map", "w") as f:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

os.path.join()で統一したい

Suggested change
with open(f"{file_path}/{file_name}.map", "w") as f:
with open(os.path.join(file_path,f"{file_name}.map"), "w") as f:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

確かに!
修正します.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

アルゴリズムの関係上, このままの実装だと, argで渡された値と若干の乖離があるのは避けられないことなので諦めます.
ただ, argで渡された値/4は簡単に実装できると思うのでやってしまいます.
(追加する処理としては, argで渡された値/4で端数が出た場合は切り捨てして小さいランダムマップの生成処理をする)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@polyacetal polyacetal requested a review from noko1024 April 14, 2025 02:25
Copy link
Member

@noko1024 noko1024 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

入力値のチェックの部分気になったのでコメントしています
実装面に関しては後は気になるところは無いかも

テストコード書けそうなら書いてほしいです!

Comment on lines 233 to +235
block_num = int(args.blockNum) if args.blockNum else 9
except ValueError:
print(
"error: Expected an integer for option '--blockNum', "
"but received a different type."
)
print(f"blockNum type: {type(args.blockNum)}")
if not (0 <= block_num <= 40):
raise ValueError("Out of range")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

範囲外の値を入力されたときはvalidation checkで例外より先にケアできると良いかなと思いました!

https://qiita.com/LyricalMaestro0/items/80e6ec2d58c828977172
https://qiita.com/TakamiChie/items/95ab9ae401879de90231

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

テストコードの件把握しました.
ただ, まとめて他のissueで解決した方がいい気がするので, 特に何もなければ, 別のissueで対応します.

Copy link
Member

@noko1024 noko1024 Apr 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

特段の事情が無い限りは変更したPRでテストもまとめる方が良いと思います

  • 実装が適切か否か,テスト条件という成功/失敗のはっきりした基準でわかること
  • テスト条件で考慮漏れがある → 実装でも考慮漏れがある可能性を発見できること

このあたりが挙げられます

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.

2 participants