[UTILITY] Stability BMP Generator

Linkman226

#anarchy
Joined
Sep 14, 2007
Messages
2,493
Without further ado, I am releasing my Stability BMP Generator. Two examples of maps it generated, both from Synthesis:



Currently this has been tested to work for these mods:

Spoiler Compatible Mods :

  • RFC Synthesis
  • RFC Dawn of Civilization


Because the actual coding changes between mods, the script may not work in all scenarios. Feel free to try it for your mod. If it works, let me know; if not, also let me know. I'll work on figuring out why and expanding the breadth of this script's scope.

A small caveat: You need to download some stuff for it to work. I am working on an executable file but it's not done yet. You can wait for a few days if you so desire, it should be out by them. Tops, a week. That won't require an additional downloads.

Installation instructions:

1. Download Python 2.7 or later on to your system.
2. Download pygtk.
3. Download PIL.
4. Finally, download the zip in the download link below. Unzip wherever your heart desires.
5. To run the script, double-click on 'Generate.py'.

When you run the script, the following should happen:

First the black command prompt will pop up. The process is underway. If it pops up but then suddenly disappears, something is wrong. Post your problem here.

Then a window should pop up after some seconds looking something like this:

StabMap.png

Follow the directions. An example is given above. When you're ready, click 'Generate.' The window may freeze up and claim to be Not Responding, especially on a slower computer. If it does go into 'Not Responding' mode, ignore the window for a few seconds, don't click it or anything, or it may just crash. It's just processing, that's all. After a few seconds it will close along with the command prompt. Your picture is ready. Check the directory which you selected as the target.

Fortunately, you cannot also configure some options in Config.ini. Want a .GIF instead, for example? Or a different-size image? Check out Config.ini. Here's the full list of options and what they do:

Spoiler ini Options :

[MULTIPLIERS]

X-MULTIPLIER=4
Y-MULTIPLIER=4

These are the multipliers to expand the image. Initially the script creates an image where each plot is one pixel, and then expands the X and Y according to these specifications. Four and four produce images of approximately equal size to the ones Rhye produce (off by a handful of pixels).

[COLORS]

;R,G,B format
OCEAN = 0, 0, 200
PEAK = 64 ,32, 16
CORE = 0, 155, 0
HISTORICAL = 0, 255, 0
HISTORICALOTHERCORE = 255, 255, 0
AHISTORICAL = 255, 155, 0
AHISTORICALOTHERCORE = 255, 0, 0

These denote the colors for each type of plot, depending on stability/ terrain. They are in standard RGB format, separated by commas. The colors selected as the default were the ones used in Rhye's original maps.

[MISC]

HASREBORNDIM=True ;accepts '1', 'yes', 'on' for true and '0', 'no', 'false', 'off' for false (case-insensitive)
Ignore this for now

EXT = .BMP

The format in which the image should be saved. All standard image formats can be used


Download Here- V .03
 
Future Plans (in order of priority):

  • Create an executable file to make this easier for people to download.
  • Improve the GUI.
  • Allow bitmaps of civs reborn as a different civ a la DoC and Synthesis.
  • Decrease pixelation as a result of expanding the image.

To Other Pythonistas:

See inefficiencies in my code? Have suggestions or help? Just let me know.

To non-coding Users:

Suggestions? I'm read and willing to hear, offer them up!
 
Just be aware that as of right now, it pretty much only works on DoC and Synthesis. I'll expand outwards soon enough.
 
Great job Linkman! If you have the time, I'm sure a lot of people - myself included - would appreciate if you could upload the results somewhere, instead of having everyone calculate the results themselves.
 
Awesome!

Haven't looked at the code yet. A good feature for the future could be to read "<Mod Folder>\Assets\XML\Civilizations\CIV4CivilizationInfos.xml" (or even better, one of the scenarios, to avoid unused ones like Zulu) to generate a selection list for the available civilizations so no one has to enter their tag manually.

By the way, how do you identify the civ ID with the player ID?
 
Cosmos- Will do.

Awesome!

Haven't looked at the code yet.

Have you, perchance, tested it yet? On your system? The next thing I was gonna do was upload all the DoC maps. Unless you wanna do that first.

A good feature for the future could be to read "<Mod Folder>\Assets\XML\Civilizations\CIV4CivilizationInfos.xml" (or even better, one of the scenarios, to avoid unused ones like Zulu) to generate a selection list for the available civilizations so no one has to enter their tag manually.

1. That was one of my plans- to create a dropdown menu allowing you to choose the civ directly from the GUI. And I don't read from the XML- I read from the WBS already, for exactly the reason you stated.

By the way, how do you identify the civ ID with the player ID?

I have a ID counter variable that +=1 each time it comes across 'CivType' in the WBS file, stopping when it reaches 'CivType = ' [the civ XML name you entered].
 
No I haven't. I use my spare time keeping up to date with the forums while getting nothing else done at the moment.

But if you're already reading the WBS anyway, it shouldn't be much extra effort to detect eligible civ names and put them into a dropdown menu.
 
No, it isn't. That's what I'll do.

I'll put up the DoC maps soon. I might just create a 'Generate All' button for that.

Also, did you get a chance to take a look at the code yet? You're better than this at me so I assume you might be able to give a few pointers.
 
Not yet, and I was away for the night and have just returned, so it's not exactly the right condition in which you'd want me to analyze your code ;) I think I can get at it tomorrow.
 
Alright guys, new version uploaded. Includes a dropdown menu now, including an option 'Generate All' which generates a map for every civ. Included also are the DoC Stability maps (also now in the DoC subforum).

Somewhat slower, and the generate all option could take a few minutes. Sorry. The executable might make things faster. I'm working on it, but I'm having some issues. Thanks.
 
Judging from the stability maps you made for DoC, I think I've already discovered an oversight. It looks as if you take all of the core rectangle tiles into consideration, without excluding those which are in tExceptions. It shows for example in the French core which extends into Navarre, for example.
 
Ya I noticed them as well. I had already set up the code for parsing the exceptions, it's just that I forgot to include them in the method that checks for a plot being core. Will fix when I get home.
 
New version up. Fixes the minor bug that Leoreth pointed out, makes a few speed optimizations (the only speed-hungry process now is when it initially adds all the civ names to the drop down), and cleaned up some of the uglier looking code.
 
Another version has been uploaded. I moved nearly all the python into C to improve speed. For comparison, generating all the DoC/Synthesis maps took only a minute (give or take) compared to the previous 2-4.
 
the pygtk installer you provided doesn't work, gave me import error

http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.24/pygtk-all-in-one-2.24.0.win32-py2.7.msi

that one works

edit:

i get this error for regular rfc

Code:
Traceback (most recent call last):
  File "Generate.py", line 24, in <module>
    main()
  File "Generate.py", line 20, in main
    s.create()
  File "StabilityBMP.pyx", line 37, in StabilityBMP.StabilityBMP.create (Stabili
tyBMP.c:1144)
  File "StabilityBMP.pyx", line 68, in StabilityBMP.StabilityBMP.isCore (Stabili
tyBMP.c:1794)
IndexError: tuple index out of range

and yes i changed the hasreborndimension to false
 
Top Bottom