Advertisement
Civilization Fanatics' Center

Go Back   Civilization Fanatics' Forums > CIVILIZATION IV > Civ4 - Creation & Customization > Civ4 - Map Scripts

Notices

Civ4 - Map Scripts Forum for Civ4 python map scripts

Reply
 
Thread Tools
Old Aug 08, 2007, 06:43 AM   #1
Refar
Deity
 
Refar's Avatar
 
Join Date: Apr 2005
Posts: 4,608
[Map Script] Random Script Chooser

This is a Suffle-script, that will actually choose at random from a list of different map scripts. This way we can expect good results, by choosing which scripts to include in the list, but without knowing for sure what the map will look like.

Scripts Included are:
Archipelago, Fractal, Pangaea, Hemispheres, Big&Small, Medium&Small and Terra.
I wrote none of the included scripts - i only did some tweaking and provided the 'shell'.

In addition to the shuffling i also made various tweaks to the included maps to increase diversity, credibility and playability of the scripts. This includes variations of size and location of landmasses, additional island regions, custom rules for starting plots, preventing peaks from bisecting land and some other map specific tweaks.

The Terrain Generator is adjusted to produce rather coherent desert regions but having less deser in total. I also pushed the polar snow limits a little bit, to reduce the amount of useless tiles. For Ressources and Features the default method is used.

No changes to the Placement of features, goodies and ressources have been made.

It is possible to set different Start Plot rules for Human Players. Like requesting the Human Player to start near coast (I hate starting a game as Viknigs to find out, that the next see is 2 opponents away...). This does Not affect the overall quality of the spot (Ressources nearbye etc.).

While it is possibly to control the probability of choosing different scripts or remove scripts from the rotation, there is no easy way to add a new script. A map always needs to be edited to be compartible with RandomScriptMap. I included a explanation of what has to be done, but it might be more or less difficult with different maps.

NOTE: The games original scripts will be not overwritten nor changed. I copied/subclassed them for use with the script.

Current Version is 1.25 from 18.03.2008
Merged into a single file.

This is the same version, that came with BTS patch 3.17.
You do not need these files, if you have the patch.



NOTE on Installation:
RandomScriptMap.py -> PublicMaps.
If upgrading from a earlier version, which came as 2 files, please remove both old files first.

NOTE on Customizing Map Rotation
You can exclude up to 3 Maps from menu when generating a custom world. If this is not enought or you wish to remove something permanently, open RandomScriptMap.py with Notepad. The header contains some constants the Player might want to change (and the explanations needed). I.e. the weights (probabilities) of different maps. Weight 0 is allowed and meant the map will be never chosen. It is also possible too choose explicitely, what map to play. This kind of defies the purpose of the script, but might still be useful at times.
And finally, if you enable logging, some information about the created map will be written in the PythonDBG.log.

Get it from the download database

Here's is a sample. All maps produced in sequence with ver. 1.0 and without any changes to the scripts default settings.

Last edited by Refar; Jun 24, 2008 at 08:39 AM.
Refar is offline   Reply With Quote
Old Aug 14, 2007, 07:38 AM   #2
Refar
Deity
 
Refar's Avatar
 
Join Date: Apr 2005
Posts: 4,608
After playing a game i made some adjustments for my next game.

The version 1.1 in the Download Database now includes:
- More coherent Desert regions
- Possiblilty to request special start conditions for the Human Player (Like getting a coastal plot)
- Some Tweaks aimed towards smaller maps (i play huge my self, but while testing i seen some minor glitches on Tiny and Duell - those shall be fixed now.)
__________________
The graphics in the game doesn't necessarily show you what's going on. Its just the way they've been animated.
So if you ever see any Heavy Bolter squads standing on a slope firing into the air or the ground, you may rest assured they are in fact blasting the enemy.
--------------- From a Dawn of War review.
Refar is offline   Reply With Quote
Old Aug 14, 2007, 09:43 PM   #3
LordGek
Prince
 
LordGek's Avatar
 
Join Date: Aug 2002
Posts: 508
Exclamation

Quote:
Originally Posted by Refar View Post
After playing a game i made some adjustments for my next game.

The version 1.1 in the Download Database now includes:
- More coherent Desert regions
- Possiblilty to request special start conditions for the Human Player (Like getting a coastal plot)
- Some Tweaks aimed towards smaller maps (i play huge my self, but while testing i seen some minor glitches on Tiny and Duell - those shall be fixed now.)
Hey Refar,
Is it just me installing it wrong or is this latest release FUBAR? v1.0 worked like a charm but v1.1 is creating me maps of ALL grassland (wall to wall grassland, no ocean, lakes, plains, deserts, or any other base terrains) with maybe a few hills, forests, and rivers thrown in the ENDLESS fields of green.

Thanks in Advance!
LordGek is offline   Reply With Quote
Old Aug 14, 2007, 10:26 PM   #4
Elrikk
Chieftain
 
Join Date: Dec 2005
Posts: 37
Quote:
Originally Posted by LordGek View Post
Hey Refar,
Is it just me installing it wrong or is this latest release FUBAR? v1.0 worked like a charm but v1.1 is creating me maps of ALL grassland (wall to wall grassland, no ocean, lakes, plains, deserts, or any other base terrains) with maybe a few hills, forests, and rivers thrown in the ENDLESS fields of green.

Thanks in Advance!

This happened to me also.

What I did was to move the RandomScriptUtil.py file from the customAssets\Python dir into the PublicMaps dir with the main .py file.

Has worked since then.


Elrikk
Elrikk is offline   Reply With Quote
Old Aug 14, 2007, 10:51 PM   #5
LordGek
Prince
 
LordGek's Avatar
 
Join Date: Aug 2002
Posts: 508
Quote:
Originally Posted by Elrikk View Post
This happened to me also.

What I did was to move the RandomScriptUtil.py file from the customAssets\Python dir into the PublicMaps dir with the main .py file.

Has worked since then.


Elrikk
That did the trick! So, Refar, you may want to change up your installation instructions since its now pretty clear putting RandomScriptUtil.py in the root of the Python directory (Custom or Primary) doesn't work quite right.
LordGek is offline   Reply With Quote
Old Aug 15, 2007, 11:55 AM   #6
jkp1187
Unindicted Co-Conspirator
 
jkp1187's Avatar
 
Join Date: Aug 2004
Location: Pittsburgh, Pennsylvania
Posts: 2,494
This looks good. I will give it a try tonight.

Just from glancing at it, it looks like you copied the entire script for the various options into the RandomScriptUtil.py file, and just have links (so to speak) to those scripts in the RandomScriptMap.py file. I'd like to add Tectonics and Medium_and_Small to the randomizer, and perhaps remove Pangaea....can I pick your brain a little bit on how to do this? Is it just a matter of cutting and pasting, and maybe adding the link to the RandoMScriptMap file?

Thanks.
__________________
JKP1187's Not Just Another NextWar Mod. (update pending)
NextWar: Revolutions (update pending)
JKP1187's Events
Map Scripts: Earth3.py; Terra2.py

I am buying a house and starting a new job, so Civ projects are on hold for now. I shall return!

jkp1187 is offline   Reply With Quote
Old Aug 16, 2007, 02:29 PM   #7
Refar
Deity
 
Refar's Avatar
 
Join Date: Apr 2005
Posts: 4,608
@Elrikk & LordGekOdd... I tried it and for me it does work It is CustomAssets/Python however, not just CustomAssets - probably your zipper skiped the subfolder ?
And yes it does work as well, when both files are in PublicMaps - then the "Util"-Thingie will show up in the Custom Game menu as well - but this is just a little flaw...

@jkp1187... yes basicly it is cut&paste. When i was at it, i also adjusted some little things, but this is not necessary.

The only thing you actually must take care of, are the user inputs... Many scripts will read out user inputs within the main controll method... You will find someting like self.map.getCustomMapOption(0)
... those are for the choices you have in the custom game menu - like World Wrap, Number of Continents etc. This you need to avoid somehow - hardcode or replace with a random number...

If the original script does not have any user input, and you do not wish to change nothing else, you not even need to copy and paste - you could just link to the original sctipt via import... something like:
import TerraMultilayeredFractal from Terra

To remove Pangaea you can exclude it, when making a map. Or set c_pangWeight = 0 in the header of my script - a map having the weight 0 will never be choosen.

/Edit.
I will add Madium_and_small und perhaps some more comment, so you can see what is happening - kind of before/after
__________________
The graphics in the game doesn't necessarily show you what's going on. Its just the way they've been animated.
So if you ever see any Heavy Bolter squads standing on a slope firing into the air or the ground, you may rest assured they are in fact blasting the enemy.
--------------- From a Dawn of War review.

Last edited by Refar; Aug 16, 2007 at 03:04 PM.
Refar is offline   Reply With Quote
Old Aug 16, 2007, 02:35 PM   #8
Refar
Deity
 
Refar's Avatar
 
Join Date: Apr 2005
Posts: 4,608
PS>

