[Map Script] PerfectWorld2.py

Any chance of getting a Perfect World script for Civ5? I really miss it. :)

I am definately working on it, but it will take some time. I've never used the Lua language and also I've developed alot of new techniques that I have yet to use on a Civ map. Hopefully it won't be more than a month or so.
 
Actually, I've noticed that Civ5's Terra seems to incorporate ideas from PerfectWorld. So the first question to ask before "When will there be PerfectWorld for Civ5?" is "What should PerfectWorld for Civ5 do differently from Terra for Civ5?"

EDIT: Might as well give the first answer. Terra doesn't simulate tectonics, so while it has mountain ranges, it doesn't tend to create large landmasses that are separated by a mountain range (like Europe and Asia), which PerfectWorld of course does.
 
I am definately working on it, but it will take some time. I've never used the Lua language and also I've developed alot of new techniques that I have yet to use on a Civ map. Hopefully it won't be more than a month or so.

That's good to know. Anything this year would make me happy. :)
 
Actually, I've noticed that Civ5's Terra seems to incorporate ideas from PerfectWorld. So the first question to ask before "When will there be PerfectWorld for Civ5?" is "What should PerfectWorld for Civ5 do differently from Terra for Civ5?"

EDIT: Might as well give the first answer. Terra doesn't simulate tectonics, so while it has mountain ranges, it doesn't tend to create large landmasses that are separated by a mountain range (like Europe and Asia), which PerfectWorld of course does.

Civ5 Terra looks to me alot like Civ4 Terra. The climate seems somewhat scattered about in a fairly even distribution. Notice how the trees pepper the map without much change in density. Also the rivers don't seem to flow in a natural way. They usually start in the middle and radiate outward to the sea, or sometimes they start near the sea and cross the whole continent. It looks better when you use actual drainage paths on a heightmap.

My next map is going to be quite different than both Terra and PW2. Internally it will be completely different. I've learned a few tricks, although much of it is still experimental.

I've been reading the start placement code for Civ5, and Sirian did an excellent job with it. I'm thinking that I might not have to mess with the starting code at all at least initially. That will save some time.
 
Yeah, I got a little overexcited about Terra. It's not Civ4's Terra, but it's not PerfectWorld either.

I've looked deeper into the code. It *does* make ridgelines from tectonics, though not with as striking results as PerfectWorld; but the climate model is basically random and just happened to get good results a few times.

Regardless, there is a lot of code in there that may be helpful to you. Many of the map scripts build on useful shared functions in assets/Gameplay/Lua, and just reading that code (some of it is well documented) may get you started on map scripting in Lua. For example, MultilayeredFractal is a nice way of manipulating maps a continent at a time, which I took advantage of to write a map script really quickly while knowing a minimum of Lua.
 
Cephalo, could you do a PW3 for BtS? For the people who love PW2 but aren't buying CiV?

I too would love to see this

a thought occurs, would there be even a remote chance (even 10.0x10^-200,000,000,000?) that it could be CvPerfectWorld.h/.cpp?

:please:
 
Wouldn't it be much faster?

Also, if those files were added to the SDK for the "standard mods" (i.e. BBAI, RevDCM, RoM etc) then there could be a much smaller, much quicker PW (a tiny .py that just called the SDK functions), if properly exposed to python, think of the possibilities

Geostrophic Wind Patterns-> Natural Trade Winds (Age of Sail ships could move faster if they followed the Wind Pattern, slower if they went against it)

Geostrophic Wind Patterns-> Fallout spread following wind patterns instead of nine tiles centered on the target tile

those are just two, I'm sure there are more, I'm just a little brain-dead currently
 
PW in SDK would be faster but there would be no additional "possibilities" unless you actually store wind patterns to the tiles themselves. Which would be just insane.

Are you saying insane->good :yup:
or insane->bad :shake:

If you take all of the variables from the beginning of the .py and figure out tags for them, then attach those tags to Civ4TerrainInfos, I wonder if it would be possible to do ocean currents? Wouldn't that also allow for a finer control as well? It would actually facilitate modders ability to use PW and customize it. Another thought is that by making them their own .cpp/.h you could alternate, "this game I feel like having a less-than-perfect world, so I'll use basic civ4 terra map generation" and then the next game if you feel like using PW, just flip the switch, it would essentially become a Game Option
 
Wouldn't it be much faster?

Also, if those files were added to the SDK for the "standard mods" (i.e. BBAI, RevDCM, RoM etc) then there could be a much smaller, much quicker PW (a tiny .py that just called the SDK functions), if properly exposed to python, think of the possibilities

