Advertisement
Guest User

Untitled

a guest
Nov 30th, 2011
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. import random
  2.  
  3. a = 250 # set this number to your horizontal width
  4. b = 400 # set this number to your vertical width
  5.  
  6. horizontalSeed = [1]
  7. while len(horizontalSeed) != a: # creates a random list a tiles long, no repeating tiles, tiles 1 and 3 twice as likely
  8. x = [random.randint(1,10)]
  9. if x[0] == 2:
  10. x[0] = 1
  11. if x[0] == 4:
  12. x[0] = 3
  13. if horizontalSeed[len(horizontalSeed)-1] != x[0]:
  14. horizontalSeed = horizontalSeed + x
  15. totalList = [horizontalSeed]
  16.  
  17. verticalSeed = [1] #creates a vertical list with height b
  18. while len(verticalSeed) != b:
  19. y = [random.randint(1,10)]
  20. if y[0] == 2:
  21. y[0] = 1
  22. if y[0] == 4:
  23. y[0] = 3
  24. if verticalSeed[len(verticalSeed)-1] != y[0]:
  25. verticalSeed = verticalSeed + y
  26. while len(totalList) != b: # creates a big list of all the tiles along the top and left sides
  27. z = [verticalSeed[len(totalList)]]
  28. totalList = totalList + [z]
  29.  
  30. x = 1
  31.  
  32. 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
  33. y = 1
  34. while y < b:
  35. z = random.randint(1,10)
  36. if z == 2:
  37. z = 1
  38. if z == 4:
  39. z = 3
  40. if (z != totalList[y][x-1]) and (z != totalList[y-1][x]):
  41. totalList[y] = totalList[y] + [z]
  42. y = y + 1
  43. x = x + 1
  44. x = 0
  45. while x != a-1: # prints the list of tiles, one row at a time.
  46. print(totalList[x])
  47. x = x+ 1
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement