Snapshot permission updates.
This commit is contained in:
1 parent
414380740f
commit
d570b16b60
15 files changed
+540
-502
No files matched your search
@@ -1,64 +1,64 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
|
||||
import dictionary
|
||||
import game
|
||||
|
||||
|
||||
def display_instructions():
|
||||
"""Print out instuctions before starting play."""
|
||||
|
||||
print(
|
||||
f"""Welcome to Wordle!
|
||||
|
||||
Wordle has a hidden word of five letters, and you get to
|
||||
make up to six guesses to find out what it is.
|
||||
|
||||
After each guess, you get feedback on each letter of your guess.
|
||||
* {game.display_result(game.LetterResult.CORRECT, "Correct!")}
|
||||
* {game.display_result(game.LetterResult.MOVE, "Correct, in a different location.")}
|
||||
* {game.display_result(game.LetterResult.INCORRECT, "Not in the word.")}
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def read_valid_guess(guess_number):
|
||||
while True:
|
||||
print(f"Guess {guess_number}: ", end="")
|
||||
guess = input()
|
||||
if guess in dictionary.words():
|
||||
return guess
|
||||
|
||||
print(f"{guess} is not a valid Wordle word. Please try again.")
|
||||
|
||||
|
||||
def display_results(guess, results):
|
||||
print(" ", end="")
|
||||
for i in range(dictionary.WORDLE_LENGTH):
|
||||
print(game.display_result(results[i], guess[i]), end="")
|
||||
print("")
|
||||
|
||||
|
||||
def play_game():
|
||||
display_instructions()
|
||||
|
||||
target = game.select_word()
|
||||
|
||||
# To help with debugging
|
||||
# print(f"The target is: {target}")
|
||||
|
||||
for guess_number in range(1, 6):
|
||||
guess = read_valid_guess(guess_number)
|
||||
results = game.grade_word(target, guess)
|
||||
|
||||
if game.success_result(results):
|
||||
print(f"You won! It took {guess_number} guesses.")
|
||||
return
|
||||
|
||||
display_results(guess, results)
|
||||
|
||||
print(f"Sorry, no guesses remaining. The word was: {target}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
play_game()
|
||||
#!/usr/bin/python
|
||||
|
||||
|
||||
import dictionary
|
||||
import game
|
||||
|
||||
|
||||
def display_instructions():
|
||||
"""Print out instuctions before starting play."""
|
||||
|
||||
print(
|
||||
f"""Welcome to Wordle!
|
||||
|
||||
Wordle has a hidden word of five letters, and you get to
|
||||
make up to six guesses to find out what it is.
|
||||
|
||||
After each guess, you get feedback on each letter of your guess.
|
||||
* {game.display_result(game.LetterResult.CORRECT, "Correct!")}
|
||||
* {game.display_result(game.LetterResult.MOVE, "Correct, in a different location.")}
|
||||
* {game.display_result(game.LetterResult.INCORRECT, "Not in the word.")}
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def read_valid_guess(guess_number):
|
||||
while True:
|
||||
print(f"Guess {guess_number}: ", end="")
|
||||
guess = input()
|
||||
if guess in dictionary.words():
|
||||
return guess
|
||||
|
||||
print(f"{guess} is not a valid Wordle word. Please try again.")
|
||||
|
||||
|
||||
def display_results(guess, results):
|
||||
print(" ", end="")
|
||||
for i in range(dictionary.WORDLE_LENGTH):
|
||||
print(game.display_result(results[i], guess[i]), end="")
|
||||
print("")
|
||||
|
||||
|
||||
def play_game():
|
||||
display_instructions()
|
||||
|
||||
target = game.select_word()
|
||||
|
||||
# To help with debugging
|
||||
# print(f"The target is: {target}")
|
||||
|
||||
for guess_number in range(1, 6):
|
||||
guess = read_valid_guess(guess_number)
|
||||
results = game.grade_word(target, guess)
|
||||
|
||||
if game.success_result(results):
|
||||
print(f"You won! It took {guess_number} guesses.")
|
||||
return
|
||||
|
||||
display_results(guess, results)
|
||||
|
||||
print(f"Sorry, no guesses remaining. The word was: {target}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
play_game()
|
||||
Reference in new issue
Block a user