# # Animate the Markov Chain for the dimer model # Bryan Clair 2012 # import sys import DimerGrid, DimerDisplay print '1) Rectangle' print '2) Aztec Diamond' print '3) Parallelogram' print '4) Read from file' p = None while p == None: select = raw_input('Choose a shape:') if select == '1': width = int(raw_input('Width?')) height = int(raw_input('Height?')) p = DimerGrid.DimerGrid(width,height) elif select == '2': size = int(raw_input('Size?')) p = DimerGrid.AztecDiamond(size) elif select == '3': width = int(raw_input('Width?')) height = int(raw_input('Height?')) p = DimerGrid.ParallelogramGrid(width,height) elif select == '4': filename = raw_input('Filename?') shape = open(filename).read() p = DimerGrid.StringGrid(shape) p.fill() d = DimerDisplay.DimerDisplay(p) d.setUpdateFrequency(5) i=0 while True: val = p.onestep() if val: (x,y) = val d.update(x,y) i += 1 if i % 1000 == 0: print i,'steps. Tiles:',p.tilecounts()