Skip to content

Sharks - Jande R. & Jeannie Z.#48

Open
janderoyalty wants to merge 15 commits intoada-c17:masterfrom
janderoyalty:master
Open

Sharks - Jande R. & Jeannie Z.#48
janderoyalty wants to merge 15 commits intoada-c17:masterfrom
janderoyalty:master

Conversation

@janderoyalty
Copy link

No description provided.

Copy link

@spitsfire spitsfire left a comment

Choose a reason for hiding this comment

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

Heck yeah, Jeannie and Jande! This was short and sweet! I only had one or two suggestions for y'all to consider, but that's it.

Another thing we discussed in class was how to imitate the probability of grabbing more common tiles versus rarer ones. Some things you could think about is creating a list of all tiles and their duplicates (ie, ['A','A','A','B','B'] and so on) to choose from.

A more advanced solution might be using the random.choice method, but with more than one param. Here's an example of how you can "weigh" your list: https://www.geeksforgeeks.org/how-to-get-weighted-random-choice-in-python/

player_hand = []
random_letter = ""
while len(player_hand) < 10:
random_letter = random.choice(string.ascii_uppercase)

Choose a reason for hiding this comment

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

Neat idea!


def uses_available_letters(word, letter_bank):
pass
list_of_letters = letter_bank[:]

Choose a reason for hiding this comment

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

Great reason to make a copy in this context. Let's say, for example, you are removing tiles from the original letter_bank, but the function returns False, meaning the word can't be made. Well, if you remove all the tiles from the list, now the player's hand is bare! and they can't play the round anymore.

Comment on lines +79 to +91
bool_set = set()
for letter in word.upper():
if letter in list_of_letters:
bool_set.add(True)
list_of_letters.remove(letter)
else:
bool_set.add(False)


if bool_set == {True}:
return True
else:
return False

Choose a reason for hiding this comment

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

Cool idea to use flags to check over each letter in the word to see if it has a tile to match. If you were worried, though, about taking up memory space, what could we do instead?

Maybe check if the list_of_letters is empty before the for loop ends or the moment you hit an else statement which means a letter wasn't in the list_of_letters, you can return False immediately

else:
return False

def score_word(word):

Choose a reason for hiding this comment

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

👍

adagrams/game.py Outdated
Comment on lines +114 to +117
elif len(word) == 10:
winning_word = word
elif len(word) < len(winning_word):
winning_word = word

Choose a reason for hiding this comment

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

since these two conditional statements duplicate the exact same line winning_word = word, we should think about combining them into a compound conditional

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.

3 participants