コード例 #1
0
def generateTerrainTypes():
    NiTextOut("Generating Terrain (Python Archipelago) ...")
    terraingen = TerrainGenerator()
    terrainTypes = terraingen.generateTerrain()
    rTerrain = []
    b = 0
    for a in terrainTypes:
        if heightMap[b] != 1:
            rTerrain.append(2)  # Desert
        elif a == 3 or a == 4:  # Tundra or snow
            rTerrain.append(0)  # Grassland
        else:
            rTerrain.append(a)
        b = b + 1
    return rTerrain
コード例 #2
0
def generateTerrainTypes():

    #JAM3 Declare Globals and pass them to the TerrainGenerator
    global iGlobalDesertMenu
    global iGlobalPlainsMenu
    global iGlobalClumpingMenu

    NiTextOut("Generating Terrain (Python Custom Continents) ...")

    iLocalDesertPercent = 32
    iLocalPlainsPercent = 18
    iLocalClumpingMenu = iGlobalClumpingMenu

    # advc.mxc (note): These two if/elif blocks don't do anything b/c the global values are 0. I'm leaving them alone to make it easy to re-enable the plains and desert options.
    if iGlobalDesertMenu == 0:
        iLocalDesertPercent = 32
    elif iGlobalDesertMenu == 1:
        iLocalDesertPercent = 24
    elif iGlobalDesertMenu == 2:
        iLocalDesertPercent = 21
    elif iGlobalDesertMenu == 3:
        iLocalDesertPercent = 16
    elif iGlobalDesertMenu == 4:
        iLocalDesertPercent = 11
    elif iGlobalDesertMenu == 5:
        iLocalDesertPercent = 8

    if iGlobalPlainsMenu == 0:
        iLocalPlainsPercent = 18
    elif iGlobalPlainsMenu == 1:
        iLocalPlainsPercent = 22
    elif iGlobalPlainsMenu == 2:
        iLocalPlainsPercent = 24
    elif iGlobalPlainsMenu == 3:
        iLocalPlainsPercent = 27
    elif iGlobalPlainsMenu == 4:
        iLocalPlainsPercent = 30
    elif iGlobalPlainsMenu == 5:
        iLocalPlainsPercent = 32

    #terraingen = TerrainGenerator(iLocalDesertPercent, iLocalPlainsPercent, 0.8, 0.7, 0.1, 0.2, 0.5, -1, -1, iLocalClumpingMenu)
    # advc.mxc: Was using fSnowLatitude=0.8, fTundraLatitude=0.7. I agree that the Warlords values (0.7 and 0.6 respectively) are too low, but the new values are too high. advc.tsl sets realistic latitude thresholds in CvMapGeneratorUtil.py, so we should just use those default values.
    terraingen = TerrainGenerator(iDesertPercent=iLocalDesertPercent,
                                  iPlainsPercent=iLocalPlainsPercent,
                                  grain_amount=iLocalClumpingMenu)

    terrainTypes = terraingen.generateTerrain()
    return terrainTypes
コード例 #3
0
def generateTerrainTypes():

	#JAM3 Declare Globals and pass them to the TerrainGenerator
	global iGlobalDesertMenu
	global iGlobalPlainsMenu
	global iGlobalClumpingMenu

	NiTextOut("Generating Terrain (Python Custom Continents) ...")

	iLocalDesertPercent = 32
	iLocalPlainsPercent = 18
	iLocalClumpingMenu = iGlobalClumpingMenu

	if iGlobalDesertMenu == 0:
		iLocalDesertPercent = 32
	elif iGlobalDesertMenu == 1:
		iLocalDesertPercent = 24
	elif iGlobalDesertMenu == 2:
		iLocalDesertPercent = 21
	elif iGlobalDesertMenu == 3:
		iLocalDesertPercent = 16
	elif iGlobalDesertMenu == 4:
		iLocalDesertPercent = 11
	elif iGlobalDesertMenu == 5:
		iLocalDesertPercent = 8


	if iGlobalPlainsMenu == 0:
		iLocalPlainsPercent = 18
	elif iGlobalPlainsMenu == 1:
		iLocalPlainsPercent = 22
	elif iGlobalPlainsMenu == 2:
		iLocalPlainsPercent = 24
	elif iGlobalPlainsMenu == 3:
		iLocalPlainsPercent = 27
	elif iGlobalPlainsMenu == 4:
		iLocalPlainsPercent = 30
	elif iGlobalPlainsMenu == 5:
		iLocalPlainsPercent = 32


	terraingen = TerrainGenerator(iLocalDesertPercent, iLocalPlainsPercent, 0.8, 0.7, 0.1, 0.2, 0.5, -1, -1, iLocalClumpingMenu)
	terrainTypes = terraingen.generateTerrain()
	return terrainTypes
