-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maple Ayaka and Grace(Jiajia Wang) #40
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,11 +1,94 @@ | ||||||||||||||||||||||
import random | ||||||||||||||||||||||
import string | ||||||||||||||||||||||
|
||||||||||||||||||||||
LETTER_POOL = { | ||||||||||||||||||||||
'A': 9, | ||||||||||||||||||||||
'B': 2, | ||||||||||||||||||||||
'C': 2, | ||||||||||||||||||||||
'D': 4, | ||||||||||||||||||||||
'E': 12, | ||||||||||||||||||||||
'F': 2, | ||||||||||||||||||||||
'G': 3, | ||||||||||||||||||||||
'H': 2, | ||||||||||||||||||||||
'I': 9, | ||||||||||||||||||||||
'J': 1, | ||||||||||||||||||||||
'K': 1, | ||||||||||||||||||||||
'L': 4, | ||||||||||||||||||||||
'M': 2, | ||||||||||||||||||||||
'N': 6, | ||||||||||||||||||||||
'O': 8, | ||||||||||||||||||||||
'P': 2, | ||||||||||||||||||||||
'Q': 1, | ||||||||||||||||||||||
'R': 6, | ||||||||||||||||||||||
'S': 4, | ||||||||||||||||||||||
'T': 6, | ||||||||||||||||||||||
'U': 4, | ||||||||||||||||||||||
'V': 2, | ||||||||||||||||||||||
'W': 2, | ||||||||||||||||||||||
'X': 1, | ||||||||||||||||||||||
'Y': 2, | ||||||||||||||||||||||
'Z': 1 | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
LETTER_SCORE = { | ||||||||||||||||||||||
("A", "E", "I", "O", "U", "L", "N", "R", "S", "T"): 1, | ||||||||||||||||||||||
("D", "G"): 2, | ||||||||||||||||||||||
("B", "C", "M", "P"): 3, | ||||||||||||||||||||||
("F", "H", "V", "W", "Y"): 4, | ||||||||||||||||||||||
("K",): 5, | ||||||||||||||||||||||
("J", "X"): 8, | ||||||||||||||||||||||
("Q", "Z"): 10, | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
def draw_letters(): | ||||||||||||||||||||||
pass | ||||||||||||||||||||||
letters = [] | ||||||||||||||||||||||
while len(letters) < 10: | ||||||||||||||||||||||
random_letter = random.choice(string.ascii_uppercase) | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead of bringing another library, let's use what we already have! Maybe we can turn our
Suggested change
|
||||||||||||||||||||||
if letters.count(random_letter) >= LETTER_POOL[random_letter]: | ||||||||||||||||||||||
continue | ||||||||||||||||||||||
else: | ||||||||||||||||||||||
letters.append(random_letter) | ||||||||||||||||||||||
Comment on lines
+46
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. interesting approach! I think it would be more efficient if we got rid of the
Suggested change
|
||||||||||||||||||||||
return letters | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
def uses_available_letters(word, letter_bank): | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 wow short and sweet! nicely done |
||||||||||||||||||||||
pass | ||||||||||||||||||||||
for letter in word: | ||||||||||||||||||||||
if word.count(letter) > letter_bank.count(letter): | ||||||||||||||||||||||
return False | ||||||||||||||||||||||
return True | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
def score_word(word): | ||||||||||||||||||||||
pass | ||||||||||||||||||||||
score = 0 | ||||||||||||||||||||||
for letter in word.upper(): | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good idea making sure that the letters and inputs will always be capitalized |
||||||||||||||||||||||
for key in LETTER_SCORE: | ||||||||||||||||||||||
if letter in key: | ||||||||||||||||||||||
score += LETTER_SCORE.get(key) | ||||||||||||||||||||||
if 7 <= len(word) <= 10: | ||||||||||||||||||||||
score += 8 | ||||||||||||||||||||||
return score | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
def get_highest_word_score(word_list): | ||||||||||||||||||||||
pass | ||||||||||||||||||||||
max_score = 0 | ||||||||||||||||||||||
for word in word_list: | ||||||||||||||||||||||
score = score_word(word) | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 yay helper functions! |
||||||||||||||||||||||
if score > max_score: | ||||||||||||||||||||||
max_score = score | ||||||||||||||||||||||
max_score_word_list = [word] | ||||||||||||||||||||||
elif score == max_score: | ||||||||||||||||||||||
max_score_word_list.append(word) | ||||||||||||||||||||||
|
||||||||||||||||||||||
winner = select_winner(max_score_word_list) | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||||||||||||||||||||||
return winner, max_score | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
def select_winner(word_list): | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||||||||||||||||||||||
min_word = word_list[0] | ||||||||||||||||||||||
for word in word_list: | ||||||||||||||||||||||
if len(word) == 10: | ||||||||||||||||||||||
return word | ||||||||||||||||||||||
elif len(word) < len(min_word): | ||||||||||||||||||||||
min_word = word | ||||||||||||||||||||||
return min_word |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 nice idea!