@ Elrikk & LordGek
Are you using any mods ? I mean the kind mod that has to be activated in the game menu... I am not much of a modder, so i just do not know, what happens with the CustomAssets if a mod is active...
__________________
The graphics in the game doesn't necessarily show you what's going on. Its just the way they've been animated.
So if you ever see any Heavy Bolter squads standing on a slope firing into the air or the ground, you may rest assured they are in fact blasting the enemy.
--------------- From a Dawn of War review.
Refar is offline   Reply With Quote
Old Aug 16, 2007, 03:13 PM   #9
LordGek
Prince
 
LordGek's Avatar
 
Join Date: Aug 2002
Posts: 508
I am using a number of mods and tweaks, so maybe they're conflicting there to be honest.
LordGek is offline   Reply With Quote
Old Aug 16, 2007, 06:47 PM   #10
Elrikk
Chieftain
 
Join Date: Dec 2005
Posts: 37
Quote:
Originally Posted by Refar View Post
PS>

@ Elrikk & LordGek
Are you using any mods ? I mean the kind mod that has to be activated in the game menu... I am not much of a modder, so i just do not know, what happens with the CustomAssets if a mod is active...


Just Blue Marble.


Elrikk
Elrikk is offline   Reply With Quote
Old Aug 17, 2007, 06:20 PM   #11
Refar
Deity
 
Refar's Avatar
 
Join Date: Apr 2005
Posts: 4,608
I uploaded the Version 1.2. The changes are:
- Medium and Small map icluded
- Some changes to the internal structure, to make adding new scripts easier.

@jkp1187 (and others who might be interested): I also included a reference in the archive, on what has to be done, to add a new script (using M&S as example). The reference is aimed towards non-programer and is - so i hope - easy to understand. How hard it will be, to reproduce the procedure with other maps, depends on the map you are trying to include.

I am considering adding Tectonics as well, but at this moment i am not sure if the author will permit this and if and when it will happen

@Elrikk: I use BlueMarble myself, so i guess it is not the problem. I cant reproduce the problem here however, so i am not really sure what went wrong for you... If you wish, you could enable the logfiles in the Civ4.ini:
; Enable the logging system
LoggingEnabled = 1

its very near end of the file. Then send me the PythonDBG.log and PythonERR.log from your BTS\Logs folder...
__________________
The graphics in the game doesn't necessarily show you what's going on. Its just the way they've been animated.
So if you ever see any Heavy Bolter squads standing on a slope firing into the air or the ground, you may rest assured they are in fact blasting the enemy.
--------------- From a Dawn of War review.
Refar is offline   Reply With Quote
Old Aug 28, 2007, 07:07 PM   #12
didact
Chieftain
 
didact's Avatar
 
Join Date: Sep 2003
Location: San Francisco
Posts: 15
Looking for Help Making Random Map script for Pitboss

I've got the RandomScriptMap.py by Oleg/Refar, thanks.

I'm trying to customize it to work with the PITBOSS for BTS. When loaded via PITBOSS most of the options are NOT accessable, which is fine as I can edit the script and put in the constants which is basically exclude archipeligo and make everything else random. I'm an OK scripter/programmer, but can someone maybe point out an example of what I might want to change ? Or let me know if this is compatible with PITBOSS?

Didact
__________________
www.dictionary.com
didact is offline   Reply With Quote
Old Aug 28, 2007, 08:28 PM   #13
Refar
Deity
 
Refar's Avatar
 
Join Date: Apr 2005
Posts: 4,608
I never tired pitboss (do not actually know what it is). From what i read...

If you open the RandomScriptMap.py you will find a bunch of constants right in the beginning. The stuff is commented... There you can set c_archiWeight = 0 to sort out the archipelago.
All custom options are allways assigned defaults (which you can also set in the header). So if just the menu is not accessible there should be no problem.

If you need to actually remove the custom options, you need to edit a couple of methods:

Code:
def getNumCustomMapOptions():
	return 6

def getCustomMapOptionName(argsList):
def getNumCustomMapOptionValues(argsList):
def getCustomMapOptionDescAt(argsList):
def isRandomCustomMapOption(argsList):
def getCustomMapOptionDefault(argsList):
Set number of custom options to 0 and delete or void (just return) the other methods.

Then edit the beforeGeneration() method, to remove the readouts for custom options. Just hardcode them with defaults (you can see the meaning of the options and the defaults in the header comments).
Code:
genMethod = map.getCustomMapOption(0)
aiStartMethod = map.getCustomMapOption(1)
plStartMethod = map.getCustomMapOption(2)
exclude1 = map.getCustomMapOption(3)		
exclude2 = map.getCustomMapOption(4)
exclude3 = map.getCustomMapOption(5)
This should eliminate all custom options.

