def main(): parser = optparse.OptionParser() parser.add_option("-t", dest="trials", type="int", default="1000") options, args = parser.parse_args() trials = options.trials count = 0 stop_dictionary = collections.defaultdict(int) for i in xrange(trials): foo = no_set.SetGame(with_replacement=False) draws = 0 hand = no_set.exists_set(foo.get_board()) while hand: if len(foo.cards) == 0: #print "board: %s" % foo.get_board() partition = no_set.exists_partition(foo.get_board()) if partition: #print "partition: %s" % partition count += 1 break foo.play_set(*hand) hand = no_set.exists_set(foo.get_board()) draws += 1 stop_dictionary[draws] += 1 print "Count of perfect games: %d, Percentage of perfect games: %f" % (count, count/float(trials)) print stop_dictionary
def main(): parser = optparse.OptionParser() parser.add_option("-t", dest="trials", type="int", default="1000") options, args = parser.parse_args() trials = options.trials draws_count = collections.defaultdict(int) for i in xrange(trials): foo = no_set.SetGame(with_replacement=False) hand = no_set.exists_set(foo.get_board()) count = 0 while hand: foo.play_set(*hand) count += 1 hand = no_set.exists_set(foo.get_board()) draws_count[count] += 1 print draws_count
def main(): parser = optparse.OptionParser() parser.add_option("-t", dest="trials", type="int", default="1000") parser.add_option("-d", dest="draw", type="int", default="1") options, args = parser.parse_args() trials = options.trials draw = options.draw has_set = 0 for i in xrange(trials): foo = no_set.SetGame(with_replacement=False) for k in xrange(1,draw): foo.get_board() foo.wipe_board() if no_set.exists_set(foo.get_board()): has_set += 1 existence_prob = has_set/float(trials) print "Trials: %d, Draw: %d" % (trials, draw) print "Probability of a set existing in the %dth draw: %f" % (draw, existence_prob) print "Probability of a set not existing in the %dth draw: %f" % (draw, 1 - existence_prob) print "1/33: %f" % (1.0/33.0)