#Plan of Action Available Times: Google Calendar Invites Collaboration preferred time: 3 PM - 8 PM (up until 11 PM for emergencies) If wave is not finished by the end of google meeting, can discuss plans further. Goal: Aim for one wave per day; complete by end of Thursday Communication: By Slack for longer code-related messages By text - to ping Feedback: Check-in before going home everything/ending meeting whether collaboration methods should be changed
- Following directions and reading comprehension
- Reading tests
- Using git to maintain code
- Manipulating and processing data in lists and strings
- Practicing pair-programming techniques
An anagram is a word or phrase formed by rearranging the letters of a different word or phrase. In this project you and your partner will be creating Adagrams, a game in which a player is given a random set of letters and must make an anagram using those letters. Each submitted word will score points.
While working on Adagrams, it may help to think of a physical metaphor for this game, such as other common word games like Scrabble or Bananagrams. These games all feature a pool of letter tiles that the player draws from.
In this version of Adagrams, we will only be working with the English alphabet.
Utilize good pair programming practices. Refer to this medium article, and the lesson in Learn titled Intro to Pair Programming from Approaching a Problem if you need a refresher for some best practices. Switch driver and navigator roles often. When there is uncertainty or confusion, step away from the keyboard and discuss, plan, and document on paper or whiteboard before continuing.
Follow these directions once, a the beginning of your project:
Only one member of the team should complete the following two steps steps:
- In Github, click on the "Fork" button in github and fork the repository to your Github account. This will make a copy of the project in your github account.
- In Github, add the other member(s) of your team as collaborators to the repository. Do this by a The student who forked the respository should first choosing Settings from the top menu bar, then Manage access from the left navigation, and finally Invite teams or people.
You can find detailed instructions here.
The member(s) who are invite will need to accept the invitation either by accepting an email invitation or accepting the invitation in Github.
Both members of the team will be working from the same forked repository. Be sure to follow proper git protocol from the Intro to Git topic in Learn.
Each member of the pair should complete the following steps:
- Navigate to your projects folder named
projects
$ cd ~/Developer/projects
- "Clone" (download a copy of this project) into your projects folder. This command makes a new folder called
adagrams-py
, and then puts the project into this new folder. Make sure you are cloning from your copy of the project and not the class version (ada-cX).
$ git clone ...
Use ls
to confirm there's a new project folder
- Move your location into this project folder
$ cd adagrams-py
- Create a virtual environment named
venv
for this project:
$ python3 -m venv venv
- Activate this environment:
$ source venv/bin/activate
Verify that you're in a python3 virtual environment by running:
$ python --version
should output a Python 3 version$ pip --version
should output that it is working with Python 3
- Install dependencies once at the beginning of this project with
# Must be in activated virtual environment
$ pip install -r requirements.txt
Summary of one-time project setup:
One person:
- Fork the project respository
- Invite team members to the respository
All team members:
-
cd
into yourprojects
folder - Clone the project onto your machine
-
cd
into theadagrams-py
folder - Create the virtual environment
venv
- Activate the virtual environment
venv
- Install the dependencies with
pip
- When you want to begin work on this project, ensure that your virtual environment is activated:
$ source venv/bin/activate
- Run the game and play test your current wave. Replace the word
wave
below with the wave number (ie, 1, 2, 3 or 4):
# Must be in activated virtual environment
$ python main.py wave
-
Use play-testing wth your partner to guide your development.
-
Use tests to verify your functions after thoroughly play-testing. See instructions for running tests in the section below. A complete set of unit tests is provided for this project.
-
Use git to commit your work regularly! Commit between each wave.
# Add your current work
$ git add .
$ git commit -m "meaningful message explaining your commit"
-
Consider switching driver/navigator rolls. Make sure the current driver pushes using
git push
and the new driver pulls usinggit pull
. -
Move on to the next wave!
-
When you are finished working for the day, deactivate your environment with deactivate or closing the Terminal tab/window
$ deactivate
-
Find the test file that contains the test you want to run.
- Check the
tests
folder, and find the test file you want to run - In that test file, read through each test case
- Check the
-
Run the tests for your specific wave
# Must be in activated virtual environment
$ pytest tests/test_wave_01.py
- Run all tests that exist in this project with:
# Must be in activated virtual environment
$ pytest
- If you want to see any
print
statements print to the console, add-s
to the end of anypytest
command:
# Must be in activated virtual environment
$ pytest -s
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.
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.
In addition to submitting your Pull Request, submit a reflection the the pair programming reflection prompt.
First, come up with a "plan of action" for how you want to work as a pair. Discuss your learning style, how you prefer to receive feedback, and one team communication skill you want to improve with this experience.
We recommend spending at least a portion of the time pair programming and working collaboratively from the same machine. Zoom and screen sharing or VSCode Live Share are good tools to consider. Some teams will choose to pair program and work collaboratively from the same machine for the entire project. Some teams will choose to divide a portion of the work and combine their code using git.
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 with your pair. Make sure you both can run $ pytest
and see the tests fail.
If, after you and your pair 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.
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:
- No parameters
- Returns an array of ten strings
- Each string should contain exactly one letter
- These represent the hand of letters that the player has drawn
- The letters should be randomly drawn from a pool of letters
- This letter pool should reflect the distribution of letters as described in the table below
- There are only 2 available
C
letters, sodraw_letters
cannot ever return more than 2C
s - Since there are 12
E
s but only 1Z
, it should be 12 times as likely for the user to draw anE
as aZ
- Invoking this function should not change the pool of letters
- Imagine that the user returns their hand to the pool before drawing new letters
Letter : Qty. | Letter : Qty. |
---|---|
A : 9 | N : 6 |
B : 2 | O : 8 |
C : 2 | P : 2 |
D : 4 | Q : 1 |
E : 12 | R : 6 |
F : 2 | S : 4 |
G : 3 | T : 6 |
H : 2 | U : 4 |
I : 9 | V : 2 |
J : 1 | W : 2 |
K : 1 | X : 1 |
L : 4 | Y : 2 |
M : 2 | Z : 1 |
Note: Making sure that the drawn letters match the rules of the letter pool can be straightforward or very difficult, depending on how you build the data structure for the letter pool. It is worth spending some time with your partner to think carefully about this.
Next, you need a way to check if an input word (a word a player submits) only uses characters that are contained within a collection (or hand) of drawn letters. Essentially, you need a way to check if the word is an anagram of some or all of the given letters in the hand.
To do so, implement the function called uses_available_letters
in game.py
. This function should have the following properties:
- Has two parameters:
word
, the first parameter, describes some input word, and is a stringletter_bank
, the second parameter, describes an array of drawn letters in a hand. You can expect this to be an array of ten strings, with each string representing a letter
- Returns either
True
orFalse
- Returns
True
if every letter in theinput
word is available (in the right quantities) in theletter_bank
- Returns
False
if not; if there is a letter ininput
that is not present in theletter_bank
or has too much of compared to theletter_bank
Now you need a function returns the score of a given word as defined by the Adagrams game.
Implement the function score_word
in game.py
. This method should have the following properties:
- Has one parameter:
word
, which is a string of characters - Returns an integer representing the number of points
- Each letter within
word
has a point value. The number of points of each letter is summed up to represent the total score ofword
- Each letter's point value is described in the table below
- If the length of the word is 7, 8, 9, or 10, then the word gets an additional 8 points
Letter | Value |
---|---|
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 |
After several hands have been drawn, words have been submitted, checked, scored, and played, you need a way to find the highest scoring word. This function looks at the list of word_list
and calculates which of these words has the highest score, applies any tie-breaking logic, and returns the winning word in a special data structure.
Implement a function called get_highest_word_score
in game.py
. This method should have the following properties:
- Has one parameter:
word_list
, which is a list of strings - Returns a tuple that represents the data of a winning word and it's score. The tuple must contain the following elements:
- index 0 ([0]): a string of a word
- index 1 ([1]): the score of that word
- In the case of tie in scores, use these tie-breaking rules:
- prefer the word with the fewest letters...
- ...unless one word has 10 letters. If the top score is tied between multiple words and one is 10 letters long, choose the one with 10 letters over the one with fewer tiles
- If the there are multiple words that are the same score and the same length, pick the first one in the supplied list