import random

class Monop:

	GO = 0
	JAIL = 10
	G2J = 30

	C1 = 11
	E3 = 24
	H2 = 39
	R1 = 5

	CC1 = 2 
	CC2 = 17
	CC3 = 33
	CH1 = 7
	CH2 = 22
	CH3 = 36

	R1 = 5
	R2 = 15
	R3 = 25
	R4 = 35

	U1 = 12
	U2 = 28

	NEXT_R = -2
	NEXT_U = -3
	BACK_3 = -4
	BLANK = -1

	current = 0
	cc = [GO, JAIL] + [BLANK]*14
	ch = [GO, JAIL, C1, E3, H2, R1, NEXT_R, NEXT_R, NEXT_U, BACK_3] + [BLANK]*6
	ccI = 0 #index for community chest
	chI = 0 #index for chance
	doublesCount = 0

	freq = [0] * 40

	random.seed(1)
	def roll(self):
		r1 = random.randint(1, 4)
		r2 = random.randint(1, 4)
		if r1 == r2:
			self.doublesCount = self.doublesCount + 1
		else:
			self.doublesCount = 0
		return r1 + r2
	
	def step(self):
		r = self.roll()
		self.current = (self.current + r) % 40
		if self.doublesCount == 3:
			self.doublesCount = 0
			self.current = self.JAIL
		
		if self.current in [self.CC1, self.CC2, self.CC3]:
			if self.cc[self.ccI] != self.BLANK:
				self.current = self.cc[self.ccI]
			self.ccI = (self.ccI + 1) % 16
		elif self.current in [self.CH1, self.CH2, self.CH3]:
			if self.ch[self.chI] == self.NEXT_R:
				if self.current == self.CH1:
					self.current = self.R2
				elif self.current == self.CH2:
					self.current = self.R3
				elif self.current == self.CH3:
					self.current = self.R1
			elif self.ch[self.chI] == self.NEXT_U:
				if self.current == self.CH1:
					self.current = self.U1
				elif self.current == self.CH2:
					self.current = self.U2
				elif self.current == self.CH3:
					self.current = self.U1
			elif self.ch[self.chI] == self.BACK_3:
				self.current = self.current - 3
				if self.current < 0:
					self.current = self.current + 40
			elif self.ch[self.chI] == self.BLANK:
				pass
			else:
				self.current = self.ch[self.chI]
			self.chI = (self.chI + 1) % 16
		elif self.current == self.G2J:
			self.current = self.JAIL
		else:
			pass
		self.freq[self.current] = self.freq[self.current] + 1


def main():
	m = Monop()
	i = 0
	N = 10000000
	while i < N:
		m.step()
		i = i + 1
	s = sorted(m.freq)
	first = s[-1]
	second = s[-2]
	third = s[-3]
	
	print m.freq.index(s[-1])
	print m.freq.index(s[-2])
	print m.freq.index(s[-3])
	print [100.0 * f / N for f in m.freq]
	
main()

