Advertisement
WayGroovy

random biome py

May 18th, 2012
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.46 KB | None | 0 0
  1. #
  2.  
  3. import random
  4. import sys
  5.  
  6. vowels = ['a', 'e', 'i', 'o', 'u']
  7. consonants = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z']
  8. hexchar = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']
  9. surfaceblocks = ['1', '2', '3', '1', '2', '3', '1', '2', '3', '1', '2', '3', '1', '2', '3', '2', '3', '2', '3', '2', '3', '2', '3', '3', '3', '3', '3', '4', '5', '12', '13', '17', '18', '19', '20', '24', '25', '35', '43', '45', '47', '48', '60', '79', '80', '86', '87', '88', '89', '87', '88', '89', '87', '88', '89', '87', '88', '89', '87', '88', '89', '97', '98', '103', '110', '112', '123', '125']
  10. groundblocks = ['1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '2', '3', '4', '5', '12', '13', '17', '18', '19', '20', '24', '25', '35', '43', '45', '47', '48', '60', '79', '80', '86', '87', '88', '89', '97', '98', '103', '110', '112', '123', '125']
  11. oreblocks = ['CLAY', 'GRAVEL', '3', '14', '15', '16', '21', '56', '14', '15', '16', '21', '56', '4', '19', '30', '73', '87', '88', '89']
  12. uw_oreblocks = ['CLAY', 'COAL_ORE', 'GOLD_ORE', 'SAND', '79', '49']
  13. plantblocks = ['RED_ROSE', 'YELLOW_FLOWER', 'LONG_GRASS', '104', '105', '89']
  14. liquidblocks = ['Water', 'Lava']
  15. treetypes = ['Tree', 'BigTree', 'Foreset', 'HugeMushroom', 'SwampTree', 'Taiga1', 'Taiga2', 'JungleTree', 'GroundBush']
  16.  
  17. def _vowel():
  18. return random.choice(vowels)
  19.  
  20. def _consonant():
  21. return random.choice(consonants)
  22.  
  23. def _cv():
  24. return _consonant() + _vowel()
  25.  
  26. def _cvc():
  27. return _cv() + _consonant()
  28.  
  29. def _syllable():
  30. return random.choice([_vowel, _cv, _cvc])()
  31.  
  32. def create_fake_word():
  33. """ This function generates a fake word by creating between two and three
  34. random syllables and then joining them together.
  35. """
  36. syllables = []
  37. for x in range(random.randint(3,5)):
  38. syllables.append(_syllable())
  39. return ''.join(syllables)
  40.  
  41. def _hexchar():
  42. return random.choice(hexchar)
  43.  
  44. def _colorval():
  45. colorvalues = []
  46. for x in range(0,6):
  47. colorvalues.append(_hexchar())
  48. return ''.join(colorvalues)
  49.  
  50. def _minsize():
  51. return abs(int(round(random.randint(1,50),0)))
  52.  
  53. def _maxsize():
  54. return abs(int(round(random.randint(51,128),0)))
  55.  
  56. def _minalt():
  57. return abs(int(round(random.randint(1,50),0)))
  58.  
  59. def _maxalt():
  60. return abs(int(round(random.randint(51,128),0)))
  61.  
  62. def _frequency():
  63. return abs(int(round(random.randint(1,25),0)))
  64.  
  65. def _rarity():
  66. return abs(int(round(random.randint(1,25),0)))
  67.  
  68. def _oresize():
  69. return abs(int(round(random.randint(4,64),0)))
  70.  
  71. def _dungeonfreq():
  72. return abs(int(round(random.gauss(4, 16),0)))
  73.  
  74. if __name__ == '__main__':
  75. filename = str.capitalize(create_fake_word())
  76. filename += 'BiomeConfig.ini'
  77. fo = open(filename, 'wb')
  78. biomesize = 'BiomeSize:'
  79. biomesize += str(random.randint(3,10))
  80. fo.write(biomesize)
  81. fo.write('\n')
  82. biomerarity = 'BiomeRarity:'
  83. biomerarity += str(random.randint(25,75))
  84. fo.write(biomerarity)
  85. fo.write('\n')
  86. fo.write('BiomeIsBorder:')
  87. fo.write('\n')
  88. fo.write('NotBorderNear:')
  89. fo.write('\n')
  90. biometemperature = 'BiomeTemperature:'
  91. biometemperature += str(round(random.uniform(0.0, 1.1), 1))
  92. fo.write(biometemperature)
  93. fo.write('\n')
  94. biomewetness = 'BiomeWetness:'
  95. biomewetness += str(round(random.uniform(0.0, 1.1), 1))
  96. fo.write(biomewetness)
  97. fo.write('\n')
  98. biomeheight = 'BiomeHeight:'
  99. biomeheight += str(round(random.gauss(0.0,3.0),1))
  100. fo.write(biomeheight)
  101. fo.write('\n')
  102. biomevolatility = 'BiomeVolatility:'
  103. biomevolatility += str(round(random.gauss(0.5,1.1),1))
  104. fo.write(biomevolatility)
  105. fo.write('\n')
  106. maxaverageheight = 'MaxAverageHeight:'
  107. maxaverageheight += str(round(random.gauss(0.0, 3.0), 1))
  108. fo.write(maxaverageheight)
  109. fo.write('\n')
  110. maxaveragedepth = 'MaxAverageDepth:'
  111. maxaveragedepth += str(round(random.gauss(0.0, 3.0), 1))
  112. fo.write(maxaveragedepth)
  113. fo.write('\n')
  114. volatility1 = 'Volatility1:'
  115. volatility1 += str(round(random.gauss(0.0, 3.0), 1))
  116. fo.write(volatility1)
  117. fo.write('\n')
  118. volatility2 = 'Volatility2:'
  119. volatility2 += str(round(random.gauss(0.0, 3.0), 1))
  120. fo.write(volatility2)
  121. fo.write('\n')
  122. fo.write('DisableBiomeHeight:false')
  123. fo.write('\n')
  124. fo.write('CustomHeightControl:0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0')
  125. fo.write('\n')
  126. surfaceblock = 'SurfaceBlock:'
  127. thissurfaceblock = random.choice(surfaceblocks)
  128. surfaceblock += thissurfaceblock
  129. fo.write(surfaceblock)
  130. fo.write('\n')
  131. groundblock = 'GroundBlock:'
  132. thisgroundblock = random.choice(groundblocks)
  133. groundblock += thisgroundblock
  134. fo.write(groundblock)
  135. fo.write('\n')
  136. fo.write('ReplacedBlocks:None')
  137. fo.write('\n')
  138. fo.write('disableNotchPonds:false')
  139. fo.write('\n')
  140. skycolor = ('SkyColor:0x')
  141. skycolor += str(_colorval())
  142. fo.write(skycolor)
  143. fo.write('\n')
  144. skycolor = ('SkyColor:0x')
  145. skycolor += str(_colorval())
  146. fo.write(skycolor)
  147. fo.write('\n')
  148. watercolor = ('WaterColor:0x')
  149. watercolor += str(_colorval())
  150. fo.write(watercolor)
  151. fo.write('\n')
  152. grasscolor = ('GrassColor:0x')
  153. grasscolor += str(_colorval())
  154. fo.write(grasscolor)
  155. fo.write('\n')
  156. foliagecolor = ('FoliageColor:0x')
  157. foliagecolor+= str(_colorval())
  158. fo.write(foliagecolor)
  159. fo.write('\n')
  160. dungeon = ('Dungeon(')
  161. dungeon += str(_dungeonfreq())
  162. dungeon += ',100,0,128)'
  163. if random.randint(0,10) > 2 :
  164. fo.write(dungeon)
  165. fo.write('\n')
  166. uglake = ('UnderGroundLake(')
  167. uglake += str(_minsize())
  168. uglake += (',')
  169. uglake += str(_maxsize())
  170. uglake += (',')
  171. uglake += str(_frequency())
  172. uglake += (',')
  173. uglake += str(_rarity())
  174. uglake += (',')
  175. uglake += str(_minalt())
  176. uglake += (',')
  177. uglake += str(_maxalt())
  178. uglake += (')')
  179. if random.randint(0,10) > 2 :
  180. fo.write(uglake)
  181. fo.write('\n')
  182. for i in range (0, random.randint(3,15)) :
  183. ore = 'Ore('
  184. ore += random.choice(oreblocks)
  185. ore += ','
  186. ore += str(_oresize())
  187. ore += ','
  188. ore += str(_frequency())
  189. ore += ','
  190. ore += str(_rarity())
  191. ore += ','
  192. ore += str(_minalt())
  193. ore += ','
  194. ore += str(_maxalt())
  195. ore += ','
  196. ore += thisgroundblock
  197. ore += ')'
  198. fo.write(ore)
  199. fo.write('\n')
  200. fo.write('UnderWaterOre(SAND,7,4,100,DIRT,GRASS)')
  201. fo.write('\n')
  202. fo.write('UnderWaterOre(CLAY,4,1,100,DIRT,CLAY)')
  203. fo.write('\n')
  204. fo.write('CustomObject()')
  205. fo.write('\n')
  206. treevar = ('Tree(')
  207. treevar += str(random.randint(1,7))
  208. treevar += ('0,')
  209. treevar += random.choice(treetypes)
  210. treevar += (',')
  211. treevar += str(random.randint(1,7))
  212. treevar += ('0,')
  213. treevar += random.choice(treetypes)
  214. treevar += (',')
  215. treevar += str(random.randint(1,7))
  216. treevar += ('0,Tree,100)')
  217. if random.randint(0,10) > 4 :
  218. fo.write(treevar)
  219. fo.write('\n')
  220.  
  221.  
  222. fo.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement