Exemple #1
0
 def test_find_sets3(self):
     for i in range(100):
         cards = sets_solver.random_cards()
         sets = sets_solver.find_sets(cards)
         sets3 = sets_solver.find_sets3(cards)
         for s in sets3:
             s = list(s)
             s.sort()
             self.assertTrue(tuple(s) in sets)
Exemple #2
0
 def test_find_sets3(self):
     for i in range(100):
         cards = sets_solver.random_cards()
         sets = sets_solver.find_sets(cards)
         sets3 = sets_solver.find_sets3(cards)
         for s in sets3:
             s = list(s)
             s.sort()
             self.assertTrue(tuple(s) in sets)
Exemple #3
0
 def test_find_sets2(self):
     for i in range(100):
         cards = sets_solver.random_cards()
         sets = sets_solver.find_sets(cards)
         sets2 = sets_solver.find_sets2(cards)
         self.assertEqual(sets, sets2)
Exemple #4
0
import pylab
import scipy
from sets_solver import find_sets2, one_game, random_cards

# distribution of number of sets in random draws with 15 cards
nsolutions_indep = []
for i in range(150000):
    cards = random_cards(ncards=15)
    nsolutions_indep.append(len(find_sets2(cards)))

pylab.gcf().set_size_inches(11, 6.4)
freq, bins, _ = pylab.hist(nsolutions_indep,
                           bins=range(-1, 14),
                           normed=1,
                           hold=0)
pylab.draw()
print 'Prob of 0 sets for the independent case', freq[
    1], 'or 1 in', 1. / freq[1]
#('Prob of 0 sets for the independent case', 0.00038668213395202477, 'or 1 in', 2586.1034482758619)

nsolutions = []
n15 = []
for i in range(5000):
    count15 = 0
    for cards in one_game():
        if cards.shape[1] > 12:
            count15 += 1
            nsolutions.append(len(find_sets2(cards)))
    n15.append(count15)

pylab.gcf().set_size_inches(11, 6.4)
Exemple #5
0
import pylab
from sets_solver import find_sets2, one_game, random_cards

# distribution of number of sets in random draws
nsolutions_indep = []
for i in range(10000):
    cards = random_cards()
    nsolutions_indep.append(len(find_sets2(cards)))
freq, bins, _ = pylab.hist(nsolutions_indep,
                           bins=range(-1, 14),
                           normed=1,
                           hold=0)
print 'Prob of 0 sets for the independent case', freq[
    1], 'or 1 in', 1. / freq[1]

# distribution of number of sets during a game
nsolutions = []
for i in range(5000):
    for cards in one_game():
        nsolutions.append(len(find_sets2(cards)))

freq, bins, _ = pylab.hist(nsolutions, bins=range(-1, 14), normed=1, hold=0)
print 'Prob of 0 sets for the game case', freq[1], 'or 1 in', 1. / freq[1]

# TODO: are there correlations within games?
Exemple #6
0
import pylab
from sets_solver import find_sets2, one_game, random_cards


# distribution of number of sets in random draws
nsolutions_indep = []
for i in range(10000):
    cards = random_cards()
    nsolutions_indep.append(len(find_sets2(cards)))
freq, bins, _ = pylab.hist(nsolutions_indep, bins=range(-1,14), normed=1, hold=0)
print 'Prob of 0 sets for the independent case', freq[1], 'or 1 in', 1./freq[1]

# distribution of number of sets during a game
nsolutions = []
for i in range(5000):
    for cards in one_game():
        nsolutions.append(len(find_sets2(cards)))

freq, bins, _ = pylab.hist(nsolutions, bins=range(-1,14), normed=1, hold=0)
print 'Prob of 0 sets for the game case', freq[1], 'or 1 in', 1./freq[1]

# TODO: are there correlations within games?
Exemple #7
0
 def test_find_sets2(self):
     for i in range(100):
         cards = sets_solver.random_cards()
         sets = sets_solver.find_sets(cards)
         sets2 = sets_solver.find_sets2(cards)
         self.assertEqual(sets, sets2)
Exemple #8
0
import pylab
import scipy
from sets_solver import find_sets2, one_game, random_cards

# distribution of number of sets in random draws with 15 cards
nsolutions_indep = []
for i in range(150000):
    cards = random_cards(ncards=15)
    nsolutions_indep.append(len(find_sets2(cards)))

pylab.gcf().set_size_inches(11, 6.4)
freq, bins, _ = pylab.hist(nsolutions_indep, bins=range(-1,14), normed=1, hold=0)
pylab.draw()
print 'Prob of 0 sets for the independent case', freq[1], 'or 1 in', 1./freq[1]
#('Prob of 0 sets for the independent case', 0.00038668213395202477, 'or 1 in', 2586.1034482758619)

nsolutions = []
n15 = []
for i in range(5000):
    count15 = 0
    for cards in one_game():
        if cards.shape[1] > 12:
            count15 += 1
            nsolutions.append(len(find_sets2(cards)))
    n15.append(count15)

pylab.gcf().set_size_inches(11, 6.4)
freq, bins, _ = pylab.hist(nsolutions, bins=range(-1,14), normed=1, hold=0)
pylab.draw()
print 'Prob of 0 sets for 15 cards', freq[1], 'or 1 in', 1./freq[1]
# ('Prob of 0 sets for 15 cards', 0.010681255698840693, 'or 1 in', 93.621951219512198)