Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os, time
- rw = 20
- rh = 20
- w = rw + 2
- h = rh + 2
- dishno = 1
- expo = 0
- score = 0
- dish = []
- dish = [[[0 for x in range(w)] for y in range(h)]for z in range(2)]
- dish [1][4][4]
- def frame():
- countx = 0
- county = 0
- score = 0
- global w, h, rh, rw, dish, dishno, expo, score
- #choosedish
- if dishno == 1:
- dishno = 0
- expo = 1
- else:
- dishno = 1
- expo = 0
- #counter
- while ((county*rw) + countx) < (rw*rh):
- score = 1
- countx += 1
- #
- if countx >= rw:
- countx = 0
- county += 1
- #print countx + (county*rw)
- #print countx
- #print county
- #search value
- if dish[dishno][county-1][countx-1] == 1:
- score += 1
- if dish[dishno][county-1][countx] == 1:
- score += 1
- if dish[dishno][county-1][countx+1] == 1:
- score += 1
- if dish[dishno][county][countx-1] == 1:
- score += 1
- if dish[dishno][county][countx+1] == 1:
- score += 1
- if dish[dishno][county+1][countx-1] == 1:
- score += 1
- if dish[dishno][county+1][countx] == 1:
- score += 1
- if dish[dishno][county+1][countx+1] == 1:
- score += 1
- #print dish[dishno][county][countx]
- #print score
- if dish[dishno][county][countx] == 0 and score == 3:
- dish[expo][county][countx] = 1
- if dish[dishno][county][countx] == 1 and (score <= 3 and score >= 2):
- dish[expo][county][countx] = 1
- if dish[dishno][county][countx] == 1 and (score > 3 and score < 2):
- dish[expo][county][countx] = 0
- def printdish():
- wipe()
- i = 1
- global rh, rw, dish
- while i < rh:
- print str(dish[expo][i][1:rw])
- i += 1
- print expo, dishno,score
- def wipe():
- os.system(['clear','cls'][os.name == 'nt'])
- dish[0][10][10] = 1
- dish[0][11][10] = 1
- dish[0][12][10] = 1
- dish[0][13][10] = 0
- while 1==1:
- printdish()
- frame()
- raw_input('')
Add Comment
Please, Sign In to add comment