Geostrophic Wind Patterns-> Natural Trade Winds (Age of Sail ships could move faster if they followed the Wind Pattern, slower if they went against it)

Geostrophic Wind Patterns-> Fallout spread following wind patterns instead of nine tiles centered on the target tile

those are just two, I'm sure there are more, I'm just a little brain-dead currently

I'd much rather just have a slow-loading mapscript than have a cool mapscript I'll never be able to use.
 
I'd much rather just have a slow-loading mapscript than have a cool mapscript I'll never be able to use.

Why would you never be able to use it? If you play civ, you use a DLL, everyone that plays Civ uses a DLL, I am simply asking if it is possible to add functionality to something that everyone uses, if it is a question of compiling a DLL with this (if it existed), I'm sure that it would be getting used by many of the SDK-modders and if you couldn't find a base DLL + PW, I'd be willing to compile it for you (if it existed)

Would there be anyone else who would be interested in a PerfectWorld_SDK?
 
Another thought that I just had...

If the rumors I have heard are true (that the Civ5 SDK is just a pared down Civ4 SDK), then wouldn't an SDK-version of PW be usable by both Civ4 and Civ5? Kill two birds with one stone. Do the SDK files and one small .py for Civ4 and a LUA file for Civ5, instead of doing a whole revision of PW.py and a new LUA PW
 
Why would you never be able to use it? If you play civ, you use a DLL, everyone that plays Civ uses a DLL, I am simply asking if it is possible to add functionality to something that everyone uses, if it is a question of compiling a DLL with this (if it existed), I'm sure that it would be getting used by many of the SDK-modders and if you couldn't find a base DLL + PW, I'd be willing to compile it for you (if it existed)

JB is on of those mac compooters.
 
TheLadiesOgre, what would that possibly gain? (Speed is not particularly an issue for something you run once per game.)

The map scripts and all their support functions are already written in Python/Lua. To write a map script in C++, you'd either have to reimplement all the map functions in C++, or you'd have to ask the Python or Lua interpreter to do most of the work anyway. And then you'd get something that only ran on one version of the game on Windows.

Part of programming is using the right tools for the job, not using one tool for every job.
 
Excellent job, Cephalo. This is by a longshot the best map generator out there; bravo.

In the interest of making something great, better, I'd like to offer some observations.

In pw2, it seems that rainfall is a bit too heavily dependent on distance from bodies of water. Thus, the interior of nearly every continent has desert, which leads to a bit of a donut effect, where continents have rings of desert in the middle and then plains around it. Two important suggestions:

1) pw3 needs some semblance of winds or an easy cheat: heavier dependence on latitude for making deserts: check out on the link below how the Saharan and Arabian deserts butt up against bodies of water and yet receive very little precipitation. What's going on? Cool high altitude air masses sink at these latitudes, warming up and desiccating the landscape. At this latitude it is VERY difficult to have anything but desert. I think if pw2 tried to model Africa it would place a bunch of plains on the Atlantic Coast.

2) The converse effect is that the Amazon rainforests continue unabated from the Atlantic all the way to the foothills of the Andes. This is because warm ground-level air masses rise at the equator, cool, and subsequently rain as they lose moisture. I think if pw2 tried to model South America we would end up with desert or at least plains in the Amazonian interior.

3) Lastly, a bit of global ocean currents would be a great help. Why, for example, despite steep hills are there deserts on the Pacific coast of southern California and Baja California? The reason is that there is an upwelling of very cold deep ocean water very near to the shore. Cool air masses from the Pacific warm as they go onto land, and, even when forced over mountains, remain too warm to produce a rainy windward zone.

http://en.wikipedia.org/wiki/File:Deserts.png
 
So you're saying desert should be less likely at low latitudes and more likely at high latitudes? I find that fascinating, b/c my strong-rooted assumption had always been just the opposite, due to it being hotter at low latitudes; I was still following, at an instinctual level, the childhood fallacy that deserts are temperature-based and not moisture-based, even though I knew this intellectually.

I was further citing, as evidence in my own mind, the Sahara, which I had thought to be fairly near the Equator. Your map shows otherwise however. :)

In any case, such a simple linear factor on desert formation should be fairly easy to mod into PW2, as would be reducing the water proximity effect. Wind patterns and ocean currents are a much bigger deal from a programming standpoint though.

