Issue with automatically determining BCs in trade window

DA 1.80e
(May also apply to TA; untested.)

I love the fact that it tries to calculate how much the AI will pay for a given tech/ship/planet/etc, or how much you have to pay, so we as humans don't have to (because, frankly, a computer can do that MUCH faster).

However, someone should probably take a look at that code. It's no big deal if you've only got, say, 2000BC, or even with a couple tens of thousands of BC. I was testing something (using cheat mode) in DA just now, though, and ran into SEVERE lag because of this function when my cash went over several million...my guess is it's around 5, but I'm not sure exactly. It's not like there was a lot of calculating to do, either-I just wanted one of his planets.

I've actually had one or two games where I wind up with that much money endgame, or close to endgame, and there was one game in particular that I never had that much money, but wound up making significantly more than that (about 28m BC in total) while trying to get myself out of debt-yeah, that was due to a bug; a production/buying bug on a planet got me into that hole, and eventually the UP tech vote got me out of it via Xeno Ethics-but first I had to survive and make myself 28m BC out of a 537m BC hole (that's 537,000,000BC for you folks watching at home. Well actually 536,740,000ish, but it amounts to the same thing.)

But that's neither here nor there.

Although I'm not sure exactly where the function starts to lag, my guess is (and I could be wrong), based on the amount of time it takes to compute, that it is actually trying EVERY POSSIBLE VALUE of BC.

This is clearly a problem when dealing with extremely large amounts of BC, though I wouldn't call it an everyday occurrence.

Now I know there's a simpler way to do this; there's a human way to do this. I never tried every single value before this feature, I just tried every value in a range, once I had narrowed it down by guessing too high and too low. I'm hoping the code can be modified to use that method instead, and if it does already, then I'm hoping it can be made more efficient.

Because, frankly, when my game freezes up for ~30+ seconds while doing this (not even an exaggeration) on an x1950GT/Q6600 system, there's something wrong.

I don't mean to be complaining, and this is obviously not something that everyone will experience, but it seems fixing the function would result in an overall improvement in calculation speed regardless of amount of BCs; though I admit in many cases the difference would be measured in milliseconds.

My apologies for not being as concise as I maybe could have been.
5,831 views 5 replies
Reply #1 Top
Programming is nothing but a giant numbers game, so why the code to do this doesn't already know how much each thing is worth in the first place and total it all up is totally beyond me.

I just tried it myself, though. With 28mBC I did get a second or two of lag purchasing about 14mBC worth of planets, but no 30 second lag like you describe. I have a QX6700, highly overclocked, however. Going to test one more thing, though.

Free Image Hosting at www.ImageShack.us

The spike one Core0 corresponds to the 'lag' I had, which lasted about 3 seconds, as does the drop on Core2. This was a QX6700 @ 3.5GHz.
Reply #2 Top
Timed the first one-I was right about one thing, it was more than 30 seconds. About 46-47 seconds, even.

Then when I just now bought the Drengin's last planet, it froze up for an entire minute and a half. These planets are costing me about 6-7m and I have about 15m at the time of (each) purchase.

Maybe he REALLY wants to keep that planet.

Previously, I did not have force AI to use max CPU checked, but I checked it, exited the game, and restarted/reloaded. Further, it's spiking both core0 and core3, so it's obviously using more than one core, or at least trying to.

I'm tempted to say it may have something to do with RAM, but as I've got 2 gigs, it shouldn't really be relevant. This is a tiny galaxy as well, so it's not like the rest of the game is bogging it down.
Reply #3 Top
Yada yada yada :D. If it is indeed trying out each BC value, thats bad... Someone go do a slightly modified binary search and solve this thing in O(2*log(base 2) BC-value-of-empire).


Reply #4 Top

Timed the first one-I was right about one thing, it was more than 30 seconds. About 46-47 seconds, even.

Then when I just now bought the Drengin's last planet, it froze up for an entire minute and a half. These planets are costing me about 6-7m and I have about 15m at the time of (each) purchase.
End of quote


There's some planets they refuse to sell at all, though. What are you buying that freezes you for that long? I can't imagine the difference in speed between our two CPUs would account for a tenfold increase in processing time.

I posted what I was 'buying' with 20 million. He wouldn't sell me Kora and three other worlds. How you bought the last planet from the Drengin is beyond me.
Reply #5 Top
I was allied with him, was evil, had all the diplo techs, as well as some other things, uh...

Did I mention I fired this game up in cheat mode? Yeah, I basically had -everything- going for me...was testing some other things, and when I was done, I decided to finish out the game with a different kind of bang. What can I say, I like buying their planets.

I bought his last planet for about 6.7m, though, again, the second to last planet was a ridiculous length of time as well (also about 6.5-7m). The third to last one was substantially cheaper-was either 6k or 60k, I forget which, and to be perfectly honest it didn't matter. He did the "such and such planet is very far from Drengi" thing even though it was right next door, but hey.

This was on normal difficulty, so it's not like I was playing against a "real" AI, but then again it wasn't a Cakewalk, either.

I have, however, in real games, managed to buy the last planet off of a civilization, usually to the tune of ~15m+-, on more than one occasion; also with a significant diplo advantage. Though, as this was before the auto calculation feature, I never got the exact result myself, and just got close enough.