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

New Pull request for final submission! #130

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
16 changes: 2 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

## Skills Assessed

- Following directions and reading comprehension
- Reading tests
- Using git to maintain code
- Manipulating and processing data in lists and strings
Expand All @@ -22,9 +21,7 @@ In this version of _Adagrams_, we will only be working with the English alphabet
Follow these directions once, at the beginning of your project:


1. Navigate to your projects folder named `projects`.

If you followed Ada's recommended file system structure from the Intro to Dev Environment lesson in Learn, you can navigate to your projects folder with the following command:
1. Navigate to your folder which where this project will be cloned. Example below is named projects.

```bash
$ cd ~/Developer/projects
Expand Down Expand Up @@ -145,7 +142,7 @@ $ pytest
$ pytest -s
```

## Project Write-Up: How to Complete and Submit
## Notes


The goal of this project is to write code in `game.py` so each of the functions meet the requirements outlined in the Project Directions below.
Expand All @@ -154,18 +151,9 @@ Go through the waves one-by-one and build the features of this game.

You will use play-testing and unit tests to drive your development.

At submission time, no matter where you are, submit the project via Learn.

This will let us give feedback on what you've finished so that you can be better prepared for the next project.

## Project Directions

### Get Familiar

Take time to read through the Wave 1 implementation requirements and the tests for Wave 1. Write down your questions, and spend some time going through your understanding of the requirements and tests. Make sure you can run `$ pytest` and see the tests fail.

If, after you have taken some time to think through the problem and would like direction for how to dissect the problem, or if you need clarity on the terms/vocabulary we used in this project, you can check out [a small hint we've provided](./project_docs/hints.md).

### Wave 1: draw_letters

Your first task is to build a hand of 10 letters for the user. To do so, implement the function `draw_letters` in `game.py`. This method should have the following properties:
Expand Down
105 changes: 101 additions & 4 deletions adagrams/game.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,108 @@
import random

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
}


def draw_letters():
pass
hand = []
copy_letter_pool = LETTER_POOL.copy()
while len(hand) < 10:
random_letter = random.choices(
list(copy_letter_pool), weights=copy_letter_pool.values(), k=1)
str_random_letter = random_letter[0]

if copy_letter_pool[str_random_letter] > 0:
hand.append(str_random_letter)
copy_letter_pool[str_random_letter] -= 1
return hand

Choose a reason for hiding this comment

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

I love the way you used the random.choices function here to account for the different weights of each letter! You were one of just a few people to catch onto this! Overall this works really well and you've accounted for several different possibilities!



def uses_available_letters(word, letter_bank):
pass
word_upper = word.upper()
for letter in word_upper:
if word_upper.count(letter) != letter_bank.count(letter):
return False
return True


def score_word(word):
pass
score = 0
score_chart = {
"A": 1,
"B": 3,
"C": 3,
"D": 2,
"E": 1,
"F": 4,
"G": 2,
"H": 4,
"I": 1,
"J": 8,
"K": 5,
"L": 1,
"M": 3,
"N": 1,
"O": 1,
"P": 3,
"Q": 10,
"R": 1,
"S": 1,
"T": 1,
"U": 1,
"V": 4,
"W": 4,
"X": 8,
"Y": 4,
"Z": 10,
}

Choose a reason for hiding this comment

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

This dictionary could be moved to outside the functions as a global constant just in case we wanted to expand this project and use the score_chart elsewhere!


for letter in word.upper():
if letter in score_chart:
score += score_chart[letter]
if len(word) >= 7:
score += 8
return score

Choose a reason for hiding this comment

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

This function looks great!



def get_highest_word_score(word_list):
pass
highest_score = 0
winner = None

for word in word_list:
word_score = score_word(word)
if word_score > highest_score:
highest_score = word_score
winner = (word, word_score)
elif word_score == highest_score:
if len(word) == 10:
return (word, word_score)
elif len(word) < len(winner[0]):
winner = (word, word_score)
return winner

Choose a reason for hiding this comment

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

I like what you did here, separating each part out into their separate pieces! One challenge I have for you would be to see if you can do the comparisons in place. This would require just one for loop and a few conditionals to compare the different words and their scores! There are a few examples on code reviews for reference!