Created
May 31, 2012 20:55
-
-
Save NikolasTzimoulis/2846200 to your computer and use it in GitHub Desktop.
Finds the best strategy for a simplistic decentralised POMDP game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import shuffle | |
from itertools import chain, combinations | |
def powerset(iterable): | |
"powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)" | |
s = list(iterable) | |
return chain.from_iterable(combinations(s, r) for r in range(len(s)+1)) | |
players = 15 | |
runs = 1000 | |
bestWins = 0 | |
bestRule = () | |
deck = range(1,11)*3 | |
for rule in powerset(range(1,11)): | |
wins = 0 | |
for i in range(runs): | |
shuffle(deck) | |
draw = deck[0:players+1] | |
showing = filter(lambda x: x in rule, draw) | |
if not showing: | |
continue | |
res = sum(showing) | |
if res > 10 and 1 <= res % 10 <= 5: | |
wins += 1 | |
print rule, 100 * wins / runs, "%" | |
if wins > bestWins: | |
bestWins = wins | |
bestRule = rule | |
print "Best:", bestRule, 100 * bestWins / runs, "%" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We have a deck of cards consisting of the numbers 1 through 10, four times (40 cards in total). | |
Each of you will be given one card from that deck, face down. Do not show your card to anyone! | |
Everyone simultaneously takes a decision: you either choose to turn over your card or leave it face down. | |
To win: The sum of the face up cards must be greater than 10 and the last digit must be 1 through 5; e.g.: | |
11, 12, 13, 14, 15 | |
21, 22, 23, 24, 25 | |
31, 32, 33, 34, 35 and so on... | |
The catch: You will have some time to collaboratively think and plan your strategy in advance. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment