Tests

find_all_triads

It can be challenging to test find_all_triads if you aren’t good at the game. You could work hard and get good at the game! Or we can give you a way to test to see if your program is working correctly.

In the constructor for the Game object, you will see this:

def __init__(self):
        """
        Creates the Game object.
        * DO NOT MODIFY THE CONSTRUCTOR *
        """
        self.deck = Deck()
        #self.setup_deck(0)
        self.tableau = []
        self.selected = []
        ...

Uncomment the line that says self.setup_deck(0). This line forces the deck into the same order ever time you run the game, which will allow you to more consistently test your game.

By changing the number 0 to other numbers, you can test other configurations of the deck to be sure your find_all_triads method is working. Here are all of Triads your program should find given a few different values plugged into setup_deck:

setup deck expected triads

self.setup_deck(0)

[[1, 4, 9], [3, 7, 10]]

self.setup_deck(1)

[] # no triads`

self.setup_deck(2)

[[0, 3, 7], [1, 7, 10], [8, 9, 11]]

self.setup_deck(3)

[[0, 1, 9], [0, 2, 10], [1, 5, 8], [3, 6, 11], [4, 5, 7]]

self.setup_deck(9)

[[2, 5, 8]]

self.setup_deck(307)

[[0, 4, 8], [0, 6, 11], [1, 4, 9], [2, 6, 7], [2, 8, 11], [3, 5, 11], [4, 7, 11]]

self.setup_deck(15805)

[[0, 2, 8], [0, 6, 7], [1, 4, 7], [1, 5, 6], [2, 3, 6], [2, 7, 11], [3, 4, 10], [3, 8, 11], [5, 10, 11]]

self.setup_deck(212866)

[[0, 2, 9], [0, 4, 8], [0, 6, 7], [0, 10, 11], [2, 4, 7], [2, 6, 11], [2, 8, 10], [4, 6, 10], [4, 9, 11], [6, 8, 9], [7, 8, 11], [7, 9, 10]]

self.setup_deck(2524267)

[[0, 2, 5], [0, 3, 9], [0, 4, 10], [0, 6, 7], [1, 10, 11], [2, 3, 4], [2, 6, 10], [2, 7, 9], [3, 5, 6], [3, 7, 10], [4, 5, 7], [4, 6, 9], [5, 9, 10]]

self.setup_deck(21979307)

[[0, 1, 9], [0, 2, 6], [0, 3, 8], [0, 7, 11], [1, 2, 7], [1, 3, 11], [1, 6, 8], [2, 3, 9], [2, 4, 10], [2, 8, 11], [3, 6, 7], [4, 5, 9], [6, 9, 11], [7, 8, 9]]

The last line of the table above includes 14 possible Triads! That is the maximum number Triads you could ever have with this deck and 12 cards on the tableau.

Be sure you comment out the self.setup_deck line when you’re done testing!

exists_triad

You can test your exists_triad method using self.setup_deck(1), which you can see above returns no Triads.

Be sure you comment out the self.setup_deck line when you’re done testing!