[Map Script] PerfectWorld.py

Seven05, do you have your civ set up to make a Python debug log? There are some print statements in the findStartingPlot function that might indicate whether it's being recalled after the initial placement. If it's re-calling the default procedure in the DLL though, nothing would show up.
I will enable the log and post some results for you next time we hook up for a game, probably Saturday.

As for the floodplains, I've had to modify it for myself (three types of desert in my mod). From a gameplay standpoint I think the only case outside of deserts that makes sense would be tundra since tundra is about as useless as desert unless you're lucky enough to have some trees. If you place them on plains/grassland they quickly overpower the normal food resources, or worse yet- they make cottage spam even more potent.

Anyway, I think as a 'pure' mapscript you should avoid any fundamental gameplay changes.
 
1.03 is now published. The visible changes are somewhat small, but I had found many, many bugs that needed to be dealt with.

Lakes are now generated proportional to the river lengths flowing into them, and that proportion is tunable. There is also a tunable evaporation penalty for lakes created in the desert. Lakes that are one square in size are now legal, but no lake may exist such that removing one land square will connect it to the ocean, because any such lake will already be thus connected to form a harbor. So if you see such a lake, know that this map is behaving illegally.

Also, if you happen to be a modder with some Python saavy, each map will report in the PythonDbg file a seed value that is used to start the random number generator. So if you happen to find a map breaking the law, you can report them with this ID number.

Enjoy!
 
Next up will definately be starting areas. One of the problems I see with having fair starting areas is, that I've noticed that in single player, AI civs are very good a getting into stone cold stalemates. Perhaps fair starting areas are really only desireable in multiplayer?

With the default implimentation, some civs get really, really bad starting areas that no amount of bonuses can fix. Also, sometimes people can start on their own fairly large continent and if it happens to be the player, then the game is way too easy. There's definately alot of room for improvement here.

seven05, how often have you seen that MP bug on my map? Do you think it could just be some one time glitch unrelated to the map? Before I work too hard, I had better get a handle on that.
 
Very good results so far with the 1.03 fixes :)

We experienced the mp bug every time we tried to start a game with this mapscript, using another mapscript works fine as does starting the game and generating the map before the other players join.
 
Very good results so far with the 1.03 fixes :)

We experienced the mp bug every time we tried to start a game with this mapscript, using another mapscript works fine as does starting the game and generating the map before the other players join.

First, I want to say thanks for all the helpful comments. I'm wondering if you have time on your next MP game, can you try to generate a map with the starting plot functions commented out? That will cause the default functions to be used and if it's stable then that tells me if I can concentrate wholly on my starting functions in finding the problem. assignStartingPlots and findStartingPlot are the only ones needing to be eliminated for this test.
 
I've noticed something that might cause the MP problem. There is a function called CvPlayer.setStartingPlot and also one called CvPlot.setStartingPlot. My script only uses the CvPlayer version, maybe I need both? I'll try both, and after testing it tonight to make sure it won't crash the map I'll publish it. SmartMap uses both.
 
First, I want to say thanks for all the helpful comments. I'm wondering if you have time on your next MP game, can you try to generate a map with the starting plot functions commented out? That will cause the default functions to be used and if it's stable then that tells me if I can concentrate wholly on my starting functions in finding the problem. assignStartingPlots and findStartingPlot are the only ones needing to be eliminated for this test.
No problem, thank you for the script! :)

I can do that quick check for you this weekend, if it does nothing I'll enable the log as well per your previous request.
 
Ok, I just published 1.03a. This change is mostly for seven05 in hopes of finding the MP bug.

I noticed that in the dll, CvPlayer.setStartingPlot does not update the m_bStartingPlot member in CvPlot, so here's to hoping that this is important and might fix the problem.
 
Here's a quick one for you, I've been running this for some time. I adjusted it to force all players to start on the coast, otherwise a non-coastal start would typically mean starting one or two plots in from the coast since the landmasses are generally too thin to really start you in the middle of all land. It applies to all players, human and AI alike and also help prevent somebody starting in the middle of a large desert (although they can still start surrounded by mostly desert).

Code:
def findStartingPlot(playerID,bestArea):
    gc = CyGlobalContext()
    gameMap = CyMap()
    player = gc.getPlayer(playerID)

    player.AI_updateFoundValues(True)

    iRange = player.startingPlotRange()
    iPass = 0

    while (true):
        iBestValue = 0
        pBestPlot = None
        
        for iX in range(gameMap.getGridWidth()):
            for iY in range(gameMap.getGridHeight()):
                pLoopPlot = gameMap.plot(iX, iY)
                if (pLoopPlot.getArea() != bestArea):
                    continue
                if (pLoopPlot.getLatitude() >= 75):
                    continue

                val = pLoopPlot.getFoundValue(playerID)

                if val > iBestValue:
                
                    valid = True
                    
                    for iI in range(gc.getMAX_CIV_PLAYERS()):
                        if (gc.getPlayer(iI).isAlive()):
                            if (iI != playerID):
                                if gc.getPlayer(iI).startingPlotWithinRange(pLoopPlot, playerID, iRange, iPass):
                                    valid = False
                                    break

                    #Only allow coastal starting plots
                    pWaterArea = pLoopPlot.waterArea()
                    if (pWaterArea.isNone()):
                        valid = false
                    valid = not pWaterArea.isLake()

                    if valid:
                        iBestValue = val
                        pBestPlot = pLoopPlot

        if pBestPlot != None:
            return gameMap.plotNum(pBestPlot.getX(), pBestPlot.getY())
                
        print "player", playerID, "pass", iPass, "failed"
        
        iPass += 1
        if iPass > 100:
            return -1

    return -1
 
