RFC Rand "Optimized"

musicfreak

Warlord
Joined
Nov 30, 2007
Messages
274
I've already made a fast/optimized version of normal RFC, so I thought I'd post the same changes for RFC RAND. With these changes, the game runs a LOT faster. You'll notice a lot less delay in between turns.

Enjoy. :)

EDIT: I removed the attachment because my optimization was included in the official mod. Don't worry though, there is more to come. :) Stay tuned.
 
Um, I tried it and it basically reverted me back to Civ without RFC. When I tried a game of Egypt I was defeated before my first move.
 
Thanks musicfreak. Can you incorporate onedreamer's fix for the mountain cow/sheep/wheat and maybe also change the settler numbers that used to be in RFC?
Sure, I'll take a look.

Um, I tried it and it basically reverted me back to Civ without RFC. When I tried a game of Egypt I was defeated before my first move.
Really? I just finished playing a game of this. Did you get any Python errors? I'll take a look and see if maybe I hiccuped.
 
works like a charm Musicfreak.

@AP what I did was just change the line musicfreak has posted in his first thread in the python files we had previously modified (they are only 3).

@Musicfreak if you really want to incorporate the peak fix be sure to correct the line about Japan/England which I forgot. In case you haven't done anything yet then don't worry because I am going to reupload it and with cPickle.
 
I think both MAM and I (in the succession game) were getting problems trying to load a save that was generated without the optimized version. I'll have to wait until we finish that game before, and hopefully by then Rhye would have come back from Japan and updated RFC RAND.

The interesting thing is that I'm able to use the optimized files with plain RFC and previous saves.
 
Well, I have loaded unoptimized rand saves with optimized rand...
 
AnotherPacifist, are you sure you overwrote all the files? Maybe you forgot something? Because I have not had a problem loading regular games...in fact, that's how I test it, by loading a game where I've already played into the modern age in normal RFC Rand. It seems like it works for onedreamer as well. Maybe you have a different version of RFC Rand? Or maybe I have a different version...? :blush:
 
I had the same problem as AnotherPacifist as well and I can gurantee I had all the right files because I only changed StoredData.py and RFCUtils.py from pickle to cPickle.
 
Try making the changes yourself (pickle -> cPickle) and see if it works. If it does then we just have different versions of RFC Rand. If not...then I have no idea.
 
If you updated to 1.10 then the python files are back to using pickle and not cPickle.

Just go in and change each line that says

Code:
import pickle

to

Code:
import cPickle as pickle
 
I'm little confused :p

is the RFC Rand Optimized.zip file in first post up to date / compatable with RFC Rand 1.10 OR not (must do the following changes - see below).

If you updated to 1.10 then the python files are back to using pickle and not cPickle.

Just go in and change each line that says

Code:
import pickle

to

Code:
import cPickle as pickle


Did you mean:

from
Code:
import cPickle as pickle

to
Code:
import pickle

so the python files are back to using pickle and not cPickle is correct? :)
 
No, kbk had it the right way around.

Presuming that you had RAND 1.0 optimized to use cPickle, if you then updated to RAND 1.10, the optimization is lost as the code is replaced with pickle again. To re-optimize, as kbk says, now replace instances of pickle with cPickle.
 
Hey guys, been a while. I updated my first post with the files for RFC RAND version 1.10, in case people were confused on how to manually implement the changes. As always, just overwrite the original files.

Cheers and happy holidays! :)
 
I was looking through the Python code to make the starting spot map reveal even bigger, when I noticed something:

Code:
        def revealSurroundings(self, iCiv, tCapital):
                for iX in range(tCapital[0]-2,tCapital[0]+3):
                        for iY in range(tCapital[1]-2,tCapital[1]+3):
                                gc.getMap().plot( iX, iY ).setRevealed(iCiv, True, True, -1);
                for iX in range(tCapital[0]-1,tCapital[0]+2):
                        for iY in range(tCapital[1]-3,tCapital[1]+4,6):
                                gc.getMap().plot( iX, iY ).setRevealed(iCiv, True, True, -1);
                for iX in range(tCapital[0]-3,tCapital[0]+4,6):
                        for iY in range(tCapital[1]-1,tCapital[1]+2):
                                gc.getMap().plot( iX, iY ).setRevealed(iCiv, True, True, -1);

This is how the 3 square radius BFC is created. I used a fictitious map coordinate to work out the following example:

Code:
x=20, y=30

for x in range (18, 23)
	for y in range (28, 33)

	18,28	19,28	20,28	21,28	22,28
	18,29	19,29	20,29	21,29	22,29
	18,30	19,30	20,30	21,30	22,30
	18,31	19,31	20,31	21,31	22,31
	18,32	19,32	20,32	21,32	22,32

for x in range (19, 22)
	for y in range (27, 34)

		19,27	20,27	21,27
		19,28	20,28	21,28
		19,29	20,29	21,29
		19,30	20,30	21,30
		19,31	20,31	21,31
		19,32	20,32	21,32
		19,33	20,33	21,33

for x in range (17, 24)
	for y in range (29, 32)

17,29	18,29	19,29	20,29	21,29	22,29	23,29
17,30	18,30	19,30	20,30	21,30	22,30	23,30
17,31	18,31	19,31	20,31	21,31	22,31	23,31

There are a lot of tiles that are set to revealed 3 times. I "optimized" this by using the third argument for the range() function, which is the 'step'. The initial square is 5x5, so a step of 6 is needed to make it into the big cross (additions in bold):

Code:
        def revealSurroundings(self, iCiv, tCapital):
                for iX in range(tCapital[0]-2,tCapital[0]+3):
                        for iY in range(tCapital[1]-2,tCapital[1]+3):
                                gc.getMap().plot( iX, iY ).setRevealed(iCiv, True, True, -1);
                for iX in range(tCapital[0]-1,tCapital[0]+2):
                        for iY in range(tCapital[1]-3,tCapital[1]+4[B],6[/B]):
                                gc.getMap().plot( iX, iY ).setRevealed(iCiv, True, True, -1);
                for iX in range(tCapital[0]-3,tCapital[0]+4[B],6[/B]):
                        for iY in range(tCapital[1]-1,tCapital[1]+2):
                                gc.getMap().plot( iX, iY ).setRevealed(iCiv, True, True, -1);

This results in:

Code:
x=20, y=30

for x in range (18, 23)
	for y in range (28, 33)

	18,28	19,28	20,28	21,28	22,28
	18,29	19,29	20,29	21,29	22,29
	18,30	19,30	20,30	21,30	22,30
	18,31	19,31	20,31	21,31	22,31
	18,32	19,32	20,32	21,32	22,32

for x in range (19, 22)
	for y in range (27, 34, 6)

		19,27	20,27	21,27
		19,33	20,33	21,33

for x in range (17, 24, 6)
	for y in range (29, 32)

17,29	23,29
17,30	23,30
17,31	23,31

This will hardly increase performance though, but nevertheless, it's something optimized...
 
Fierabras, good work. You're right, that probably won't make a difference at all over the course of the game, but it's things like this that need optimizing in this mod. Basically, now that pickle is replaced with cPickle, we just need to get rid of as many loops as we can (and moving stability to the DLL...but that's a different story). What I'm working on is getting rid of all the loops that loop through tiles on the map, and instead using one big one that does everything. This should speed up the game a LOT, especially with things such as Russia's UP (which currently loops through what could amount to 100+ squares, every turn). "For loops" are notoriously slow in Python, so if all these loops could be joined into one loop, it should speed up the game dramatically.
 
Top Bottom