-
Notifications
You must be signed in to change notification settings - Fork 3
henrikw/SetGame
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
SetGameSimulator simulates playing the game of SET®. It is inspired by Peter Norvig's blogpost entitled "The Odds of Finding a Set in The Card Game SET". However, it extends that simulation in several ways: the odds are tabulated per round played (not just the aggregated result), it lets you pick a selection mode (as opposed to picking the first Set found), and it shows some extra statistics such as average number of Sets available. Output from help: java SetGame -h SetGameSimulator simulates playing the game SET, and prints statistics from the simulation. In particular it prints how many times no Set is present among the cards on the table. Possible parameters: -n x x indicates the number of games to play (default is 10000) -sm x selection mode when there is more than one possible Set to pick from the table (default is 1): x=1 Pick the first found Set x=2 Pick randomly among the possible Sets x=3 Pick a Set where the most properties are the same -seed x x is the random number generator seed value. If none is given, a value is chosen and printed in the results. That way, the exact same simulation can be run again by giving the previous (printed) seed value as input argument -debug for each round in the game, prints the cards on the table, and the Set found -h help, prints this message and then stops the execution A sample run: java SetGame -n 100000 -sm 3 Total games played=100000, total rounds=2597160, took 83 seconds. Games that never needed 15 cards on the table: 31337 (31,3 percent of all games) Games where no cards remain on the table at the end: 1212 (1,2 percent of all games) Selection mode="Random among 'most similar' Sets" (3), seed=94394399 In deck | Set | NoSet | Set:NoSet for 12 | Avg # of Sets --------+-------+-------+------------------+------------- 69 | 96790 | 3210 | 30,2:1 | 2,78 66 | 94685 | 5271 | 18,0:1 | 2,52 63 | 93680 | 6250 | 15,0:1 | 2,43 60 | 93344 | 6586 | 14,2:1 | 2,40 57 | 93255 | 6685 | 13,9:1 | 2,38 54 | 93142 | 6786 | 13,7:1 | 2,37 51 | 93153 | 6770 | 13,8:1 | 2,38 48 | 93133 | 6795 | 13,7:1 | 2,38 45 | 93033 | 6896 | 13,5:1 | 2,37 42 | 93122 | 6796 | 13,7:1 | 2,37 39 | 92935 | 6974 | 13,3:1 | 2,36 36 | 92920 | 7009 | 13,3:1 | 2,36 33 | 92925 | 6991 | 13,3:1 | 2,36 30 | 92934 | 6984 | 13,3:1 | 2,35 27 | 92930 | 6971 | 13,3:1 | 2,36 24 | 92917 | 7006 | 13,3:1 | 2,35 21 | 92799 | 7115 | 13,0:1 | 2,35 18 | 92898 | 7007 | 13,3:1 | 2,34 15 | 92878 | 7056 | 13,2:1 | 2,35 12 | 92967 | 6946 | 13,4:1 | 2,35 9 | 92951 | 6969 | 13,3:1 | 2,34 6 | 92962 | 6962 | 13,4:1 | 2,35 3 | 93031 | 6881 | 13,5:1 | 2,35 0 | 92521 | 7409 | 12,5:1 | 2,35 In deck | Set | NoSet | Set:NoSet for 15 | Avg # of Sets --------+-------+-------+------------------+------------- 69 | 0 | 0 | oo:1 | - 66 | 3166 | 44 | 72,0:1 | 3,31 63 | 5245 | 70 | 74,9:1 | 3,33 60 | 6250 | 70 | 89,3:1 | 3,38 57 | 6596 | 60 | 109,9:1 | 3,35 54 | 6673 | 72 | 92,7:1 | 3,36 51 | 6781 | 77 | 88,1:1 | 3,37 48 | 6775 | 72 | 94,1:1 | 3,39 45 | 6796 | 71 | 95,7:1 | 3,36 42 | 6885 | 82 | 84,0:1 | 3,36 39 | 6787 | 91 | 74,6:1 | 3,33 36 | 6994 | 71 | 98,5:1 | 3,33 33 | 6996 | 84 | 83,3:1 | 3,35 30 | 6993 | 82 | 85,3:1 | 3,33 27 | 6967 | 99 | 70,4:1 | 3,34 24 | 6993 | 77 | 90,8:1 | 3,32 21 | 6997 | 86 | 81,4:1 | 3,32 18 | 7106 | 95 | 74,8:1 | 3,32 15 | 7036 | 66 | 106,6:1 | 3,36 12 | 7035 | 87 | 80,9:1 | 3,32 9 | 6953 | 80 | 86,9:1 | 3,33 6 | 6973 | 76 | 91,8:1 | 3,36 3 | 6950 | 88 | 79,0:1 | 3,32 0 | 6899 | 70 | 98,6:1 | 3,34 In deck | Set | NoSet | Set:NoSet for 18 | Avg # of Sets --------+-------+-------+------------------+------------- 69 | 0 | 0 | oo:1 | - 66 | 0 | 0 | oo:1 | - 63 | 44 | 0 | oo:1 | 5,23 60 | 70 | 0 | oo:1 | 5,33 57 | 70 | 0 | oo:1 | 5,83 54 | 60 | 0 | oo:1 | 5,58 51 | 72 | 0 | oo:1 | 5,39 48 | 77 | 0 | oo:1 | 5,47 45 | 72 | 0 | oo:1 | 5,50 42 | 71 | 0 | oo:1 | 5,39 39 | 82 | 0 | oo:1 | 5,24 36 | 91 | 0 | oo:1 | 5,43 33 | 71 | 0 | oo:1 | 5,54 30 | 84 | 0 | oo:1 | 5,49 27 | 82 | 0 | oo:1 | 5,32 24 | 99 | 0 | oo:1 | 5,17 21 | 77 | 0 | oo:1 | 5,35 18 | 86 | 0 | oo:1 | 5,09 15 | 95 | 0 | oo:1 | 5,39 12 | 66 | 0 | oo:1 | 5,61 9 | 87 | 0 | oo:1 | 5,16 6 | 80 | 0 | oo:1 | 5,59 3 | 76 | 0 | oo:1 | 5,51 0 | 88 | 0 | oo:1 | 5,48 In deck | Set | NoSet | Set:NoSet for 21 | Avg # of Sets --------+-------+-------+------------------+------------- 69 | 0 | 0 | oo:1 | - 66 | 0 | 0 | oo:1 | - 63 | 0 | 0 | oo:1 | - 60 | 0 | 0 | oo:1 | - 57 | 0 | 0 | oo:1 | - 54 | 0 | 0 | oo:1 | - 51 | 0 | 0 | oo:1 | - 48 | 0 | 0 | oo:1 | - 45 | 0 | 0 | oo:1 | - 42 | 0 | 0 | oo:1 | - 39 | 0 | 0 | oo:1 | - 36 | 0 | 0 | oo:1 | - 33 | 0 | 0 | oo:1 | - 30 | 0 | 0 | oo:1 | - 27 | 0 | 0 | oo:1 | - 24 | 0 | 0 | oo:1 | - 21 | 0 | 0 | oo:1 | - 18 | 0 | 0 | oo:1 | - 15 | 0 | 0 | oo:1 | - 12 | 0 | 0 | oo:1 | - 9 | 0 | 0 | oo:1 | - 6 | 0 | 0 | oo:1 | - 3 | 0 | 0 | oo:1 | - 0 | 0 | 0 | oo:1 | - Example of output when using debug (only showing a few rounds of the game). Each category (number, symbol, shading, colour) is represented by a 0, 1 or 2: java SetGame -n 1 -sm 3 -debug Round 1 deck size=69 table size=12 Table 0:1:1:2 0:1:1:1 2:0:2:0 2:0:2:2 2:0:0:1 1:1:0:2 1:1:2:1 2:2:1:2 0:0:2:0 2:2:0:2 0:1:2:2 2:0:1:1 Found 0 Sets: No Sets found!!! Round 2 deck size=66 table size=15 Table 0:1:1:2 0:1:1:1 2:0:2:0 2:0:2:2 2:0:0:1 1:1:0:2 1:1:2:1 2:2:1:2 0:0:2:0 2:2:0:2 0:1:2:2 2:0:1:1 1:1:0:1 2:2:2:0 2:0:0:2 Found 2 Sets: Set 1 (chosen) 2:0:2:0 2:0:1:1 2:0:0:2 Set 2 2:2:1:2 0:0:2:0 1:1:0:1 Round 3 deck size=66 table size=12 Table 0:1:1:2 0:1:1:1 2:0:2:2 2:0:0:1 1:1:0:2 1:1:2:1 2:2:1:2 0:0:2:0 2:2:0:2 0:1:2:2 1:1:0:1 2:2:2:0 Found 1 Sets: Set 1 (chosen) 2:2:1:2 0:0:2:0 1:1:0:1 SET is a registered trademark of Cannei, LLC. Used with permission from Set Enterprises, Inc.
About
Simulate playing the game of SET® in order to get the probabilities of not finding a SET.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published