TLP - Programming Maintenance
Week 10 - One roll of Farkle
Background
A popular party game (and phone app) is the game Farkle. You don't need to know the overall rules of Farkle to complete this assignment. You are only going to create enough code to manage PART of one turn for one player.
As background, a full turn for one player goes like this:
- A player rolls six dice.
- It is highly likely that there will be some dice that score points. If so
- The player may quit their turn taking the points earned, or
- The player may set aside one or more dice that score points and then roll the remaining dice
- If at anytime the player has set aside all six dice as scoring dice than they can pick up all six dice and continue scoring points by rolling all six dice.
- If at anytime the player rolls N dice and none of those N produce scoring dice than the player loses ALL points accumulated that round and earns a score of 0.
If you would like to watch a video with some sample rolls you can watch this video
While there are multiple scoring schedules for this game, I will ask that you use this one:
Roll Combination | Points Scored |
---|---|
Individual 1's | 100 points each |
Individual 5's | 50 points each |
Three 1's | 1,000 points |
Three 2's | 200 points |
Three 3's | 300 points |
Three 4's | 400 points |
Three 5's | 500 points |
Three 6's | 600 points |
1-2-3-4-5-6 | 3,000 points |
Three pairs (including 4-of-a-kind and a pair) | 1,500 points |
This week we aren't going to use the table above just yet. But it will help us get started if we understand where we are going.
Task One
- Write a function called containsStraight()
- Input
- A list of numbers
- If you like, you may assume that there are exactly six dice in the list.
- But if you want to challenge yourself a little bit, you may consider any length list of dice
- A list of numbers
- Performance
- Determines whether the list contains a straight.
- If you are working with the assumption that the list is exactly six dice than this is "easy" - one each of 1, 2, 3, 4, 5, and 6
- If you are working with a list of any length than the definition of a straight is it must contain at least one each of 1, 2, 3, 4, 5, and 6
- Determines whether the list contains a straight.
- Output
- True or False
- Hint
- myLyst.sort() will take a list and put it in "order"
Task Two
- Write a function called containsThreePairs()
- Input
- A list of numbers
- If you like, you may assume that there are exactly six dice in the list.
- But if you want to challenge yourself a little bit, you may consider any length list of dice
- A list of numbers
- Performance
- Determines whether the list contains three pairs.
- This one is more of a challenge because it isn't as simple as you might first think
- [ 1, 1, 2, 2, 3, 3] is three pairs
- [ 1, 1, 1, 1, 2, 2] is three pairs
- [ 1, 1, 1, 1, 1, 1] is three pairs
- and of course
- [1, 2, 3, 3, 2, 1] is three pairs
- Determines whether the list contains three pairs.
- Output
- True or False