AnotherPacifist
Deity
- Joined
- Sep 21, 2007
- Messages
- 4,878
Shame on me, but I still haven't tried it yet. But for Russia's UP, have you taken into account barbs and independents (which may not necessarily show up as war "officially")?
Actually, I realized that there's no way to check if you are at war with someone without looping through every civ and checking them independantly, so there goes that suggestion.Shame on me, but I still haven't tried it yet. But for Russia's UP, have you taken into account barbs and independents (which may not necessarily show up as war "officially")?
Update!
I found more files that could use this optimization. I've also done a couple other small things that I'm not going to try to explain.Again, this is for BTS only, other version will come soon, don't worry.
![]()
import pickle
import cPickle as pickle
#Vikings
(( "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", ),
( "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", ),
( "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "Narvik", "Hammerfest", "Hammerfest", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", ),
11: { 28: {47: 'Fort Casimir', 48: 'Fort Kristina'},
29: {47: 'Älfsborg', 48: 'Uppland', 49: 'Torne'},
30: { 47: 'Fort Christina',
48: 'Nya Korsholm',
49: 'Norumbega',
50: 'Norumbega'},
31: {49: 'Norumbega', 50: 'Norumbega'},
32: {37: 'Sankt Thomas', 55: 'Markland', 56: 'Markland'},
33: {56: 'Markland'},
Oh, I did? My bad, yes you may change it.on the AI wars you have changed the grid like you showed, but left it with "import pickle" rather than "import cpickle as pickle" like the other files, is this deliberate or can I change it?
That was me.Somebody suggested using dictionaries before, I forget why it wasn't implemented. Maybe Rhye concluded it wouldn't make that much of a difference.
Good, I'm glad.Thanks Musicfreak, that was a very helpful tutorial as I prefer to implement changes myself rather than download them. I currently have very little python knowledge but I completely understood your tutorial.
Thanks.
Thanks! About marshal...I've tried using it, but I get an EOF error every time...don't know why, but I'm guessing it has something to do with Rhye's change in the way script data is saved. The problem is, if I change it back, I also get an EOF error.Great stuff, musicfreak!
Very informative thread: pickle vs. cPickle (vs. marshal?), tuple vs. dictionairy
Thanks! About marshal...I've tried using it, but I get an EOF error every time...don't know why, but I'm guessing it has something to do with Rhye's change in the way script data is saved. The problem is, if I change it back, I also get an EOF error.I need to figure out what's causing it.
It crashes IDLE but you shouldn't have any problem opening it in a normal text editor.Absolutely amazing work man!![]()
Extra bonus: I can now finally load the CityNameManager, it was too big to load it without a crash.
I've attached some more cPickle files, the game runs even faster now.
All those files are included in my attachment...check the first post.Absolutely amazing work man!![]()
Extra bonus: I can now finally load the CityNameManager, it was too big to load it without a crash.
I've attached some more cPickle files, the game runs even faster now.
Well I think the reason for it is Rhye's change to the way Civ stores script data. The original DLL uses the ReadString and WriteString functions, which should (theoretically) work without problems (although it doesn't seem to play well with RFC). Rhye changed it to a loop that first reads an integer (the size of the string), and then loops through once for every character and uses Read() to read in every character, one at a time. He commented the block as "bugfix", although I'm thinking that's the cause of the bug. However, like I said, when I change it back to how it is in the original DLL (using ReadString), it gives an EOF error no matter what the Python code actually does...I'm not an expert, but usually you get an EOF error when using a wrong loop direction:
while not EOF
take next record
do something
instead of:
do something
take next record
while not EOF
I've encountered this problem a lot over the years in web-scripting. About still having the same error when changing it back: maybe you have to do a fresh restart (clear cache?) of civ, otherwise you get old errors. It's something I noticed when changing Python, while keeping the game open.
For me it took ages to load in any editor with syntax highlighting, and I have a pretty decent computer. I imagine that on a slower one it would just hang. Notepad works fine but I have to have syntax highlighting.It crashes IDLE but you shouldn't have any problem opening it in a normal text editor.