I do love Ogre's idea for trade winds hastening wooden ships, but realistically I don't think this would be a practical game mechanic... Even if you could model it successfully with the map generator and store the info in the tiles, how are you supposed to convey the wind information to the players so they can use it intelligently? Without being able to see a whole wind overlay on the world map, you'd be reduced to cursing at your screen when your fleet mysteriously can't escape its pursuers or chase down its victims, for a seemingly random reason.

As for ocean currents, sure I'd love to see them modelled in PW2 (too bad they can't be made to affect submarines as above, hehe), but I don't know anything about how they form, why they flow where they do, and if they should have any additional effects beyond adding coastal deserts.

While we're on the subject btw, shouldn't all Pangaea games have large interior deserts, and a sudden shift to 100% ice tiles everywhere towards the end of the game? Just curious. :p
 
The map scripts and all their support functions are already written in Python/Lua. To write a map script in C++, you'd either have to reimplement all the map functions in C++, or you'd have to ask the Python or Lua interpreter to do most of the work anyway. And then you'd get something that only ran on one version of the game on Windows.

IIRC, unless you implement your own variations on the functions, all mapscripts use functions that are already in the SDK, I am talking about porting the PW variations of the functions into the SDK and then using them for all of the varied things that modders might think up.

Also, correct me if I am wrong, but if the functions were already in the SDK could they not then be called by Python/Lua and performed much more quickly as there would be less to compile on the spot (which AFAIK is the reason why PW takes so long to execute with all of its code which needs compiled).

By the way, sorry it took me so long to reply, I somehow completely missed your post.

I do love Ogre's idea for trade winds hastening wooden ships, but realistically I don't think this would be a practical game mechanic... Even if you could model it successfully with the map generator and store the info in the tiles, how are you supposed to convey the wind information to the players so they can use it intelligently? Without being able to see a whole wind overlay on the world map, you'd be reduced to cursing at your screen when your fleet mysteriously can't escape its pursuers or chase down its victims, for a seemingly random reason.

As for ocean currents, sure I'd love to see them modelled in PW2 (too bad they can't be made to affect submarines as above, hehe), but I don't know anything about how they form, why they flow where they do, and if they should have any additional effects beyond adding coastal deserts.

In addition to a globe view overlay, couldn't it be displayed in the tile hover text like the latitude/longitude? If ocean currents could be done as well, then couldn't they both be tile hover text (as well as globe view overlay)? Think of the movement modifier you'd get if you had both the ocean current and the trade winds going in your favor or both going against you.

Ocean currents form due to water temperature and salinity, they sink at the poles and rise near the equator, as far as their actual surface movement I think it has something to do with the rotation of the planet (unsure though as I am not a planetary scientist).
 
Excellent job, Cephalo. This is by a longshot the best map generator out there; bravo.

In the interest of making something great, better, I'd like to offer some observations.

In pw2, it seems that rainfall is a bit too heavily dependent on distance from bodies of water. Thus, the interior of nearly every continent has desert, which leads to a bit of a donut effect, where continents have rings of desert in the middle and then plains around it. Two important suggestions:

1) pw3 needs some semblance of winds or an easy cheat: heavier dependence on latitude for making deserts: check out on the link below how the Saharan and Arabian deserts butt up against bodies of water and yet receive very little precipitation. What's going on? Cool high altitude air masses sink at these latitudes, warming up and desiccating the landscape. At this latitude it is VERY difficult to have anything but desert. I think if pw2 tried to model Africa it would place a bunch of plains on the Atlantic Coast.

2) The converse effect is that the Amazon rainforests continue unabated from the Atlantic all the way to the foothills of the Andes. This is because warm ground-level air masses rise at the equator, cool, and subsequently rain as they lose moisture. I think if pw2 tried to model South America we would end up with desert or at least plains in the Amazonian interior.

3) Lastly, a bit of global ocean currents would be a great help. Why, for example, despite steep hills are there deserts on the Pacific coast of southern California and Baja California? The reason is that there is an upwelling of very cold deep ocean water very near to the shore. Cool air masses from the Pacific warm as they go onto land, and, even when forced over mountains, remain too warm to produce a rainy windward zone.

http://en.wikipedia.org/wiki/File:Deserts.png

There is a variable near the beginning of the script called 'geostrophic factor'. If you turn that way up, you'll get a larger influence from geostrophic winds rather than the monsoon winds which are responsible for the 'donut'.

*However* I've recently discovered in my work for Civ5 that my geostrophic climate generator my be broken on this map, so you may occasionally get weird results by turning that up. I'm using a much better system for diagnosing map data with colored bitmaps this time (in PW2 it was text based kinda like ascii art.) and it's uncovering alot of rough edges in my old way of calculating things. :)
 
Top Bottom