You might also want to change the map to not being 'advanced' (return 0) since the '1' is preventing the script from showing up in some menus.
Code:
def isAdvancedMap():
	return 1
__________________
The graphics in the game doesn't necessarily show you what's going on. Its just the way they've been animated.
So if you ever see any Heavy Bolter squads standing on a slope firing into the air or the ground, you may rest assured they are in fact blasting the enemy.
--------------- From a Dawn of War review.

Last edited by Refar; Aug 28, 2007 at 08:36 PM.
Refar is offline   Reply With Quote
Old Sep 28, 2007, 10:06 AM   #14
jkp1187
Unindicted Co-Conspirator
 
jkp1187's Avatar
 
Join Date: Aug 2004
Location: Pittsburgh, Pennsylvania
Posts: 2,494
Refar,

Kudos again for this script. I played a couple of games with it recently, and ended up with some truly unexpected maps with settings that it never occurs to me to pick. Really kept me on my toes.

THanks again.
__________________
JKP1187's Not Just Another NextWar Mod. (update pending)
NextWar: Revolutions (update pending)
JKP1187's Events
Map Scripts: Earth3.py; Terra2.py

I am buying a house and starting a new job, so Civ projects are on hold for now. I shall return!

jkp1187 is offline   Reply With Quote
Old Oct 07, 2007, 09:17 PM   #15
jkp1187
Unindicted Co-Conspirator
 
jkp1187's Avatar
 
Join Date: Aug 2004
Location: Pittsburgh, Pennsylvania
Posts: 2,494
EDIT: Nevermind -- I didn't realize that the "end" comments are all classed as comments, so it doesn't matter. Delete this post!
__________________
JKP1187's Not Just Another NextWar Mod. (update pending)
NextWar: Revolutions (update pending)
JKP1187's Events
Map Scripts: Earth3.py; Terra2.py

I am buying a house and starting a new job, so Civ projects are on hold for now. I shall return!


Last edited by jkp1187; Oct 07, 2007 at 09:30 PM.
jkp1187 is offline   Reply With Quote
Old Oct 08, 2007, 07:40 AM   #16
jkp1187
Unindicted Co-Conspirator
 
jkp1187's Avatar
 
Join Date: Aug 2004
Location: Pittsburgh, Pennsylvania
Posts: 2,494
Okay, I actually have a real question this time. I noticed that the original Terra.py script has the following code:

Code:
def getGridSize(argsList):
    "Enlarge the grids! According to Soren, Earth-type maps are usually huge anyway."
    grid_sizes = {
        WorldSizeTypes.WORLDSIZE_DUEL:        (13,8),
        WorldSizeTypes.WORLDSIZE_TINY:        (16,10),
        WorldSizeTypes.WORLDSIZE_SMALL:        (21,13),
        WorldSizeTypes.WORLDSIZE_STANDARD:    (26,16),
        WorldSizeTypes.WORLDSIZE_LARGE:        (32,20),
        WorldSizeTypes.WORLDSIZE_HUGE:        (38,24)
    }

    if (argsList[0] == -1): # (-1,) is passed to function on loads
        return []
    [eWorldSize] = argsList
    return grid_sizes[eWorldSize]
It looks like you removed this from the terra script included in RandomScriptUtil.py. Why is that?

Does this mean that the Terra map included in your Random Script will not be larger that 'normal', like the default terra script is?

Reason I'm asking is that I'm trying to add both the original Terra.py and the Earth2.py script (made by another modder in this forum that piggybacked off of the original Terra.py script) to RandomScriptUtil.py. (I do not want to remove the Terra script that you modified -- these would just be additional choices.) If there was a reason (other than personal preference) that you removed it, I will remove it from
__________________
JKP1187's Not Just Another NextWar Mod. (update pending)
NextWar: Revolutions (update pending)
JKP1187's Events
Map Scripts: Earth3.py; Terra2.py

I am buying a house and starting a new job, so Civ projects are on hold for now. I shall return!

jkp1187 is offline   Reply With Quote
Old Oct 08, 2007, 01:33 PM   #17
Refar
Deity
 
Refar's Avatar
 
Join Date: Apr 2005
Posts: 4,608
You can put the getGridSize methode in RandomMapScript.py (not in Util).

However if you just use the unchanged methode from Terra.py, you will end up having all your maps bigger, not just Terra. If this is ok for you, just copy the method over.

It should be possible, to make getGridSize() deliver different grids, depending on what script will be used. Since i can not play to large maps anyway, i decided not to bother. Also i not sure, at what time the getGridSize() is actually called. If it is called before beforeGeneration() method, then the code below will allways deliver the default grid from the last 'else'.

