def generatePlotTypes(): NiTextOut("Setting Plot Types (Python Mirror) ...") gc = CyGlobalContext() map = CyMap() userInputLandmass = map.getCustomMapOption(2) dice = gc.getGame().getMapRand() global terrainRoll terrainRoll = dice.get(8, "PlotGen Chooser - Mirror PYTHON") # 0-3 = LvR # 4 = Wide Conts # 5 = Snaky Conts # 6 = 'Pelago # 7 = Tiny Islands # Teams together on an all land map. if userInputLandmass == 0 or (userInputLandmass == 5 and terrainRoll < 4): # LvR land_world = FractalWorld() land_world.initFractal(continent_grain=4, rift_grain=-1, has_center_rift=False, invert_heights=True) return land_world.generatePlotTypes(water_percent=8) # Teams separated by water, use MultilayeredFractal. water_world = MirrorMultilayeredFractal() if userInputLandmass == 5: # Varied setting gives 50% land maps (LvR) and 50% water maps (random type). terrain_type = terrainRoll - 3 else: terrain_type = userInputLandmass return water_world.generatePlotsByRegion(terrain_type)
def generatePlotTypes(): NiTextOut("Setting Plot Types (Python Mirror) ...") gc = CyGlobalContext() map = CyMap() userInputLandmass = map.getCustomMapOption(2) dice = gc.getGame().getMapRand() global terrainRoll terrainRoll = dice.get(8, "PlotGen Chooser - Mirror PYTHON") # 0-3 = LvR # 4 = Wide Conts # 5 = Snaky Conts # 6 = 'Pelago # 7 = Tiny Islands # Teams together on an all land map. if userInputLandmass == 0 or (userInputLandmass == 5 and terrainRoll < 4): # LvR land_world = FractalWorld() land_world.initFractal(continent_grain = 4, rift_grain = -1, has_center_rift = False, invert_heights = True) return land_world.generatePlotTypes(water_percent = 8) # Teams separated by water, use MultilayeredFractal. water_world = MirrorMultilayeredFractal() if userInputLandmass == 5: # Varied setting gives 50% land maps (LvR) and 50% water maps (random type). terrain_type = terrainRoll - 3 else: terrain_type = userInputLandmass return water_world.generatePlotsByRegion(terrain_type)
def generatePlotTypes(): NiTextOut("Setting Plot Types (Python Fractal) ...") fractal_world = FractalWorld( 4, 4 ) fractal_world.initFractal(continent_grain = 3, rift_grain = 4, has_center_rift = False, polar = False) retVal = fractal_world.generatePlotTypes(70) sinkEasternShore(fractal_world, 5) return retVal
def generatePlotTypes(): NiTextOut("Setting Plot Types (Python Shuffle) ...") gc = CyGlobalContext() dice = gc.getGame().getMapRand() fractal_world = FractalWorld() grainRoll = 1 + dice.get(8, "Fractal Grain - Shuffle PYTHON") if grainRoll > 5: grainRoll -= 5 if grainRoll == 2: fractal_world.initFractal(polar = True) return fractal_world.generatePlotTypes(water_percent=75) else: if grainRoll == 5: grainRoll -= 3 fractal_world.initFractal(continent_grain = grainRoll, rift_grain = -1, has_center_rift = False, polar = True) return fractal_world.generatePlotTypes()
def generatePlotTypes(): NiTextOut("Setting Plot Types (Python Islands) ...") iPlayers = CyGlobalContext().getGame().countCivPlayersEverAlive() # Check for valid number of players. if iPlayers > 0 and iPlayers < 19: pass else: # Error catching. fractal_world = FractalWorld() fractal_world.initFractal(polar=True) plotTypes = fractal_world.generatePlotTypes() return plotTypes fractal_world = IslandsMultilayeredFractal() plotTypes = fractal_world.generatePlotsByRegion() return plotTypes
def generatePlotTypes(): NiTextOut("Setting Plot Types (Python Islands) ...") iPlayers = CyGlobalContext().getGame().countCivPlayersEverAlive() # Check for valid number of players. if iPlayers > 0 and iPlayers < 19: pass else: # Error catching. fractal_world = FractalWorld() fractal_world.initFractal(polar = True) plotTypes = fractal_world.generatePlotTypes() return plotTypes fractal_world = IslandsMultilayeredFractal() plotTypes = fractal_world.generatePlotsByRegion() return plotTypes
def generatePlotTypes(): NiTextOut("Setting Plot Types (Python Shuffle) ...") gc = CyGlobalContext() dice = gc.getGame().getMapRand() fractal_world = FractalWorld() grainRoll = 1 + dice.get(8, "Fractal Grain - Shuffle PYTHON") if grainRoll > 5: grainRoll -= 5 if grainRoll == 2: fractal_world.initFractal(polar=True) return fractal_world.generatePlotTypes(water_percent=75) else: if grainRoll == 5: grainRoll -= 3 fractal_world.initFractal(continent_grain=grainRoll, rift_grain=-1, has_center_rift=False, polar=True) return fractal_world.generatePlotTypes()
def generatePlotTypes(): gc = CyGlobalContext() map = CyMap() dice = gc.getGame().getMapRand() fractal_world = FractalWorld() userInputLandmass = map.getCustomMapOption(0) if userInputLandmass == 0: random = True terrainRoll = dice.get(12, "") if terrainRoll < 3: land_type = 0 elif terrainRoll < 6: land_type = 1 elif terrainRoll < 9: land_type = 2 else: land_type = 3 else: if userInputLandmass > 1: land_type = userInputLandmass else: continentRoll = dice.get(4, "") if continentRoll > 1: land_type = 1 else: land_type = 0 if land_type == 2: ### small continents fractal_world.initFractal(continent_grain=3, rift_grain=2, has_center_rift=True, polar=True) return fractal_world.generatePlotTypes(grain_amount=4) elif land_type == 3: ### archipelago fractal_world.initFractal(continent_grain=4, rift_grain=-1, has_center_rift=False, polar=True) return fractal_world.generatePlotTypes(grain_amount=4) elif land_type == 0: ### pangaea fractal_world.initFractal(continent_grain=1, rift_grain=-1, has_center_rift=False, polar=True) return fractal_world.generatePlotTypes(grain_amount=4) else: ### large continents fractal_world.initFractal(rift_grain=2, has_center_rift=True, polar=True) return fractal_world.generatePlotTypes(grain_amount=4)
def generatePlotTypes(): NiTextOut("Setting Plot Types (Python Islands) ...") iPlayers = CyGlobalContext().getGame().countCivPlayersEverAlive() # Check for valid number of players. if iPlayers > 0 and iPlayers < 10: pass else: # Error catching. fractal_world = FractalWorld() fractal_world.initFractal(polar = True) plotTypes = fractal_world.generatePlotTypes() return plotTypes fractal_world = IslandsMultilayeredFractal() plotTypes = fractal_world.generatePlotsByRegion() qPlotTypes = [] for square in plotTypes: if square==PlotTypes.PLOT_OCEAN: square = PlotTypes.PLOT_LAND heightMap.append(0) else: heightMap.append(1) qPlotTypes.append(square) return qPlotTypes
def generatePlotTypes(): gc = CyGlobalContext() map = CyMap() dice = gc.getGame().getMapRand() fractal_world = FractalWorld() userInputLandmass = map.getCustomMapOption(0) if userInputLandmass == 0: random = True terrainRoll = dice.get(12, "") if terrainRoll < 3: land_type = 0 elif terrainRoll < 6: land_type = 1 elif terrainRoll < 9: land_type = 2 else: land_type = 3 else: if userInputLandmass > 1: land_type = userInputLandmass else: continentRoll = dice.get(4, "") if continentRoll > 1: land_type = 1 else: land_type = 0 if land_type == 2: ### small continents fractal_world.initFractal(continent_grain = 3, rift_grain = 2, has_center_rift = True, polar = True) return fractal_world.generatePlotTypes(grain_amount = 4) elif land_type == 3: ### archipelago fractal_world.initFractal(continent_grain = 4, rift_grain = -1, has_center_rift = False, polar = True) return fractal_world.generatePlotTypes(grain_amount = 4) elif land_type == 0: ### pangaea fractal_world.initFractal(continent_grain = 1, rift_grain = -1, has_center_rift = False, polar = True) return fractal_world.generatePlotTypes(grain_amount = 4) else: ### large continents fractal_world.initFractal(rift_grain = 2, has_center_rift = True, polar = True) return fractal_world.generatePlotTypes(grain_amount = 4)
def generatePlotTypes(): NiTextOut("Setting Plot Types (Python Fractal) ...") fractal_world = FractalWorld() fractal_world.initFractal(rift_grain = -1, has_center_rift = False, polar = True) return fractal_world.generatePlotTypes()
def generatePlotTypes(): NiTextOut("Setting Plot Types (Python Continents) ...") fractal_world = FractalWorld() fractal_world.initFractal(polar = True) return fractal_world.generatePlotTypes(water_percent=75)
def generatePlotTypes(): NiTextOut("Setting Plot Types (Python Continents) ...") fractal_world = FractalWorld() fractal_world.initFractal(polar=True) return fractal_world.generatePlotTypes(water_percent=75)
def generatePlotTypes(): NiTextOut("Setting Plot Types (Python Team Battleground) ...") global hinted_world, mapRand global fractal_world gc = CyGlobalContext() map = CyMap() mapRand = gc.getGame().getMapRand() userInputPlots = map.getCustomMapOption(0) if userInputPlots == 2: # Four Corners hinted_world = HintedWorld() iNumPlotsX = map.getGridWidth() iNumPlotsY = map.getGridHeight() centery = (hinted_world.h - 1)//2 centerx = (hinted_world.w - 1)//2 iCenterXList = [] iCenterXList.append(centerx-1) iCenterXList.append(centerx) iCenterXList.append(centerx+1) iCenterYList = [] iCenterYList.append(centery-1) iCenterYList.append(centery) iCenterYList.append(centery+1) bridgey = centery # Set all blocks to land except a strip in the center for x in range(hinted_world.w): for y in range(hinted_world.h): if x == centerx: if y == bridgey: hinted_world.setValue(x,y,128) # coast else: hinted_world.setValue(x,y,0) else: hinted_world.setValue(x,y,255) if y in iCenterYList: hinted_world.setValue(x,y,128) # coast if y == centery: hinted_world.setValue(x,y,0) # ocean hinted_world.buildAllContinents() plotTypes = hinted_world.generatePlotTypes(20) # Remove any land bridge that exists centerplotx = (iNumPlotsX - 1)//2 dx = 1 for x in range(centerplotx-dx, centerplotx+dx+1): for y in range(iNumPlotsY): i = map.plotNum(x, y) if plotTypes[i] != PlotTypes.PLOT_OCEAN: plotTypes[i] = PlotTypes.PLOT_OCEAN centerploty = (iNumPlotsY - 1)//2 dy = 1 for y in range(centerploty-dy, centerploty+dy+1): for x in range(iNumPlotsX): i = map.plotNum(x, y) if plotTypes[i] != PlotTypes.PLOT_OCEAN: plotTypes[i] = PlotTypes.PLOT_OCEAN # Now add the bridge across the center! sizekey = map.getWorldSize() sizevalues = { WorldSizeTypes.WORLDSIZE_DUEL: 3, WorldSizeTypes.WORLDSIZE_TINY: 4, WorldSizeTypes.WORLDSIZE_SMALL: 5, WorldSizeTypes.WORLDSIZE_STANDARD: 6, WorldSizeTypes.WORLDSIZE_LARGE: 8, WorldSizeTypes.WORLDSIZE_HUGE: 10 } # Rise of Mankind 2.53 if ( not sizekey in sizevalues ): shift = 12 else: shift = sizevalues[sizekey] # Rise of Mankind 2.53 linewidth = 3 offsetstart = 0 - int(linewidth/2) offsetrange = range(offsetstart, offsetstart + linewidth) westX1, southY1, eastX1, northY1 = centerplotx - shift, centerploty - shift, centerplotx + shift, centerploty + shift westX2, southY2, eastX2, northY2 = centerplotx - shift, centerploty - shift, centerplotx + shift, centerploty + shift bridge_data = [[westX1, southY1, eastX1, northY1], [westX2, northY2, eastX2, southY2]] for bridge_loop in range(2): [startx, starty, endx, endy] = bridge_data[bridge_loop] if abs(endy-starty) < abs(endx-startx): # line is closer to horizontal if startx > endx: startx, starty, endx, endy = endx, endy, startx, starty # swap start and end dx = endx-startx dy = endy-starty if dx == 0 or dy == 0: slope = 0 else: slope = float(dy)/float(dx) y = starty for x in range(startx, endx+1): for offset in offsetrange: if map.isPlot(x, int(round(y+offset))): i = map.plotNum(x, int(round(y+offset))) plotTypes[i] = PlotTypes.PLOT_LAND y += slope else: # line is closer to vertical if starty > endy: startx, starty, endx, endy = endx, endy, startx, starty # swap start and end dx, dy = endx-startx, endy-starty if dx == 0 or dy == 0: slope = 0 else: slope = float(dx)/float(dy) x = startx for y in range(starty, endy+1): for offset in offsetrange: if map.isPlot(int(round(x+offset)), y): i = map.plotNum(int(round(x+offset)), y) plotTypes[i] = PlotTypes.PLOT_LAND x += slope return plotTypes if (userInputPlots == 4 # round or userInputPlots == 5): # donut hinted_world = HintedWorld() iNumPlotsX = map.getGridWidth() iNumPlotsY = map.getGridHeight() centery = (iNumPlotsY - 1)//2 centerx = (iNumPlotsX - 1)//2 radii = centery - 1 # Set all blocks to ocean except the inner circle for x in range(iNumPlotsX): for y in range(iNumPlotsY): dist_xy_c = sqrt( (x - centerx) ** 2 + (y - centery) ** 2) if dist_xy_c < radii: hinted_world.setValue(x,y,255) else: hinted_world.setValue(x,y,0) # ocean hinted_world.buildAllContinents() plotTypes = hinted_world.generatePlotTypes(water_percent = 0) if userInputPlots == 5: # donut # get the size of the hole map_size = map.getWorldSize() sizevalues = { WorldSizeTypes.WORLDSIZE_DUEL: 2, WorldSizeTypes.WORLDSIZE_TINY: 3, WorldSizeTypes.WORLDSIZE_SMALL: 4, WorldSizeTypes.WORLDSIZE_STANDARD: 5, WorldSizeTypes.WORLDSIZE_LARGE: 7, WorldSizeTypes.WORLDSIZE_HUGE: 8 } # Rise of Mankind 2.53 if ( not map_size in sizevalues ): hole_radii = 9 else: hole_radii = sizevalues[map_size] # Rise of Mankind 2.53 # Set all blocks to ocean except the inner circle for x in range(iNumPlotsX): for y in range(iNumPlotsY): i = map.plotNum(x, y) dist_xy_c = sqrt( (x - centerx) ** 2 + (y - centery) ** 2) if (dist_xy_c < radii): plotTypes[i] = PlotTypes.PLOT_LAND else: plotTypes[i] = PlotTypes.PLOT_OCEAN if (userInputPlots == 5 # donut and dist_xy_c < hole_radii): plotTypes[i] = PlotTypes.PLOT_OCEAN return plotTypes elif userInputPlots == 1: # Top vs Bottom fractal_world = FractalWorld(fracXExp=6, fracYExp=6) fractal_world.initFractal(continent_grain = 4, rift_grain = -1, has_center_rift = False, invert_heights = True) plot_types = fractal_world.generatePlotTypes(water_percent = 8) return plot_types else: # Left vs Right iNumPlotsX = map.getGridWidth() iNumPlotsY = map.getGridHeight() hinted_world = HintedWorld(4,2) centerx = (hinted_world.w - 1)//2 centery = (hinted_world.h - 1)//2 bridgey = centery # set all blocks to land except a strip in the center for x in range(hinted_world.w): for y in range(hinted_world.h): if x == centerx: if y == bridgey: hinted_world.setValue(x,y,128) # coast else: hinted_world.setValue(x,y,0) else: hinted_world.setValue(x,y,255) hinted_world.buildAllContinents() plotTypes = hinted_world.generatePlotTypes(20) #fix any land bridge that exists centerplotx = (iNumPlotsX - 1)//2 dx = 1 for x in range(centerplotx-dx, centerplotx+dx+1): for y in range(iNumPlotsY): i = map.plotNum(x, y) if plotTypes[i] != PlotTypes.PLOT_OCEAN: plotTypes[i] = PlotTypes.PLOT_OCEAN if userInputPlots == 3: # Left v Right with bridge centerplotx = (iNumPlotsX)//2 centerploty = (iNumPlotsY)//2 dy = 1 for x in range(iNumPlotsX): for y in range(centerploty-dy, centerploty+dy+1): i = map.plotNum(x, y) if plotTypes[i] == PlotTypes.PLOT_OCEAN: plotTypes[i] = PlotTypes.PLOT_LAND return plotTypes
def generatePlotTypes(): # BugUtil.debug("Team_Battleground: generatePlotTypes") NiTextOut("Setting Plot Types (Python Team Battleground) ...") global hinted_world, mapRand global fractal_world gc = CyGlobalContext() map = CyMap() mapRand = gc.getGame().getMapRand() userInputPlots = map.getCustomMapOption(0) if userInputPlots == 2: # Four Corners hinted_world = HintedWorld() iNumPlotsX = map.getGridWidth() iNumPlotsY = map.getGridHeight() centery = (hinted_world.h - 1)//2 centerx = (hinted_world.w - 1)//2 iCenterXList = [] iCenterXList.append(centerx-1) iCenterXList.append(centerx) iCenterXList.append(centerx+1) iCenterYList = [] iCenterYList.append(centery-1) iCenterYList.append(centery) iCenterYList.append(centery+1) bridgey = centery # Set all blocks to land except a strip in the center for x in range(hinted_world.w): for y in range(hinted_world.h): if x == centerx: if y == bridgey: hinted_world.setValue(x,y,128) # coast else: hinted_world.setValue(x,y,0) else: hinted_world.setValue(x,y,255) if y in iCenterYList: hinted_world.setValue(x,y,128) # coast if y == centery: hinted_world.setValue(x,y,0) # ocean hinted_world.buildAllContinents() plotTypes = hinted_world.generatePlotTypes(20) # Remove any land bridge that exists centerplotx = (iNumPlotsX - 1)//2 dx = 1 for x in range(centerplotx-dx, centerplotx+dx+1): for y in range(iNumPlotsY): i = map.plotNum(x, y) if plotTypes[i] != PlotTypes.PLOT_OCEAN: plotTypes[i] = PlotTypes.PLOT_OCEAN centerploty = (iNumPlotsY - 1)//2 dy = 1 for y in range(centerploty-dy, centerploty+dy+1): for x in range(iNumPlotsX): i = map.plotNum(x, y) if plotTypes[i] != PlotTypes.PLOT_OCEAN: plotTypes[i] = PlotTypes.PLOT_OCEAN # Now add the bridge across the center! sizekey = map.getWorldSize() sizevalues = { WorldSizeTypes.WORLDSIZE_DUEL: 3, WorldSizeTypes.WORLDSIZE_TINY: 4, WorldSizeTypes.WORLDSIZE_SMALL: 5, WorldSizeTypes.WORLDSIZE_STANDARD: 6, WorldSizeTypes.WORLDSIZE_LARGE: 8, WorldSizeTypes.WORLDSIZE_HUGE: 10 } shift = sizevalues[sizekey] linewidth = 3 offsetstart = 0 - int(linewidth/2) offsetrange = range(offsetstart, offsetstart + linewidth) westX1, southY1, eastX1, northY1 = centerplotx - shift, centerploty - shift, centerplotx + shift, centerploty + shift westX2, southY2, eastX2, northY2 = centerplotx - shift, centerploty - shift, centerplotx + shift, centerploty + shift bridge_data = [[westX1, southY1, eastX1, northY1], [westX2, northY2, eastX2, southY2]] for bridge_loop in range(2): [startx, starty, endx, endy] = bridge_data[bridge_loop] if abs(endy-starty) < abs(endx-startx): # line is closer to horizontal if startx > endx: startx, starty, endx, endy = endx, endy, startx, starty # swap start and end dx = endx-startx dy = endy-starty if dx == 0 or dy == 0: slope = 0 else: slope = float(dy)/float(dx) y = starty for x in range(startx, endx+1): for offset in offsetrange: if map.isPlot(x, int(round(y+offset))): i = map.plotNum(x, int(round(y+offset))) plotTypes[i] = PlotTypes.PLOT_LAND y += slope else: # line is closer to vertical if starty > endy: startx, starty, endx, endy = endx, endy, startx, starty # swap start and end dx, dy = endx-startx, endy-starty if dx == 0 or dy == 0: slope = 0 else: slope = float(dx)/float(dy) x = startx for y in range(starty, endy+1): for offset in offsetrange: if map.isPlot(int(round(x+offset)), y): i = map.plotNum(int(round(x+offset)), y) plotTypes[i] = PlotTypes.PLOT_LAND x += slope return plotTypes if (userInputPlots == 4 # round or userInputPlots == 5): # donut hinted_world = HintedWorld() iNumPlotsX = map.getGridWidth() iNumPlotsY = map.getGridHeight() centery = (iNumPlotsY - 1)//2 centerx = (iNumPlotsX - 1)//2 radii = centery - 1 # Set all blocks to ocean except the inner circle for x in range(iNumPlotsX): for y in range(iNumPlotsY): dist_xy_c = sqrt( (x - centerx) ** 2 + (y - centery) ** 2) if dist_xy_c < radii: hinted_world.setValue(x,y,255) else: hinted_world.setValue(x,y,0) # ocean hinted_world.buildAllContinents() plotTypes = hinted_world.generatePlotTypes(water_percent = 0) if userInputPlots == 5: # donut # get the size of the hole map_size = map.getWorldSize() sizevalues = { WorldSizeTypes.WORLDSIZE_DUEL: 2, WorldSizeTypes.WORLDSIZE_TINY: 3, WorldSizeTypes.WORLDSIZE_SMALL: 4, WorldSizeTypes.WORLDSIZE_STANDARD: 5, WorldSizeTypes.WORLDSIZE_LARGE: 7, WorldSizeTypes.WORLDSIZE_HUGE: 8 } hole_radii = sizevalues[map_size] # Set all blocks to ocean except the inner circle for x in range(iNumPlotsX): for y in range(iNumPlotsY): i = map.plotNum(x, y) dist_xy_c = sqrt( (x - centerx) ** 2 + (y - centery) ** 2) # if (dist_xy_c < radii): # if not (plotTypes[i] == PlotTypes.PLOT_LAND # and plotTypes[i] == PlotTypes.PLOT_PEAK # and plotTypes[i] == PlotTypes.PLOT_HILLS): # plotTypes[i] = PlotTypes.PLOT_LAND # else: # plotTypes[i] = PlotTypes.PLOT_OCEAN if (dist_xy_c >= radii): plotTypes[i] = PlotTypes.PLOT_OCEAN if (userInputPlots == 5 # donut and dist_xy_c < hole_radii): plotTypes[i] = PlotTypes.PLOT_OCEAN return plotTypes elif userInputPlots == 1: # Top vs Bottom fractal_world = FractalWorld(fracXExp=6, fracYExp=6) fractal_world.initFractal(continent_grain = 4, rift_grain = -1, has_center_rift = False, invert_heights = True) plot_types = fractal_world.generatePlotTypes(water_percent = 8) return plot_types else: # Left vs Right iNumPlotsX = map.getGridWidth() iNumPlotsY = map.getGridHeight() hinted_world = HintedWorld(4,2) centerx = (hinted_world.w - 1)//2 centery = (hinted_world.h - 1)//2 bridgey = centery # set all blocks to land except a strip in the center for x in range(hinted_world.w): for y in range(hinted_world.h): if x == centerx: if y == bridgey: hinted_world.setValue(x,y,128) # coast else: hinted_world.setValue(x,y,0) else: hinted_world.setValue(x,y,255) hinted_world.buildAllContinents() plotTypes = hinted_world.generatePlotTypes(20) #fix any land bridge that exists centerplotx = (iNumPlotsX - 1)//2 dx = 1 for x in range(centerplotx-dx, centerplotx+dx+1): for y in range(iNumPlotsY): i = map.plotNum(x, y) if plotTypes[i] != PlotTypes.PLOT_OCEAN: plotTypes[i] = PlotTypes.PLOT_OCEAN if userInputPlots == 3: # Left v Right with bridge centerplotx = (iNumPlotsX)//2 centerploty = (iNumPlotsY)//2 dy = 1 for x in range(iNumPlotsX): for y in range(centerploty-dy, centerploty+dy+1): i = map.plotNum(x, y) if plotTypes[i] == PlotTypes.PLOT_OCEAN: plotTypes[i] = PlotTypes.PLOT_LAND return plotTypes