Advertisement
WayGroovy

randombiome.py 1.3

Jun 20th, 2012
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 9.60 KB | None | 0 0
  1. #/usr/bin/env python
  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', '4', '5', '12', '13', '24', '48', '79', '80', '86', '98', '103', '110']
  10. groundblocks = ['1', '3', '4', '12', '13', '24', '48', '79', '80', '88', '89', '97', '98']
  11. oreblocks = ['CLAY', 'GRAVEL', '3', '14', '15', '16', '21', '46', '56', '73', '14', '15', '16', '21', '56', '73', '4', '19', '30', '73', '87', '88', '89']
  12. uw_oreblocks = ['CLAY', 'COAL_ORE', 'GOLD_ORE', 'SAND', '79', '49', '19', '30', '73', '87', '88', '89']
  13. plantblocks = ['RED_ROSE', 'YELLOW_FLOWER', 'LONG_GRASS', '104', '105']
  14. liquidblocks = ['Water', 'Lava']
  15. isleborders = ['Ocean', 'Desert', 'Forest', 'Plains', 'Taiga']
  16. treetypes = ['Tree', 'BigTree', 'Foreset', 'HugeMushroom', 'SwampTree', 'Taiga1', 'Taiga2', 'JungleTree', 'GroundBush']
  17. customheights = ['CustomHeightControl:0.0,0.0,-1000.0,-2500.0,-2500.0,-2500.0,-500.0,0.0,0.0,0.0,-3000.0,-3000.0,0.0,-10.0,-200.0,-2500.0,-3000.0,-1500.0,0.0,-200.0,-4500.0,-200.0,-500.0,-2500.0,-3000.0,-50.0,-20.0,250.0,500.0,-1500.0,-2500.0,500.0,-200.0', 'CustomHeightControl:0.0,-500.0,-1000.-1500,-2500.0,-2000.0,-1500.0,-500.0,150.0,500.0,1250.0,2000.1250,0.0,50.0,0.0,0.0,0.0,0.0', 'CustomHeightControl:0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.50,150.0,50.0,0.0,0.0,0.0,0.0,0.0', 'CustomHeightControl:0.0,-50.0,-150.0,-2500.0,-150.0,0.0,0.0,0.0,0.0,0.0,100.0,0.0,0.0,0.0,0.0,0.0,0.0', 'CustomHeightControl:0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,10.0,50.0,10.0,0.0,0.0,0.0,0.0', 'CustomHeightControl:0.0,-100.0,-200.0,-500.0,-750.0,-1250.0,-2500.0,-3000.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0', 'CustomHeightControl:0.0,3000.0,2500.0,2000.0,1500.0,1000.0,5000.0,2500.0,500.0,250.0,100.0,50.0,25.0,10.0,5.0,1.0,0.0']
  18.  
  19. def _vowel():
  20.     return random.choice(vowels)
  21.  
  22. def _consonant():
  23.     return random.choice(consonants)
  24.  
  25. def _cv():
  26.     return _consonant() + _vowel()
  27.  
  28. def _cvc():
  29.     return _cv() + _consonant()
  30.  
  31. def _syllable():
  32.     return random.choice([_vowel, _cv, _cvc])()
  33.  
  34. def create_fake_word():
  35.     syllables = []
  36.     for x in range(random.randint(1,2)):
  37.         syllables.append(_syllable())
  38.     return ''.join(syllables)
  39.  
  40. def _hexchar():
  41.     return random.choice(hexchar)
  42.  
  43. def _colorval():
  44.     colorvalues = []
  45.     for x in range(0,6):
  46.         colorvalues.append(_hexchar())
  47.     return ''.join(colorvalues)
  48.  
  49. def _minsize():
  50.     return abs(int(round(random.randint(1,25),0)))
  51.  
  52. def _maxsize():
  53.     return abs(int(round(random.randint(26,64),0)))
  54.  
  55. def _minalt():
  56.     return abs(int(round(random.randint(1,20),0)))
  57.  
  58. def _maxalt():
  59.     return abs(int(round(random.randint(51,64),0)))
  60.  
  61. def _frequency():
  62.     return abs(int(round(random.randint(1,25),0)))
  63.  
  64. def _rarity():
  65.     return abs(int(round(random.randint(1,25),0)))
  66.  
  67. def _oresize():
  68.     return abs(int(round(random.randint(4,64),0)))
  69.  
  70. def _dungeonfreq():
  71.     return abs(int(round(random.gauss(4, 16),0)))  
  72.  
  73. if __name__ == '__main__':
  74.     isisle = []
  75.     filename = 'Rand-'
  76.     if random.randint(0,10) > 6 :
  77.         isisle = 1
  78.         filename += 'Isle-'
  79.     filename += str.capitalize(create_fake_word())
  80.     filename += 'BiomeConfig.ini'
  81.     fo = open(filename, 'wb')
  82.     biomesize = 'BiomeSize:'
  83.     biomesize += str(int(round(random.gauss(5,0.5),1)))
  84.     fo.write(biomesize)
  85.     fo.write('\n')
  86.     biomerarity = 'BiomeRarity:'
  87.     biomerarity += str(int(abs(round(100-(random.lognormvariate(1,2))))))
  88.     fo.write(biomerarity)
  89.     fo.write('\n')
  90.     islebiome = ''
  91.     if isisle == 1 :
  92.         islebiome += random.choice(isleborders)
  93.     fo.write('IsleInBiome:')
  94.     fo.write (islebiome)
  95.     fo.write ('\n')
  96.     fo.write('BiomeIsBorder:')
  97.     fo.write('\n')
  98.     fo.write('NotBorderNear:')
  99.     notbordernear = ''
  100.     if isisle == 0 :
  101.         fo.write('Ocean')
  102.         for ia in range (0, random.randint(1,3)) :
  103.             notbordernear = random.choice(isleborders)
  104.             fo.write(',')
  105.             fo.write(notbordernear)
  106.     fo.write('\n')
  107.     biometemperature = 'BiomeTemperature:'
  108.     biometemperature += str(round(random.uniform(0.0, 1.1), 1))
  109.     fo.write(biometemperature)
  110.     fo.write('\n')
  111.     biomewetness = 'BiomeWetness:'
  112.     biomewetness += str(round(random.uniform(0.0, 1.1), 1))
  113.     fo.write(biomewetness)
  114.     fo.write('\n')
  115.     biomeheight = 'BiomeHeight:'
  116.     biomeheight += str(round(random.gauss(-1.8,0.4),1))
  117.     fo.write(biomeheight)
  118.     fo.write('\n')
  119.     biomevolatility = 'BiomeVolatility:'
  120.     biomevolatility += str(abs(round(random.gauss(0.1,0.3),1)))
  121.     fo.write(biomevolatility)
  122.     fo.write('\n')
  123.     maxaverageheight = 'MaxAverageHeight:'
  124.     maxaverageheight += str(abs(round(random.gauss(0.0,0.3), 1)))
  125.     fo.write(maxaverageheight)
  126.     fo.write('\n')
  127.     maxaveragedepth = 'MaxAverageDepth:'
  128.     maxaveragedepth += str(abs(round(random.gauss(0.0,0.3), 1)))
  129.     fo.write(maxaveragedepth)
  130.     fo.write('\n')
  131.     volatility1 = 'Volatility1:'
  132.     volatility1 += str(abs(round(random.gauss(0.0,1.0), 1)))
  133.     fo.write(volatility1)
  134.     fo.write('\n')
  135.     volatility2 = 'Volatility2:'
  136.     volatility2 += str(abs(round(random.gauss(0.0,1.0), 1)))
  137.     fo.write(volatility2)
  138.     fo.write('\n')
  139.     fo.write('DisableBiomeHeight:false')
  140.     fo.write('\n')
  141.     if random.randint(0,10) > 7 :
  142.         fo.write(random.choice(customheights))
  143.     else :
  144.         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')
  145.     fo.write('\n')
  146.     surfchance = random.randint(0,10)
  147.     surfaceblock = 'SurfaceBlock:'
  148.     if surfchance > 6 :
  149.         thissurfaceblock = random.choice(surfaceblocks)
  150.     elif surfchance < 1 :
  151.         thissurfaceblock = '87'
  152.     else :
  153.         thissurfaceblock = '2'
  154.     surfaceblock += thissurfaceblock
  155.     fo.write(surfaceblock)
  156.     fo.write('\n')
  157.     groundblock = 'GroundBlock:'
  158.     thisgroundblock = random.choice(groundblocks)
  159.     groundblock += thisgroundblock
  160.     fo.write(groundblock)
  161.     fo.write('\n')
  162.     fo.write('ReplacedBlocks:None')
  163.     fo.write('\n')
  164.     fo.write('disableNotchPonds:false')
  165.     fo.write('\n')
  166.     skycolor = ('SkyColor:0x')
  167.     skycolor += str(_colorval())
  168.     fo.write(skycolor)
  169.     fo.write('\n')
  170.     skycolor = ('SkyColor:0x')
  171.     skycolor += str(_colorval())
  172.     fo.write(skycolor)
  173.     fo.write('\n')
  174.     watercolor = ('WaterColor:0x')
  175.     watercolor += str(_colorval())
  176.     fo.write(watercolor)
  177.     fo.write('\n')
  178.     grasscolor = ('GrassColor:0x')
  179.     grasscolor += str(_colorval())
  180.     fo.write(grasscolor)
  181.     fo.write('\n')
  182.     foliagecolor = ('FoliageColor:0x')
  183.     foliagecolor+= str(_colorval())
  184.     fo.write(foliagecolor)
  185.     fo.write('\n')
  186.     dungeon = ('Dungeon(')
  187.     dungeon += str(_dungeonfreq())
  188.     dungeon += ',100,0,128)'
  189.     if random.randint(0,10) > 2 :
  190.         fo.write(dungeon)
  191.         fo.write('\n')
  192.     uglake = ('UnderGroundLake(')
  193.     uglake += str(_minsize())
  194.     uglake += (',')
  195.     uglake += str(_maxsize())
  196.     uglake += (',')
  197.     uglake += str(_frequency())
  198.     uglake += (',')
  199.     uglake += str(_rarity())
  200.     uglake += (',')
  201.     uglake += str(_minalt())
  202.     uglake += (',')
  203.     uglake += str(_maxalt())
  204.     uglake += (')')
  205.     if random.randint(0,10) > 2 :
  206.         fo.write(uglake)
  207.         fo.write('\n')
  208.     for i in range (0, random.randint(3,15)) :
  209.         ore = 'Ore('
  210.         ore += random.choice(oreblocks)
  211.         ore += ','
  212.         ore += str(_oresize())
  213.         ore += ','
  214.         ore += str(_frequency())
  215.         ore += ','
  216.         ore += str(_rarity())
  217.         ore += ','
  218.         ore += str(_minalt())
  219.         ore += ','
  220.         ore += str(_maxalt())
  221.         ore += ','
  222.         ore += thisgroundblock
  223.         ore += ')'
  224.         fo.write(ore)
  225.         fo.write('\n')
  226.     fo.write('UnderWaterOre(SAND,7,4,100,DIRT,GRASS)')
  227.     fo.write('\n')
  228.     fo.write('UnderWaterOre(CLAY,4,1,100,DIRT,CLAY)')
  229.     fo.write('\n')
  230.     fo.write('CustomObject()')
  231.     fo.write('\n')
  232.     treevar = ('Tree(')
  233.     treevar += str(random.randint(1,7))
  234.     treevar += ('0,')
  235.     treevar += random.choice(treetypes)
  236.     treevar += (',')
  237.     treevar += str(random.randint(1,5))
  238.     treevar += ('0,')
  239.     treevar += random.choice(treetypes)
  240.     treevar += (',')
  241.     treevar += str(random.randint(1,5))
  242.     treevar += ('0,Tree,')
  243.     treevar += str(random.randint(20,100))
  244.     treevar += (', ')
  245.     if thissurfaceblock == '2' :
  246.         if random.randint(0,10) > 3 :
  247.             fo.write(treevar)
  248.             fo.write('\n')
  249.         for ip in range (0, random.randint(0,4)) :
  250.             plantvar = ('Plant(')
  251.             plantvar += random.choice(plantblocks)
  252.             plantvar += (',2,100,0,128,GRASS,DIRT,SOIL)')
  253.             fo.write(plantvar)
  254.             fo.write('\n')
  255.         if random.randint(0,10) > 6 :
  256.             fo.write ('Grass(LONG_GRASS,1,10,100,GRASS,DIRT)')
  257.             fo.write ('\n')
  258.         if random.randint(0,10) > 6 :
  259.             fo.write ('Plant(PUMPKIN,1,3,0,128,GRASS)')
  260.             fo.write ('\n')
  261.         if random.randint(0,10) > 6 :
  262.             fo.write ('Plant(MELON,1,3,0,128,GRASS)')
  263.             fo.write ('\n')
  264.         if random.randint(0,10) > 6 :
  265.             fo.write ('Grass(LONG_GRASS,1,10,100,GRASS,DIRT)')
  266.             fo.write ('\n')
  267.     if random.randint(0,10) > 6 :
  268.         fo.write ('Liquid(WATER,20,100,8,128,STONE)')
  269.         fo.write ('\n')
  270.     if random.randint(0,10) > 6 :
  271.         fo.write ('Liquid(LAVA,10,100,8,128,STONE)')
  272.         fo.write ('\n')
  273.     fo.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement