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

Scrabble - Jackie & Leti (Ampers) #8

Open
wants to merge 49 commits into
base: master
Choose a base branch
from

Conversation

LetiTran
Copy link

@LetiTran LetiTran commented Feb 23, 2018

Scrabble

Congratulations! You're submitting your assignment.

Comprehension Questions

Feature Feedback
What are the advantages of using git when collaboratively working on one code base? One advantage is that both of us can contribute to the same project and both of us can have access to the most recent updates. We can also view a log of all the changes made by the other person. Git also helps manage conflicts.
Why do you think we chose to make the score method in the Scoring class a class method instead of an instance method? We made score a class method so that we can directly access the method from other classes within the same Module Scrabble.
Describe an example of a test you wrote for a nominal case. We created a test to return the sum of scores of played words. We made our instance of a player play two words and in the assert statement we indicated that the score must equal the number we manually calculated.
Describe an example of a test you wrote for an edge case. We wrote a test within scoring_spec in which if max score is tied and none of the words have a length of 7 the selected winning word would be the one with less characters.
Does your code use any methods from the Enumerable mixin? If so, where and why was it helpful? We used select, max_by, and min_by in scoring.rb in the self.highest_score_from method. They were helpful to use in this method because it made our code more concise without having to use .each method.
What was one method you and your pair used to debug code? We inserted puts statements in places in which we thought the code was having issues. We also followed the stack trace to help us figure out where the errors were coming from.
Is there a specific piece of code you'd like feedback on? Did we efficiently use max_by and min_by in scoring.rb in the self.highest_score_from method or are there other enumerable methods that are more appropriate for what we wanted to do.
What are two discussion points that you and your pair discussed when giving/receiving feedback from each other that you would be willing to share? For us, the ping pong method allowed us to equally divide time spent driving and navigating. We consistently explained our code to each other which helped us understand what each part does. There was one part in wave 3 that we spent too much time trying to debug and we both think that if we were to do this again, we would have asked for help earlier.

LetiTran and others added 30 commits February 20, 2018 14:27
@CheezItMan
Copy link

Scrabble

What We're Looking For

Feature Feedback
General
Answered comprehension questions Check
Both Teammates contributed to the codebase Check
Regular Commits with meaningful commit messages Good number of commits and good messages
Scoring class
score method Check
Uses appropriate data structure to store the letter score Your way works, but there is a more compact way.
Appropriately handles edge cases Check
highest_score_from method Check
Appropriately handles edge cases Check
Test implementations for highest_score_from Yes, but see my note.
Player class
Uses an array to keep track of words played Check, but play isn't working properly
Uses existing code to create highest_scoring_word and highest_word_score Check
Returns true or false from won? method Check
Tests edge cases on the play(word) NOPE, see my in-code notes on your tests. You need to be much more through.
TileBag class
Uses a data structure to keep the set of default tiles in the bag See my comment on the data structure
draw_tiles method uses the parameter to draw a set of random tiles Check
tiles_remaining method returns a count Check
Tests draw_tiles edge cases You're missing the case where I try to draw 100 tiles.
Summary Not bad you hit the learning goals. You need to be a bit more through in your edge cases and see my note about the structure you use in TileBag. However over all, nice work!

lib/scoring.rb Outdated
# Set the points for that word to initialize at zero and calculate the points of each word, adding them to the points variable:
points = 0

letters_array.each do |letter|

Choose a reason for hiding this comment

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

This works, but is there a more compact way to do this, maybe with a hash?

lib/scoring.rb Outdated
scoring_table = {}

# Set the scores of each word:
array_of_words.each {|word| scoring_table["#{word}"] = score(word)}

Choose a reason for hiding this comment

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

You don't need the interpolation here:

array_of_words.each {|word| scoring_table[word] = score(word)}

will work

end

it 'returns the highest word if there are two words' do
winning_words = Scrabble::Scoring.highest_score_from(["dog", "academy"])

Choose a reason for hiding this comment

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

Since order can potentially be important in the highest_score_from method repeating these tests by varying the order is useful.

Something like:

      winning_words = Scrabble::Scoring.highest_score_from(["academy", "dog"])
      winning_words.must_equal "academy"

# _________________PLAY METHOD____________________
# Accepts a word as an argument and add it to the plays array.

def play(word)

Choose a reason for hiding this comment

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

Read the description again. This method is required to return false if they have already won prior to playing the word.

# Returns true if the toal score is more than 100, otherwise returns false.

def won?
total_score > 100 ? true : false

Choose a reason for hiding this comment

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

Good ternary

end
end

describe "#play(word)" do

Choose a reason for hiding this comment

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

What about:

  1. Playing more than 1 word.
  2. Playing an invalid word
  3. Playing words after the player has already won!


end

it "Returns false if player has over 100 points" do

Choose a reason for hiding this comment

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

won? should return true if the player has >= 100 points. It's play that should return false

lib/tile_bag.rb Outdated
attr_reader :bag

def initialize
@bag = {

Choose a reason for hiding this comment

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

There's a number of problems with this data structure. Most pressing is that it gives each letter an equal chance of being drawn. This is despite the fact that there are a lot more "E" tiles than "Z".

new_letter = @bag.keys.sample
tiles_drawn << new_letter
@bag[new_letter] -= 1
@bag.delete_if { |letter, quantity| quantity == 0 }

Choose a reason for hiding this comment

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

Good that you're keeping the number of tiles from going negative.

end

describe '#tiles_remaining' do
it "returns number of tiles remaining in bag" do

Choose a reason for hiding this comment

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

You should also test to see what happens when I try to draw more tiles than are in the bag!

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