Selective Old World

lumpthing

generic lump
Joined
Sep 11, 2004
Messages
781
Location
Lumpinium, England
I know I can use the code below to force all civs to start on the biggest continent, but is there a way to make this rule apply to only certain civs. For example, to say that the English, Dutch and Spanish must start on the biggest continent, but all the other civs can start anywhere?

Code:
def isValidOldW(playerID, x, y):
	map = CyMap()
	if (map.plot(x, y).getArea() != map.findBiggestArea(False).getID()):
		return False
	return True

def findStartingPlot(argsList):
	[playerID] = argsList	
	return CvMapGeneratorUtil.findStartingPlot(playerID, isValidOldW)
 
make two different "isValid" methods (one of which might be just the default implementation for civs starting where-ever...), then choose which one to pass to CvMapGeneratorUtil.findStartingPlot(Player, isValid)...
 
Uh... Sorry...

Well... I dont know how to handle civ's names in map generation. I think:
Code:
 gc.getPlayer(playerID).getCivilizationType() == "CIVILIZATION_JAPAN"
is close, to waht it will look like

As you worked on that "Earth Flavour Script" i assume you do know how the condition has to look like... So the code below is to demonstrate how to bind the usage of multiple different isValid() methods to a condition, but you will need to provide the right conditions for the if's...

Code:
[COLOR="Red"]# Validity Function for Old World Civ[/COLOR]
def isValidOldW(playerID, x, y):
	map = CyMap()
	if (map.plot(x, y).getArea() != map.findBiggestArea(False).getID()):
		return False
	return True

[COLOR="Red"]#Validity funciton forciang a civ to start anywhere BUT old world[/COLOR]
def def isValid_NOT_OldW(playerID, x, y):
	map = CyMap()
	if (map.plot(x, y).getArea() == map.findBiggestArea(False).getID()):
		return False
	return True

def findStartingPlot(argsList):
	[playerID] = argsList
        
        [COLOR="Red"]#Old World Civs  [/COLOR]       
        if ( gc.getPlayer(playerID).getCivilizationType() == "CIVILIZATION_ENGLAND" ) :
		return CvMapGeneratorUtil.findStartingPlot(playerID, isValidOldW)
        [COLOR="Red"]#Not Old World Civs[/COLOR]
        elif ( gc.getPlayer(playerID).getCivilizationType() == "CIVILIZATION_JAPAN" ) :
		return CvMapGeneratorUtil.findStartingPlot(playerID, isValid_NOT_OldW)
        [COLOR="Red"]#Everyone not covered above. None passes no special isValid() method, so the default implementation will be used.[/COLOR]
        else :
                return CvMapGeneratorUtil.findStartingPlot(playerID, None)
 
Uh... Sorry...

Well... I dont know how to handle civ's names in map generation. I think:
Code:
 gc.getPlayer(playerID).getCivilizationType() == "CIVILIZATION_JAPAN"
is close, to waht it will look like

this is :
Code:
gc.getCivilizationInfo(gc.getPlayer(playerID).getCivilizationType()).getType() == "CIVILIZATION_JAPAN"

or
Code:
gc.getPlayer(playerID).getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_JAPAN")


Tcho !
 
Thanks very much for your help both of you

I slapped in the following code:

Code:
# Validity Function for Old World Civ
def isValidOldW(playerID, x, y):
	map = CyMap()
	if (map.plot(x, y).getArea() != map.findBiggestArea(False).getID()):
		return False
	return True

#Validity funciton forciang a civ to start anywhere BUT old world
def isValid_NOT_OldW(playerID, x, y):
	map = CyMap()
	if (map.plot(x, y).getArea() == map.findBiggestArea(False).getID()):
		return False
	return True