コード例 #4
0
def generateTerrainTypes():
    map = CyMap()
    NiTextOut("Generating Terrain (Python Archipelago) ...")
    terraingen = TerrainGenerator()
    terrainTypes = terraingen.generateTerrain()
    rTerrain = []
    b = 0
    nonArableType = 2  # Desert
    if (map.getCustomMapOption(3) == 1):
        nonArableType = 4  # Snow
    elif (map.getCustomMapOption(3) == 2):
        nonArableType = 5  # Coast
    for a in terrainTypes:
        if heightMap[b] != 1:
            rTerrain.append(nonArableType)
        elif a == 3 or a == 4:  # Tundra or snow
            rTerrain.append(0)  # Grassland
        else:
            rTerrain.append(a)
        b = b + 1
    return rTerrain
コード例 #5
0
ファイル: Hemispheres.py プロジェクト: rytisbitcoin/AdvCiv
def generateTerrainTypes():
	NiTextOut("Generating Terrain (Python Custom Continents) ...")
	terraingen = TerrainGenerator()
	terrainTypes = terraingen.generateTerrain()
	return terrainTypes
コード例 #6
0
def generateTerrainTypes():
	NiTextOut("Generating Terrain (Python Global Highlands) ...")
	terraingen = TerrainGenerator()
	terrainTypes = terraingen.generateTerrain()
	return terrainTypes
コード例 #7
0
def generateTerrainTypes():
	NiTextOut("Generating Terrain (Python Custom Continents) ...")
	terraingen = TerrainGenerator()
	terrainTypes = terraingen.generateTerrain()
	return terrainTypes
コード例 #8
0
def generateTerrainTypes():
	NiTextOut("Generating Terrain (Python Terra) ...")
	terraingen = TerrainGenerator()
	terrainTypes = terraingen.generateTerrain()
	return terrainTypes
コード例 #9
0
def generateTerrainTypes():
	# Run a check for cohesion failure.
	# If the largest land area contains less than 80% of the land (Natural/Pressed),
	# or less than 90% of the land (Solid), add a third layer of fractal terrain
	# to try to link the main landmasses in to a true Pangaea.
	map = CyMap()
	dice = CyGame().getMapRand()
	iHorzFlags = CyFractal.FracVals.FRAC_WRAP_X + CyFractal.FracVals.FRAC_POLAR
	biggest_area = map.findBiggestArea(false)
	global terrainRoll
	userInputShoreline = map.getCustomMapOption(0)
	iTotalLandPlots = map.getLandPlots()
	iBiggestAreaPlots = biggest_area.getNumTiles()
	#print("Total Land: ", iTotalLandPlots, " Main Landmass Plots: ", iBiggestAreaPlots)
	if (userInputShoreline == 1 or userInputShoreline == 2 or (userInputShoreline == 0 and terrainRoll < 7)) and iBiggestAreaPlots < 0.8 * iTotalLandPlots:
		global pangaea_type
		print("Total Land: ", iTotalLandPlots, " Main Landmass Plots: ", iBiggestAreaPlots)
		print "Cohesion failure! Attempting to remedy..."
		#print("Pangaea Type: ", pangaea_type)
		iW = map.getGridWidth()
		iH = map.getGridHeight()
		iWestX = int(0.3 * iW)
		eastX = int(0.7 * iW)
		southLat = 0.4
		northLat = 0.6
		if pangaea_type == 0: # Natural
			global shiftRoll
			#print("Shift Roll: ", shiftRoll)
			if shiftRoll == 1:
				southLat += 0.075
				northLat += 0.075
			else:
				southLat -= 0.075
				northLat -= 0.075
		elif pangaea_type == 2: # Pressed Polar
			global polarShiftRoll
			#print("Polar Shift Roll: ", polarShiftRoll)
			if polarShiftRoll == 1:
				southLat += 0.175
				northLat += 0.175
			else:
				southLat -= 0.175
				northLat -= 0.175
		else: # Pressed Equatorial
			pass
		iSouthY = int(southLat * iH)
		northY = int(northLat * iH)
		iRegionWidth = eastX - iWestX + 1
		iRegionHeight = northY - iSouthY + 1

		# Init the plot types array and the regional fractals
		plotTypes = [] # reinit the array for each pass
		plotTypes = [PlotTypes.PLOT_OCEAN] * (iRegionWidth*iRegionHeight)
		regionContinentsFrac = CyFractal()
		regionHillsFrac = CyFractal()
		regionPeaksFrac = CyFractal()
		regionContinentsFrac.fracInit(iRegionWidth, iRegionHeight, 1, dice, iHorzFlags, 7, 5)
		regionHillsFrac.fracInit(iRegionWidth, iRegionHeight, 3, dice, iHorzFlags, 7, 5)
		regionPeaksFrac.fracInit(iRegionWidth, iRegionHeight, 4, dice, iHorzFlags, 7, 5)

		iWaterThreshold = regionContinentsFrac.getHeightFromPercent(40)
		iHillsBottom1 = regionHillsFrac.getHeightFromPercent(20)
		iHillsTop1 = regionHillsFrac.getHeightFromPercent(30)
		iHillsBottom2 = regionHillsFrac.getHeightFromPercent(70)
		iHillsTop2 = regionHillsFrac.getHeightFromPercent(80)
		iPeakThreshold = regionPeaksFrac.getHeightFromPercent(25)

		# Loop through the region's plots
		for x in range(iRegionWidth):
			for y in range(iRegionHeight):
				i = y*iRegionWidth + x
				val = regionContinentsFrac.getHeight(x,y)
				if val <= iWaterThreshold: pass
				else:
					hillVal = regionHillsFrac.getHeight(x,y)
					if ((hillVal >= iHillsBottom1 and hillVal <= iHillsTop1) or (hillVal >= iHillsBottom2 and hillVal <= iHillsTop2)):
						peakVal = regionPeaksFrac.getHeight(x,y)
						if (peakVal <= iPeakThreshold):
							plotTypes[i] = PlotTypes.PLOT_PEAK
						else:
							plotTypes[i] = PlotTypes.PLOT_HILLS
					else:
						plotTypes[i] = PlotTypes.PLOT_LAND

		for x in range(iRegionWidth):
			wholeworldX = x + iWestX
			for y in range(iRegionHeight):
				i = y*iRegionWidth + x
				if plotTypes[i] == PlotTypes.PLOT_OCEAN: continue # Not merging water!
				wholeworldY = y + iSouthY
				# print("Changing water plot at ", wholeworldX, wholeworldY, " to ", plotTypes[i])
				iWorld = wholeworldY*iW + wholeworldX
				pPlot = map.plotByIndex(iWorld)
				if pPlot.isWater():	# Only merging new land plots over old water plots.
					pPlot.setPlotType(plotTypes[i], true, true)

		# Smooth any graphical glitches these changes may have produced.
		map.recalculateAreas()

	# Now generate Terrain.
	NiTextOut("Generating Terrain (Python Pangaea) ...")
	terraingen = TerrainGenerator()
	terrainTypes = terraingen.generateTerrain()
	return terrainTypes
