Advertisement
WayGroovy

randombiome.py v1.2

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