Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← Scoring - Design of Computer Programs

Get Embed Code
1 Language

Showing Revision 3 created 05/24/2016 by Udacity Robot.

  1. I could take the results from all plays, so each play is a triple of position, direction, and a word,
  2. and then I could add a score to those, but it seems like I'm just taking this lists apart
  3. and putting them back together so many time. I've already done it three times.
  4. I did a row play--took it apart, added it back in j for the horizontal plays, and took that apart,
  5. added back in a direction for all_plays. I could do that one more time to insert the score.
  6. Maybe that would've been the right choice.
  7. Maybe I just got fatigued, and I made a mistake in my design sense,
  8. but what I decided to do was modify my horizontal_plays and all_plays functions.
  9. There are two modifications.
  10. Here in horizontal_plays, after I got the play, I calculate a score,
  11. and then I insert that into my result.
  12. Now my results are no longer just position, word play--they're score, position, word play.
  13. Then I want to do the same thing in all_plays.
  14. I want to make my play be a score, position, direction, word tuple,
  15. and I'm just, as before, ripping these things apart and putting them back together.
  16. Now, remember the board. It's got these double letters, triple word scores, and so on.
  17. If you're old-school it looks like this.
  18. This is on a piece of cardboard that's a physical material.
  19. We've also written triple and double scores, so I need to come up with some ways
  20. of representing these spots on the board and how they're special.
  21. Now, could I squeeze it into my existing representation of a row?
  22. Remember a row is a list, and it can have things like that border is a string.
  23. Then we have a letter. Then we can have anchors like ANY.
  24. Could I have room for putting information about bonus squares on the board--
  25. the double and triple letters?
  26. Could I have, say, 3W to mean triple-word score as an element of this row?
  27. I guess my intuition is I don't think that's going to work very well.
  28. The problem is one of these squares--say this one--
  29. could be both an anchor and a triple-word score.
  30. So we'd need some representation that allowed both of those.
  31. That just doesn't seem to be easy to extend what I already have.
  32. Let's not override our row notation.
  33. Our rows, as we have it--I'm pretty happy with them.
  34. I'm not going to allow this. I'm going to keep row exactly as they are.
  35. I'm going to introduce another data structure--a parallel board, I'm going to have two boards.
  36. One board that I play on and another board that holds the bonuses. Think of it as two layers.
  37. One representation of a two-dimensional matrix just holds these double words
  38. and triple letters scores and so on,
  39. and then on top of that there's a second two-dimensional array
  40. that holds the values of the letters and also holds the anchors. Oh, I got a good score.
  41. Now I'm going to have board[ j ][ i ] will hold the letter or anchor,
  42. and then bonus[ j ][ i ] will hold corresponding bonus--
  43. a double word, a triple letter, or just nothing.