Add Word Scramble interactive CLI game#13660
Add Word Scramble interactive CLI game#13660MahyudeenShahid wants to merge 4 commits intoTheAlgorithms:masterfrom MahyudeenShahid:master
Conversation
This commit introduces a new interactive CLI game called Word Scramble. It features difficulty levels, multiple rounds, a hint system, scoring with time bonuses, and persistent high scores.
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
| } | ||
|
|
||
|
|
||
| def load_high_scores(): |
There was a problem hiding this comment.
Please provide return type hint for the function: load_high_scores. If the function does not return a value, please provide the type hint as: def function() -> None:
| return [] | ||
|
|
||
|
|
||
| def save_high_scores(scores): |
There was a problem hiding this comment.
Please provide return type hint for the function: save_high_scores. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: scores
|
|
||
| def save_high_scores(scores): | ||
| """Save high scores to disk (keep only top 10).""" | ||
| scores = sorted(scores, key=lambda s: s["score"], reverse=True)[:10] |
There was a problem hiding this comment.
Please provide descriptive name for the parameter: s
| json.dump(scores, fh, indent=2) | ||
|
|
||
|
|
||
| def load_stats(): |
There was a problem hiding this comment.
Please provide return type hint for the function: load_stats. If the function does not return a value, please provide the type hint as: def function() -> None:
| return {"games_played": 0, "best_streak": 0} | ||
|
|
||
|
|
||
| def save_stats(stats): |
There was a problem hiding this comment.
Please provide return type hint for the function: save_stats. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: stats
| return int(base * mult + time_bonus) | ||
|
|
||
|
|
||
| def play_round(word, difficulty): |
There was a problem hiding this comment.
Please provide return type hint for the function: play_round. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: word
Please provide type hint for the parameter: difficulty
| print(f"Not quite. {same_positions} letter(s) in the correct position. Try again.") | ||
|
|
||
|
|
||
| def pick_word_by_difficulty_and_category(difficulty, category=None): |
There was a problem hiding this comment.
Please provide return type hint for the function: pick_word_by_difficulty_and_category. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: difficulty
Please provide type hint for the parameter: category
| return random.choice(pool) | ||
|
|
||
|
|
||
| def celebratory_art(): |
There was a problem hiding this comment.
Please provide return type hint for the function: celebratory_art. If the function does not return a value, please provide the type hint as: def function() -> None:
| save_stats(stats) | ||
|
|
||
|
|
||
| def main_menu(): |
There was a problem hiding this comment.
Please provide return type hint for the function: main_menu. If the function does not return a value, please provide the type hint as: def function() -> None:
for more information, see https://pre-commit.ci
Refactor Word Scramble game code to improve type hints and fix minor formatting issues.
for more information, see https://pre-commit.ci
MahyudeenShahid
left a comment
There was a problem hiding this comment.
Fix remaining lint/type issues
|
Please read the definition of an algorithm in CONTRIBUTING.md. This repo does to do games, we do algorithms. |
Title:
add interactive word scramble game
Description:
This pull request adds a new interactive CLI Word Scramble game implemented in a single Python file.
Files added:
This file implements:
Describe your change:
Checklist:
word_scramble_game.py)Reference:
Commit message:
add interactive word scramble game algorithm