def findStartingPlot(argsList):
	[playerID] = argsList
        
    	#Old World Civs         
	if ( gc.getPlayer(playerID).getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_ENGLAND") ) or ( gc.getPlayer(playerID).getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_FRANCE") ) :
		return CvMapGeneratorUtil.findStartingPlot(playerID, isValidOldW)
	#Not Old World Civs
	elif ( gc.getPlayer(playerID).getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_JAPAN") ) :
		return CvMapGeneratorUtil.findStartingPlot(playerID, isValid_NOT_OldW)
	#Everyone not covered above. None passes no special isValid() method, so the default implementation will be used.
	else :
		return CvMapGeneratorUtil.findStartingPlot(playerID, None)

...and tested it on a duel-sized map with France, England and Japan. Unfortunately it does not seem to work. I only tested it three or four times but there was always one big continent with two civs and one little continent with one civ with Japan always on the biggest continent!
 
That's odd, as in theory it looks good... Tho i never tried exactly this code before, i had used similar snipplets to make different rules apply to AI and human civs...

Do you use it together with the "Earth Flavour" thingie of yours ? becausse i think the Flavour code reshuflles the starting plots in the end... (To match the flavour selections...)
 
yeah i used it with the earth flavour thing so i expect its that. I'll test it without earth flavour some time to make sure.

incidentally, all the proper code for earth flavour mod is taken from dreiche2's script for Fall From Heaven. I just changed the settings to work for standard Earth civs. So that's why I'm clueless about the code :)
 
I dont understand it completely either, so unfortunately i cant help you merge thise two... tho i think it should be possible somehow.
 
Hmmm :( I am a bit confused then... It must be something about the

gc.getPlayer(playerID).getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_JAPAN")

statement i think... Perhaps the civs are not yet determined at that point ?

Do you have logging enabled ? (can be anabled via the .ini, at the end of the file LoggingEnabled = 1) If so can you prehaps look if the PythonErr.log file has some error messages ?
 
Uh... my bad... I Copy-Pasted-Edited the code from another script where GC was defined globally... Sorry. :blush: You need to put this
Code:
gc = CyGlobalContext()

in the beginning of the findStartingPlot() method... Just below the [playerID] = argsList line
 
... Perhaps the civs are not yet determined at that point ?

All the game infos are enabled "onSetPlayerAlive" before "beforeInit" except the map scripts settings like grid size , wrap etc ...

Here the code rewritten to be easy to change :

Code:
def findStartingPlot(argsList):
	[playerID] = argsList
	gc = CyGlobalContext()

	oldCivList = ["CIVILIZATION_ENGLAND", "CIVILIZATION_FRANCE"]
	notOldCivList = ["CIVILIZATION_JAPAN"]

	oldCivList = [gc.getInfoTypeForString(item) for item in oldCivList]
	notOldCivList = [gc.getInfoTypeForString(item) for item in notOldCivList]
	iPlayerCiv = gc.getPlayer(playerID).getCivilizationType()
        
    	#Old World Civs      
	if iPlayerCiv in oldCivList :
		return CvMapGeneratorUtil.findStartingPlot(playerID, isValidOldW)
	#Not Old World Civs
	elif iPlayerCiv in notOldCivList :
		return CvMapGeneratorUtil.findStartingPlot(playerID, isValid_NOT_OldW)
	#Everyone not covered above. None passes no special isValid() method, so the default implementation will be used.
	else :
		return CvMapGeneratorUtil.findStartingPlot(playerID, None)


Tcho !
 
This looks good. I hope you don't mind me stealing this code to use in some of my own map scripts.

One question though -- one of the scripts I was planning to use it in was the Earth3/Terra2 maps, which are variations on the basic Terra script. Now, if I use this code, I might end up with a situation where every civ in a game is an "old world" team...or, worse, where every civ but one is an old world team, and as a result, one civ has free run of the new world for most of the game.

Is there an easy way to set up the script such that unless there are specific civs forced via the interface, that the game will always have a minimum of two new world civs? Or are the civs included in the game randomly determined PRIOR to map generation?

Thanks.
 
Is there an easy way to set up the script such that unless there are specific civs forced via the interface, that the game will always have a minimum of two new world civs? Or are the civs included in the game randomly determined PRIOR to map generation?

I think there is no way to know if a civ was forced or choosen at random from within the map script...

You could however just count old/new world teams, and - if the distribution is to unbalanced, relocate some... Perhaps relocating the last civs in the list - as those are unlikely to be human...
 
Yes, i had expected something like that...

What you would need to do, is somehow merging those conditions from the diffrent "isValid" methods into the process used by the flavour mod.

I do not understand the code of the flavour mod, so i cant help you merge.

Perhaps the author of the original flavour location code can give some hints, on how to merge additional conditions in.
 
Back
Top Bottom