User:Roelroscama/creativeIndustries/Game simulations: Difference between revisions

From XPUB & Lens-Based wiki
(Created page with "<source lang="python"> #!/usr/bin/python from random import randint amount_of_players = 1000 player_input = 1 app_winnings = 0 amount_of_games = 1 app = 0 x = dict.fromkeys(...")
 
No edit summary
 
Line 1: Line 1:
Lottery Models:
All chip in, one is paid. The facilitator is also paid (makes facilitator the big winner).
<source lang="python">
<source lang="python">
#!/usr/bin/python
#!/usr/bin/python

Latest revision as of 10:42, 29 May 2013

Lottery Models:

All chip in, one is paid. The facilitator is also paid (makes facilitator the big winner).

#!/usr/bin/python
from random import randint

amount_of_players = 1000
player_input = 1
app_winnings = 0
amount_of_games = 1
app = 0

x = dict.fromkeys(range(1, amount_of_players), 0)


def Lottery():
	global app
	#the actual lottery
	a = randint(1,amount_of_players-1)
	#substract 1 from all participants
	for value in x:
		x[value] -= player_input 
	#add all the substracted to the lucky one
	x[a] += ((len(x)*player_input)-app_winnings)
	for person, value in x.iteritems():
		print "person no", person, "now has", value
	app+=app_winnings


roundno = 0
for i in range(0,amount_of_games):
	print "round no", roundno
	Lottery()
	roundno+=1
	print '\n'
	print 'earnings for app', app
	print '\n'