Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- a = 250 # set this number to your horizontal width
- b = 400 # set this number to your vertical width
- horizontalSeed = [1]
- while len(horizontalSeed) != a: # creates a random list a tiles long, no repeating tiles, tiles 1 and 3 twice as likely
- x = [random.randint(1,10)]
- if x[0] == 2:
- x[0] = 1
- if x[0] == 4:
- x[0] = 3
- if horizontalSeed[len(horizontalSeed)-1] != x[0]:
- horizontalSeed = horizontalSeed + x
- totalList = [horizontalSeed]
- verticalSeed = [1] #creates a vertical list with height b
- while len(verticalSeed) != b:
- y = [random.randint(1,10)]
- if y[0] == 2:
- y[0] = 1
- if y[0] == 4:
- y[0] = 3
- if verticalSeed[len(verticalSeed)-1] != y[0]:
- verticalSeed = verticalSeed + y
- while len(totalList) != b: # creates a big list of all the tiles along the top and left sides
- z = [verticalSeed[len(totalList)]]
- totalList = totalList + [z]
- x = 1
- while x < a: # goes from top to bottom then left to right, checking the tiles on top and to the left, adding one in if it is different
- y = 1
- while y < b:
- z = random.randint(1,10)
- if z == 2:
- z = 1
- if z == 4:
- z = 3
- if (z != totalList[y][x-1]) and (z != totalList[y-1][x]):
- totalList[y] = totalList[y] + [z]
- y = y + 1
- x = x + 1
- x = 0
- while x != a-1: # prints the list of tiles, one row at a time.
- print(totalList[x])
- x = x+ 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement