Skip to content
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

Kunzite - Abby Castillo #126

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 72 additions & 4 deletions adagrams/game.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,79 @@
# initializations
print("")
print("*** INITIALIZATIONS ***")

import random

LETTERS_TUPLE = ( {'A': 9,
Copy link

Choose a reason for hiding this comment

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

Interesting choice of data structure! Since in the next line of you index this nested dictionary out of the tuple, it's not clear why the nesting in the first place - you could use a dictionary and bypass the need to index a tuple!

'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}, )

letters_dict = LETTERS_TUPLE[0]
# print(f"letters_dict is {letters_dict}")

# helper functions

def make_letter_pool_list(letter_frequencies):
Copy link

Choose a reason for hiding this comment

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

Cool helper function, this will help ensure the letter pool distribution is accounted for!

letter_pool_list = []
for letter in letter_frequencies:
for i in range(letter_frequencies[letter]):
letter_pool_list.append(letter)
return letter_pool_list

# print(f"random number: {random.randint(0, 100)}")
# wave functions

def draw_letters():
pass
letter_pool = make_letter_pool_list(letters_dict)
hand = []
while len(hand) < 10:
letter_selection = random.randint(0, len(letter_pool) - 1)
hand.append(letter_pool[letter_selection])
del letter_pool[letter_selection]
return hand

def uses_available_letters(word, letter_bank):
pass
hand = list(letter_bank)
Copy link

Choose a reason for hiding this comment

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

letter_bank is already a list, so no need to convert to a list.

word = word.upper()
for letter in word:
if letter not in hand:
return False
elif letter in hand:
hand.remove(letter)
Copy link

Choose a reason for hiding this comment

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

No need to remove the letter from the hand on this implementation. All you're concerned with is checking whether the letter is not in the hand. If you iterate over all the letters and find that all of them are in the hand, you can just return True.

return True

def score_word(word):
pass
score = 0
Copy link

Choose a reason for hiding this comment

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

Nice job here, this will score the word according to the letter to point value mapping, however the requirements for Wave 03 also state: "If the length of the word is 7, 8, 9, or 10, then the word gets an additional 8 points", which this function doesn't account for.

for letter in word:
score += LETTERS_TUPLE[0][letter]

return score

def get_highest_word_score(word_list):
pass
pass

hand = draw_letters()
uses_available_letters('sandwich', hand)
57 changes: 57 additions & 0 deletions project_docs/dev-notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
so i might want to start with a dictionary. wrap it inside a tuple to be safe.

letters_tuple = ( {A: 9,
B: 2,
N: 2,
etc})

then in the code, you run a loop that creates a list full of all the letters.

def make_letter_string(letters_tuple):
letters_dict = letters_tuple[0]
for letter, frequency in letters_dict.items:

....

OK!

so.

in your draw_letters() function.

initialize a hand variable.
(so... hand = [])
take the letter_pool_list.

*** LOOP BEGINS ***
return a random number based on the length of that list, set to a variable.
(so... letter_selection = random.randint(0, len(letter_pool_list)))
then pick the letter item based on the random number, add it to hand
(so... hand.append(letter_pool_list[letter_selection]))
then remove that letter from the letter_pool_list.
(so... del letter_pool_list[letter_selection])

OK....

## WAVE 2 !!!

here you are going to do stuff with sets.

begin by turning word into a list. you do this with a loop.

so, first, initialize the list.
(so... word_letters = [])
then, iterate through the string.
so...
for letter in word:
word_letters.append[letter]

oh. no.
do it this way:

for letter in word:
if letter not in letter_bank:
return False
elif letter in letter_bank:
letter_bank.remove(letter)
return True