Here's a quick one for you, I've been running this for some time. I adjusted it to force all players to start on the coast, otherwise a non-coastal start would typically mean starting one or two plots in from the coast since the landmasses are generally too thin to really start you in the middle of all land. It applies to all players, human and AI alike and also help prevent somebody starting in the middle of a large desert (although they can still start surrounded by mostly desert).

Once I lock down the MP bug I'm going to give starting plots a big overhaul with some tunable options. I want to find some way to give all players on a continent somewhat equal opportunity to all the good stuff it has. I suppose everyone likes to start on the coast, but I had a very fun game recently starting completely land locked on all sides in the middle of the desert. Luckily the starting plot normalizer gave me lots of marble so I could culture flip a coastal city with my wonders.

Coast only starts is a good option to provide though. I would also like to provide an option for different levels of fairness, including completely random and totally unfair. Also, maybe an option for different qualities of starting locations aside from fairness, like everyone with a bad, medium, or best starting location. It might be fun for players to have to look for the best areas instead of just owning them at the beginning.

I plan to go nuts with the starting location stuff.
 
I think this script is getting even better with each new release. Good job:)

However, there are two small glitches that bothered me right from the first version. One is the number of rivers and flood plains in the deserts. They make the poorest parts of map the best for settling. I don't usually get Sahara-like deserts with no cities around. I realize there are seasonal rivers on deserts but they shouldn't be treated as regular rivers.

The second glitch is in the screenshot. The rvier delta looks ugly and the x-marked tiles has no river on it (in regular map scripts it's always a river-tile). o-marked tile should also be flood plain.
Desert rivers without flood plains should also be generated just like in regular scripts. For example the upper parts of a desert river could have no flood plains.
 

Attachments

  • Civ4ScreenShot0000.JPG
    Civ4ScreenShot0000.JPG
    84.5 KB · Views: 342
I think this script is getting even better with each new release. Good job:)

However, there are two small glitches that bothered me right from the first version. One is the number of rivers and flood plains in the deserts. They make the poorest parts of map the best for settling. I don't usually get Sahara-like deserts with no cities around. I realize there are seasonal rivers on deserts but they shouldn't be treated as regular rivers.

The second glitch is in the screenshot. The rvier delta looks ugly and the x-marked tiles has no river on it (in regular map scripts it's always a river-tile). o-marked tile should also be flood plain.
Desert rivers without flood plains should also be generated just like in regular scripts. For example the upper parts of a desert river could have no flood plains.

I have noticed that the delta glitch only happens to me when I regenerate the map without starting a new game. Other weird stuff happens also like floating resources and goody huts. It never happens to me the first time I generate the map. I wonder if some map finalization function needs to be called that isn't in some cases. Are you regenerating the map at all? The fix that works for me is to save your game, exit to the main menu and reload.

Also, in making floodplains, there's a function called CvPlot.isRiverSide. Basically I just make every desert square that answers 'true' to that function a floodplain. So it's very simplistic. I was thinking maybe I should tone that down, but it won't be trivial.
 
That was a regenerated map, but I think that even though it's only a display bug it's caused by the fact that the x-marked tile is not counted as river tile while it should be. I noticed it because I wanted to build a levee in the city placed on such tile and I couldn't. It doesn't happen always but when a river flows into a lake it's pretty common
 
That was a regenerated map, but I think that even though it's only a display bug it's caused by the fact that the x-marked tile is not counted as river tile while it should be. I noticed it because I wanted to build a levee in the city placed on such tile and I couldn't. It doesn't happen always but when a river flows into a lake it's pretty common

You're right, that's definately a bug. I'll have to fix that. It must be that even though isNOfRiver and isWOfRiver are both false, the riverID still needs to be set to give the corners fresh water. Thanks for being persistant about insisting that it was a bug.
 
I come bearing sad news :(

The MP bug still exists. That is if I host a game and you join while I'm in the staging room when we create the map we will be OOS (out of sync) and when you re-connect you're starting city will be somewhere very different.

Worse yet, I neglected to enable logging while we were going through trying to resolve a few other mod issues.
 
I come bearing sad news :(

The MP bug still exists. That is if I host a game and you join while I'm in the staging room when we create the map we will be OOS (out of sync) and when you re-connect you're starting city will be somewhere very different.

Worse yet, I neglected to enable logging while we were going through trying to resolve a few other mod issues.

Did you have a chance to comment out the starting plot code? That's the thing that I needed most.
 
That was a regenerated map, but I think that even though it's only a display bug it's caused by the fact that the x-marked tile is not counted as river tile while it should be. I noticed it because I wanted to build a levee in the city placed on such tile and I couldn't. It doesn't happen always but when a river flows into a lake it's pretty common

Hey Rael, I have a question for you. What are the stated requirements for a levee? I only use vanilla at this time, so it's hard for me to test things properly. In vanilla, on other map scripts, there would be no fresh water on the x-marked tile if that lake there was ocean instead of a lake. Did they change the rules for Warlords etc?

I have no idea why that graphical glitch upon regenerating is there, other maps don't have that problem. Why it is fixed upon reload is also a mystery to me.
 
requirements for levee is next to a river. A fresh water lake won't do it for you. The dutch dike on the other hand I believe can be built either next to a river, or coastal (since it also adds +1 hammer to water tiles).


BTW I really love the map script!!
 
requirements for levee is next to a river. A fresh water lake won't do it for you. The dutch dike on the other hand I believe can be built either next to a river, or coastal (since it also adds +1 hammer to water tiles).


BTW I really love the map script!!

Thanks! One more quick question, when you use a different old map script with BtS, like Terra for example, will Raels x-marked square meet the requirement for a river? Or, does that only happen in the newer BtS map scripts?
 
Top Bottom