コード例 #10
0
def generateTerrainTypes():
    NiTextOut("Generating Terrain (Python Global Highlands) ...")
    terraingen = TerrainGenerator()
    terrainTypes = terraingen.generateTerrain()
    return terrainTypes
コード例 #11
0
def generateTerrainTypes():
  terrainTypes = TerrainGenerator().generateTerrain()
  return terrainTypes
コード例 #12
0
def generateTerrainTypes():
	# Run a check for cohesion failure.
	# If the largest land area contains less than 80% of the land (Natural/Pressed),
	# or less than 90% of the land (Solid), add a third layer of fractal terrain 
	# to try to link the main landmasses in to a true Pangaea.
	gc = CyGlobalContext()
	map = CyMap()
	dice = gc.getGame().getMapRand()
	iHorzFlags = CyFractal.FracVals.FRAC_WRAP_X + CyFractal.FracVals.FRAC_POLAR
	biggest_area = map.findBiggestArea(false)
	global terrainRoll
	userInputShoreline = map.getCustomMapOption(0)
	iTotalLandPlots = map.getLandPlots()
	iBiggestAreaPlots = biggest_area.getNumTiles()
	#print("Total Land: ", iTotalLandPlots, " Main Landmass Plots: ", iBiggestAreaPlots)
	if (userInputShoreline == 1 or userInputShoreline == 2 or (userInputShoreline == 0 and terrainRoll < 7)) and iBiggestAreaPlots < 0.8 * iTotalLandPlots:
		global pangaea_type
		print("Total Land: ", iTotalLandPlots, " Main Landmass Plots: ", iBiggestAreaPlots)
		print "Cohesion failure! Attempting to remedy..."
		#print("Pangaea Type: ", pangaea_type)
		iW = map.getGridWidth()
		iH = map.getGridHeight()
		iWestX = int(0.3 * iW)
		eastX = int(0.7 * iW)
		southLat = 0.4
		northLat = 0.6
		if pangaea_type == 0: # Natural
			global shiftRoll
			#print("Shift Roll: ", shiftRoll)
			if shiftRoll == 1:
				southLat += 0.075
				northLat += 0.075
			else:
				southLat -= 0.075
				northLat -= 0.075
		elif pangaea_type == 2: # Pressed Polar
			global polarShiftRoll
			#print("Polar Shift Roll: ", polarShiftRoll)
			if polarShiftRoll == 1:
				southLat += 0.175
				northLat += 0.175
			else:
				southLat -= 0.175
				northLat -= 0.175
		else: # Pressed Equatorial
			pass
		iSouthY = int(southLat * iH)
		northY = int(northLat * iH)
		iRegionWidth = eastX - iWestX + 1
		iRegionHeight = northY - iSouthY + 1
		
		# Init the plot types array and the regional fractals
		plotTypes = [] # reinit the array for each pass
		plotTypes = [PlotTypes.PLOT_OCEAN] * (iRegionWidth*iRegionHeight)
		regionContinentsFrac = CyFractal()
		regionHillsFrac = CyFractal()
		regionPeaksFrac = CyFractal()
		regionContinentsFrac.fracInit(iRegionWidth, iRegionHeight, 1, dice, iHorzFlags, 7, 5)
		regionHillsFrac.fracInit(iRegionWidth, iRegionHeight, 3, dice, iHorzFlags, 7, 5)
		regionPeaksFrac.fracInit(iRegionWidth, iRegionHeight, 4, dice, iHorzFlags, 7, 5)

		iWaterThreshold = regionContinentsFrac.getHeightFromPercent(40)
		iHillsBottom1 = regionHillsFrac.getHeightFromPercent(20)
		iHillsTop1 = regionHillsFrac.getHeightFromPercent(30)
		iHillsBottom2 = regionHillsFrac.getHeightFromPercent(70)
		iHillsTop2 = regionHillsFrac.getHeightFromPercent(80)
		iPeakThreshold = regionPeaksFrac.getHeightFromPercent(25)

		# Loop through the region's plots
		for x in range(iRegionWidth):
			for y in range(iRegionHeight):
				i = y*iRegionWidth + x
				val = regionContinentsFrac.getHeight(x,y)
				if val <= iWaterThreshold: pass
				else:
					hillVal = regionHillsFrac.getHeight(x,y)
					if ((hillVal >= iHillsBottom1 and hillVal <= iHillsTop1) or (hillVal >= iHillsBottom2 and hillVal <= iHillsTop2)):
						peakVal = regionPeaksFrac.getHeight(x,y)
						if (peakVal <= iPeakThreshold):
							plotTypes[i] = PlotTypes.PLOT_PEAK
						else:
							plotTypes[i] = PlotTypes.PLOT_HILLS
					else:
						plotTypes[i] = PlotTypes.PLOT_LAND

		for x in range(iRegionWidth):
			wholeworldX = x + iWestX
			for y in range(iRegionHeight):
				i = y*iRegionWidth + x
				if plotTypes[i] == PlotTypes.PLOT_OCEAN: continue # Not merging water!
				wholeworldY = y + iSouthY
				# print("Changing water plot at ", wholeworldX, wholeworldY, " to ", plotTypes[i])
				iWorld = wholeworldY*iW + wholeworldX
				pPlot = map.plotByIndex(iWorld)
				if pPlot.isWater():	# Only merging new land plots over old water plots.
					pPlot.setPlotType(plotTypes[i], true, true)

		# Smooth any graphical glitches these changes may have produced.
		map.recalculateAreas()

	# Now generate Terrain.
	NiTextOut("Generating Terrain (Python Pangaea) ...")
	terraingen = TerrainGenerator()
	terrainTypes = terraingen.generateTerrain()
	return terrainTypes
コード例 #13
0
def generateTerrainTypes():
	NiTextOut("Generating Terrain (Python Fractal) ...")
	terraingen = TerrainGenerator(grain_amount=6)
	terrainTypes = terraingen.generateTerrain()
	return terrainTypes
コード例 #14
0
ファイル: PAE_Life.py プロジェクト: dead-flunky/PAE
def generateTerrainTypes():
    terraingen = TerrainGenerator()
    terrainTypes = terraingen.generateTerrain()
    return terrainTypes
コード例 #15
0
def generateTerrainTypes():
    print "terrain"
    NiTextOut("Generating Terrain (Python Islands) ...")
    terraingen = TerrainGenerator()
    terrainTypes = terraingen.generateTerrain()
    return terrainTypes
コード例 #16
0
def generateTerrainTypes():
    NiTextOut("Generating Terrain (Python Terra) ...")
    terraingen = TerrainGenerator()
    terrainTypes = terraingen.generateTerrain()
    return terrainTypes
コード例 #17
0
def generateTerrainTypes():
	print "terrain"
	NiTextOut("Generating Terrain (Python Islands) ...")
	terraingen = TerrainGenerator()
	terrainTypes = terraingen.generateTerrain()
	return terrainTypes