The method needed would be something like this:

Code:
def getGridSize():
        if (argsList[0] == -1): # (-1,) is passed to function on loads
              return []

	if ( gl_mapType == MAP_TERRA ) : # Terra
             grid_sizes = {
                 WorldSizeTypes.WORLDSIZE_DUEL:        (13,8),
                 ....
                 ....
             }
             [eWorldSize] = argsList
             return grid_sizes[eWorldSize]

	elif ( gl_mapType == MAP_HEMIS ) : # Hemispheres
             grid_sizes = {
                 WorldSizeTypes.WORLDSIZE_DUEL:        (x,y),
                 .... # GridSizes you want for this script
                 ....
             }
             [eWorldSize] = argsList
             return grid_sizes[eWorldSize]

	elif ( .... ) : # Other Custom Sizes
	    ....
            ....
	else : # Default Sizes for everything not listed above
             grid_sizes = {
                 WorldSizeTypes.WORLDSIZE_DUEL:        (x,y),
                 .... 
                 ....
             }
             [eWorldSize] = argsList
             return grid_sizes[eWorldSize]
__________________
The graphics in the game doesn't necessarily show you what's going on. Its just the way they've been animated.
So if you ever see any Heavy Bolter squads standing on a slope firing into the air or the ground, you may rest assured they are in fact blasting the enemy.
--------------- From a Dawn of War review.
Refar is offline   Reply With Quote
Old Oct 08, 2007, 02:55 PM   #18
jkp1187
Unindicted Co-Conspirator
 
jkp1187's Avatar
 
Join Date: Aug 2004
Location: Pittsburgh, Pennsylvania
Posts: 2,494
Actually, I like the idea of using terra.py map sizes for my maps. So all I have to do for that is to add the getGridSize code in the RandomScriptMap.py file? Does it have to go in a specific location?

I might try your suggested code after I've had a chance to learn a little more Python. (I'm still working through the tutorial now.) As you can tell, I really want to throw a bunch of map scripts in there to make things very randomized.
__________________
JKP1187's Not Just Another NextWar Mod. (update pending)
NextWar: Revolutions (update pending)
JKP1187's Events
Map Scripts: Earth3.py; Terra2.py

I am buying a house and starting a new job, so Civ projects are on hold for now. I shall return!

jkp1187 is offline   Reply With Quote
Old Oct 08, 2007, 07:03 PM   #19
Refar
Deity
 
Refar's Avatar
 
Join Date: Apr 2005
Posts: 4,608
Yes, if you are ok with all maps being larger, you can just copy the whole method without any change.

I believe the location does not really matter, but why not put it same place it is in Terra.py, which is right after "minStartingDistanceModifier()"
__________________
The graphics in the game doesn't necessarily show you what's going on. Its just the way they've been animated.
So if you ever see any Heavy Bolter squads standing on a slope firing into the air or the ground, you may rest assured they are in fact blasting the enemy.
--------------- From a Dawn of War review.
Refar is offline   Reply With Quote
Old Oct 08, 2007, 07:22 PM   #20
jkp1187
Unindicted Co-Conspirator
 
jkp1187's Avatar
 
Join Date: Aug 2004
Location: Pittsburgh, Pennsylvania
Posts: 2,494
Quote:
Originally Posted by Refar View Post
Yes, if you are ok with all maps being larger, you can just copy the whole method without any change.

I believe the location does not really matter, but why not put it same place it is in Terra.py, which is right after "minStartingDistanceModifier()"
Cool.

Last question -- what does the value after MinStartingDistanceModifier() mean? I noticed it was "-20" for Terra, but something like "-8" for Big and Small. Does a 'higher' value mean civs will start closer together? So map scripts with -20 will start civs closer together than map scripts with -40?

Thanks again for your help!
__________________
JKP1187's Not Just Another NextWar Mod. (update pending)
NextWar: Revolutions (update pending)
JKP1187's Events
Map Scripts: Earth3.py; Terra2.py

I am buying a house and starting a new job, so Civ projects are on hold for now. I shall return!

jkp1187 is offline   Reply With Quote
Reply

Bookmarks

Go Back Civilization Fanatics' Forums > CIVILIZATION IV > Civ4 - Creation & Customization > Civ4 - Map Scripts > [Map Script] Random Script Chooser

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Advertisement

All times are GMT -6. The time now is 01:26 PM.


Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
This site is copyright Civilization Fanatics' Center.
Support CFC: Amazon.com | Amazon UK | Amazon DE | Amazon CA | Amazon FR