View Full Version : Flip Calc - Calculates the probability of culture flips
anarres May 12, 2003, 02:14 PM Edit: I will always have the latest version linked in to the first post so you don't have to go looking through the thread for it...
Please note that Version 1.5 contains a significant change to the distance formula, you should update to this version straight away.
Version 1.5 (http://forums.civfanatics.com/attachment.php?attachmentid=37005)
http://www.civfanatics.net/uploads4/FlipCalc_1-4.jpg
'Distance' dialog:
http://www.civfanatics.net/uploads4/FlipCalc1.2.distance2.jpg
Change list:
- Changed distance formula from:
http://www.civfanatics.net/uploads4/FC.distance.jpg
to: max(x,y) + 0.5*min(x,y)
1.4 (22nd June):
- Added a 'Minimum Garrison' field.
- Made the whole form dynamic. If all fields have valid values the calculations will be done automatically. If any fields are invalid 'n/a' is displayed, click 'Calculate' to see which one.
- Culture numbers now can be decimals instead of just whole numbers, this is so you can enter a ratio in like 2.5 : 1.
- Distance dialog box now keeps it's data when you close and re-open it.
1.3 (15th May)
- fixed some annoying bugs
1.2 (15th May)
- added new form to allow better entry of distance
- changed icon
1.1 (14th May)
- Added error checking
- Added cumalative probability of flip
1.0 (13th May)
- First version
--------------------------------------------------------------------------------
Taken from the FAQ:
How many units do i need to suprpess a culture flip?
[list] the full formula (this is from Sorenson, who is responsible for this programming):
P=[(F+T)*Cc*H*(Cte/Cty) - G]/D
where:
P = probability that it will flip this turn
F = # foreignors, with resistors counting double
T = # working tiles under foreign control (out of the max of 21, no matter what the cultural boundaries are atm)
Cc = 2 if foreign civ has more local culture than you, 1 otherwise
H = .5 for WLTKD, 2 for disorder, 1 otherwise
Cte = Total culture of the foreign civ
Cty = Total culture of your civ
G = # garrison units
D = factor based on relative distance to capitals
Now reorganizing this gives the required garrison as:
G = (F+T)*Cc*H*(Cte/Cty)
As you can see there is a nice set of extra factors there. Now when you take a city Cc is likely to be 2 for a long while. And then there is the culture ratio. And this is a true ratio so it could be 1.1:1, 2:1, 5:1 depending on how much culture each of you has.According to this, the factor D is a crucial scaling variable that will enable us to work out the exact chance of a culture flip, since all other factors are known. 'D' should really be written 'n*d', where 'd' is the actual ratio of distance to capitals, and 'n' is the scaling factor.
P=[(F+T)*Cc*H*(Cte/Cty) - G]/n*d
My ultimate goal is to produce a 'Flip Calculator', an in-game tool that will allow you to select a city and give you the chance of it flipping to each civ.
The exact culture score of an opponent is a slight spoiler, as is the existing culture of a city you capture, so in honesty a 'Flip Calculator' would not be 'pure' (usable in GOTM and tourney) if it gained this information in game. You could still have a manual entry for these which would allow a non-spoiler version, and you could estimate the relative culture ratio fairly accurately.
Does anyone know what the value of 'n' is? If not I will run some scenarios to determine it, it shouldn't be difficult, just a little time consuming.
DaveMcW May 12, 2003, 02:48 PM D=2000, in flip formula (http://forums.civfanatics.com/showthread.php?threadid=41933)
anarres May 12, 2003, 03:08 PM Yay! Thanks DaveMcW! [dance]
I *knew* I'd seen it somewhere. ;)
Looking at the original Apolyton thread (http://apolyton.net/forums/showthread.php?s=&threadid=48254) 'n' (as it is in my forumula) is definitely 2000, and 'd' (in my formula) is the ratio of distance to capitals, capped between 0.25 and 4.
hehe, calc ahoy!
My first attempt will be a windows app with manual fields to enter the variables in. The second will hopefully integrate with civ and allow you to dynamically select a city to evaluate.
wilbill May 12, 2003, 03:20 PM Good luck with the project, Anarres. I've developed a pretty good "feel" for when there's a danger of flipping and am not wrong often, but it still happens.
Chieftess May 12, 2003, 03:55 PM Drat, there goes another attempt for me to create a civ related program. :p (atleast Visual Basic is the quick way...)
Thread moved and title changed.
anarres May 12, 2003, 04:37 PM Thanks CT! :love:
I probably will do the first version in VB, just to get it done quickly. ;)
For the second version that ties in with civ I am fairly sure that I will need to use C++ to properly access the memory stack.
Chieftess May 12, 2003, 04:42 PM I've been trying to write a dialog-based app in C++ for ages, with no success (very little tutorials. Never learned it in college... Ask Sirp. ;)). I can do it in C++ too. (besides, I'm sure someone's going to find out how to access the cities in the save before I do...)
Well, neither Borland nor Visual C++ want to link correctly... :wallbash:
anarres May 12, 2003, 05:40 PM I can do C++, I just use VB for utils with graphical interfaces.
To give meaningful data the latest version will have to work on the active memory itself, reading the values as the game is playing. Having to save a file and check it will be far to cumbersome. I know this is possible, SpiderZord is writing a GOTM logging utility that does it. :)
Chieftess May 12, 2003, 06:35 PM And here it is. I'll be moving this to the Utilities forum next. ;)
Chieftess' Civ3 Culture Calc (http://www.civfanatics.net/uploads4/CT_CultureCalc.zip)
Note: It's **VERY** crude (and thus, **VERY** beta), since I'm still trying to figure out how to work MS Visual C++. (anyone have any sites for dialog programming?)
As for the active memory, I have NO idea how to even use that, or even have a DirectX program within a DirectX program. I can't even program DirectX well...
zulu9812 May 12, 2003, 06:51 PM nice hijack Chieftess ;)
Chieftess May 12, 2003, 07:04 PM Originally posted by zulu9812
nice hijack Chieftess ;)
I figured you were coming with your wrong forum animation. ;)
anyway, the thread with my version of it is here (http://forums.civfanatics.com/showthread.php?s=&threadid=53181).
Plexus May 13, 2003, 01:20 AM I know yer name! :evil:
Nice program, ct.
Chieftess May 13, 2003, 07:36 AM Originally posted by Plexus
I know yer name! :evil:
Nice program, ct.
Now all I need is Spycatcher's name and then... :mwaha: (running gamecatcher between anarchywrksbest and spycatcher34).
Well, let's get this thing back on topic.
anarres May 13, 2003, 08:54 AM :cry:
So can I pick this up or have you claimed it for yourself CT??
Chieftess May 13, 2003, 09:01 AM You can pick it up. There can always be 2 versions. :)
Medium or supersized?
anarres May 13, 2003, 09:48 AM Well, here is my version 1.
Note: There is no error checking on any of the fields yet. The calculations seem to be fine, and it even remembers to cap the distance ratio for you if you enter in a value outside the 0.25 to 4 range.
Negative values for the flip chance should read 0.00%, stupid formatting on my part...
If you use it please post any bugs here.
The next version will have full error checking in, and it will allow a decent input system for the distance ratio (should have NW-SE distances for both human and AI).
Please also note that it was written in VB6 for development speed. ;)
anarres May 13, 2003, 09:55 AM Here is a screenie:
http://www.civfanatics.net/uploads4/FlipCalc.jpg
Moulton May 13, 2003, 11:29 AM Anarres -- could not find yours to download....
I still believe that the final datum is the Jokers-Wild random chance of flipping, no matter what else is happening. I have taken to leaving only one unit in a city once the resistance is quelled.
anarres May 13, 2003, 11:37 AM Moulton, the file is *attached* to post 16. (3 up from here).
Please post comment/feedback. I guess CT will get the popular vote, but it would be nice if *someone* found a use for mine. ;)
Edit: I also linked the attachment in to the first post, that can act as a pointer to the latest version...
Moulton May 13, 2003, 12:16 PM Thanks, I will try both. Wish I had thought of it :(
kring May 13, 2003, 12:27 PM I will try both as well.
betazed May 13, 2003, 03:53 PM Anarres,
Great tool. I tested it a bit. It worked fine. However, now and then I would get this error.
I uploaded a screenshot.
http://www.civfanatics.net/uploads4/culflip.jpg
HTH in your debugging.
BTW, I will be glad to help you port this to VC++.
Chieftess May 13, 2003, 04:01 PM Do a check for 0 culture, too. That can cause a runtime overflow. (devide by 0)
betazed May 13, 2003, 04:04 PM Also leaving any field blank will yield a runtime error. That should be easy to check and rectify.
anarres May 13, 2003, 04:18 PM Thanks people! :)
As noted above:
Note: There is no error checking on any of the fields yet.
I am going to have to wait until tomorrow as I have forgotten to email the work home. On the bright side, I should be able to knock out the field checking and error handling in my lunchhour, like today. ;)
betazed, my C++ is rusty, but should suffice. If I need a hand I'll shout.
At the moment I am concentrating on working out how to access the memory to be able to run in-game. I know SpiderZord has done this in the Powerbar and in his GOTM project, so I have PM'd him to ask for 'pointers'. :D
Chieftess May 13, 2003, 05:24 PM I'm still trying to get the algorithm down pat. :)
Siegmund May 13, 2003, 08:26 PM Two further questions about flip probabilities -- and I am not sure the answers have been investigated yet, but I hope so:
1) Does the Forbidden Palace change the "distance to capital" flip modifier, the same way that corruption is measured based on "distance to Palace or FP, whichever is closer"?
2) Is a "foreign citizen"...
a) Only citizens of the civ to which you might flip;
b) Any citizen of one of the other civs in the game; or
c) Any citizen of ANY other culture including those of completely destroyed but not yet assimilated civs?
Chieftess May 13, 2003, 10:51 PM 1 - No, I think I read somewhere (maybe even one of the Firaxians said it) that the FP does not affect the distance.
2 - I think it's any citizen that's not of your nationality. that's why war torn cities tend to flip so easily.
Sirp May 14, 2003, 01:22 AM I believe that it's the number of foreigners and number of resisters of the civ that's trying to cause the flip.
Think about it, you attack the English and take an English city, so then you have a heap of foreigners in that city. The city can flip back to the English, according to the formula. Can the city flip to the Spanish who are on the other side of the map? Uhh...no.
-Sirp.
anarres May 14, 2003, 04:43 AM 1) Yep, only distance to capital, FP is ignored.
2) I agree with Sirp, IIRC it is only foreign citizens of the civ in question, not all foreign citizens.
anarres May 14, 2003, 06:45 AM I REALLY NEED HELP FINDING THE PTW MEMORY OFFSETS!
I have no idea how anyone ever found these, but if you know please post here or PM me!
SpiderZord May 14, 2003, 08:25 AM I am writing a utility to calculate the chance of a culture flip. ... I would *really* like to integrate this with civ by readig the city data from memory.
I have just 2 questions:
1 - Is it possible to read not only the citizens (including how many resisting) and 'covered' tiles in the 21 tile radius, but also the number of units in the city with attack value (i.e. 'police' units)?
2 - If so, could I possible look at some of your source code, most noticabily the offset information for reading the memory?
anarres,
I have looked at the formula and I have most of what you need. As you mentioned, I'm currently working on PowerTimeLine (the documentation utility for GOTM/QSC) - and as part of that work, I am packaging the memory reads of civ data as a vb dll. My intent with the dll was to give all of you helpful utility programmers access to the game variables you need. I am currently drowning in finalizing something for PTL - when I get something finished, we can work through the rest of the items you'll need ( I don't have citizen status yet - happy, content, resisting, but should be able to find it). I would simply give you the offsets, but it gets complicated - you need the three most complex objects (cities, tiles & units) which are scattered all through process memory and have to be located with pointer arrays first. If you give me some time, I can even incorporate some or all of the calculation as functions available from the dll... :)
anarres May 14, 2003, 08:35 AM Thanks SpiderZord! :D
Do you do MS Messenger? I have found an msm address for you, if you can come online at some point I would love a 5 minute chat. :mischief:
Chieftess May 14, 2003, 08:37 AM I'd like that for mine to. Though, I'm sure Anarres' will be better than mine.
anarres May 14, 2003, 11:54 AM Latest version 1.1 attached.
I have added error checking on all fields and have also added code to tell you the chance of a flip in 'n' turns.
http://www.civfanatics.net/uploads4/FlipCalc1.1.jpg
Mazarin May 14, 2003, 11:06 PM great tool, anarres:goodjob:
one more question on the "distance to capitol": is this the "true" distance or the distance in tiles? e.g. if a city is 5 sqares diagonally awy from a capitol, do I have to work with sqr(50) or 5 as the distance?
anarres May 15, 2003, 06:03 AM The distance uses euclidian distance with NW-SE and NE-SW axis'.
So, if you count the number if tiles you have to go in the NW-SE direction and call it 'x', and call the NE-SW distance 'y', then the distance formula is:
http://www.civfanatics.net/uploads4/FC.distance.jpg
In your example the distance is 5 tiles.
For another example, it it is 6 tiles in the NW-SE axis and 8 tiles in the NE-SW axis, the distance is
SquareRoot(6*6 + 8*8)
= SquareRoot(36 + 64)
= SquareRoot(100)
= 10 tiles
Note that for simplicity I have chosen one of the few examples with a whole number as the answer.
anarres May 15, 2003, 06:13 AM Version 1.2 will contain a system for entering the distance to both capitals in NW-SE and NE-SW style, but will also retain the option to just enter the ratio directly.
Anyone got anything else they want in 1.2?
Version 2 will be the holy grail that integrates with Civ and reads the values from memory. You will be able to select one of your cities and calculate the odds of a flip without any further input.
anarres May 15, 2003, 06:22 AM A big thank you goes out to SpiderZord who has pointed me in the right direction and provided some badly needed memory offsets.
:worshp: :worshp: :worshp: :worshp: :worshp:
anarres May 15, 2003, 06:51 AM Hmm, sorry for doing 4 in a row, but...
I need advice on which icon to use for the Flip Calc. As you can see I'm no picasso, so if anyone out there can make me a better one then please do so.
http://www.civfanatics.net/uploads4/FC.icons.big.jpg
And here they are real size:
http://www.civfanatics.net/uploads4/FC.icons.jpg
anarres May 15, 2003, 10:05 AM Version 1.2 is now available!
Changes:
- added new form to allow better entry of distance
- changed icon
New 'distance' dialog:
http://www.civfanatics.net/uploads4/FlipCalc1.2.distance2.jpg
http://www.civfanatics.net/uploads4/FlipCalc1.2.jpg
anarres May 15, 2003, 02:35 PM fixed some annoying bugs
Skyfish May 18, 2003, 05:01 PM You did choose the best icon that was on offer :)
anarres May 18, 2003, 05:11 PM I still want a better one, but it looks ok on my quick launch bar:
http://www.civfanatics.net/uploads4/FlipCalc.quicklaunch.jpg
Hygro May 20, 2003, 01:21 AM I like it :D
Just one question--how do you know the total culture of the AI?
edit:
Also, wouldn't it be good to know how many of the citizens are of your own nationality?
anarres May 20, 2003, 03:31 AM Just one question--how do you know the total culture of the AI?At the moment you have to guess it, later on I will provide means of finding that within the application.
The real issue is the ratio of culture. If you think the AI has 3 times the amount as you (from the F7 screen) you can enter '3' for the AI and '1' for you.
Also, wouldn't it be good to know how many of the citizens are of your own nationality?Why? It not part of the forumula... :crazyeye:
Gen May 20, 2003, 09:06 AM I've just found your utility, anarres. It's really great, very helpful :goodjob:
However, there is a serious error in calculations. Program doesn't correctly value the new (added in some patch) garrison suppress cap factor which basically says that strong enough garrison reduces flip probability to 0 no matter what.
The rule for calculating what is "enough":
let FP (Flip Point) = 1 foreign citizen or 1 tile in enemy teritory. 1 resistor = 2FP.
Sum all FP counting foreigners, resistors (*2) and tiles. Multiply FP by happiness factor just like in original formula, but ignore culture ratios, distances and other factors. Then garrison city with 2 * FP units - that city will never flip (at least it shouldn't according to Firaxis ;) ), even if your culture is 100 times lower and enemy capital is next door.
Taking symbols from original formula:
"Absolute control" garrison = (F + T) * H * 2
H = 2 if civil disorder, 1/2 if WLTKD, 1 otherwise
anarres May 20, 2003, 11:20 AM Thanks for the praise Gen. :)
I didn't include the garrison required yet (it is version 1.4), but where is this info about a new maximum garrison? It's not that I don't believe you, but I have not heard of it before. A link would be most useful.
FWIW, it would suit me perfectly to be able to ignore the culture factor for minimum 'safe' garrison. For me the ratio is often 1:5 against me, and this makes a *huge* difference to the required garrison as stated in the original formula.
Note that 'culture ratio' and 'local culture' are given values of 1 and the whole thing is doubled to get your new equation from the old:
G = (F+T)*Cc*H*(Cte/Cty)
If Cc = (Cte/Cty) = 1 then
G = (F+T)*H
Chieftess May 20, 2003, 02:21 PM Originally posted by Gen
I've just found your utility, anarres. It's really great, very helpful :goodjob:
However, there is a serious error in calculations. Program doesn't correctly value the new (added in some patch) garrison suppress cap factor which basically says that strong enough garrison reduces flip probability to 0 no matter what.
The rule for calculating what is "enough":
let FP (Flip Point) = 1 foreign citizen or 1 tile in enemy teritory. 1 resistor = 2FP.
Sum all FP counting foreigners, resistors (*2) and tiles. Multiply FP by happiness factor just like in original formula, but ignore culture ratios, distances and other factors. Then garrison city with 2 * FP units - that city will never flip (at least it shouldn't according to Firaxis ;) ), even if your culture is 100 times lower and enemy capital is next door.
Taking symbols from original formula:
"Absolute control" garrison = (F + T) * H * 2
H = 2 if civil disorder, 1/2 if WLTKD, 1 otherwise
What about mine? ;)
I just noticed mine has the same problem with the garrison. (one ours split their ways to game save and ingame, they'll be completely different animals).
Hygro May 20, 2003, 05:05 PM Originally posted by anarres
Why? It not part of the forumula... :crazyeye:
Wait a sec... but isn't it important for flipping the other way? I'm having trouble wording this, but if you have more of your own nationals it would make it harder to flip to them? Or just make it easier to flip back to you?
Gen May 21, 2003, 03:45 AM Sorry Chieftess, I did not try your program yet. I'm going to correct that mistake and download it right now! :)
anarres & Chieftess:
Now, the suppress factor. It was introduced in patch 1.17f due to number of complains about flipping Firaxis were receiving from many players. I've done some searching for you and here are the results -
Quote from 1.17f readme.txt file:
"* It is now possible to completely suppress a city's cultural reversion with enough military units. "
That information was then precised by Soren Johnson, originally on Apolyton (sorry I did not found the thread but here is a LINK (http://apolyton.net/news/index.php?Category=Civ3&Offset=44) to Apolyton's news archives where you can read that):
"Number of units to supress cultural reversion: cities with 2 or 3 foreign nationals and full control of their city radius probably will be under no risk with 4 to 6 units"
... which corresponds well with "my" formula. Agree with anarres, that makes HUGE difference when you are backward culturally!
This change was then discussed in a couple of threads, for example:
http://forums.civfanatics.com/showthread.php?s=&threadid=16438&highlight=culture+flip+1.17f
http://forums.civfanatics.com/showthread.php?s=&threadid=16441&highlight=culture+flip+1.17f
Unfortunately, I couldn't find more detailed information :( (although I could swear I've read more precise info somewhere, and I use that rule in every game since 1.17f and never had a single flip). You may ask other posters (IIRC Zachriel and Catt are convinced about that formula being right, maybe they have better source of information than me). Or maybe just mail Soren directly? If he answers, it would be great to update our FAQ as well!
Gen May 21, 2003, 04:39 AM Originally posted by Hygro
if you have more of your own nationals it would make it harder to flip to them?
Unfortunately, no :(
Originally posted by Hygro
... Or just make it easier to flip back to you?
Yes, if the worst happens and your city flips, more of your nationals will mean more chance to you to get city flip back.
anarres May 21, 2003, 04:41 AM Dan Magaha FIRAXIS
It all goes back to the factors I listed in that thread. Note that ground units are one of the LEAST influential factors -- if the city you captured had a lot of culture in it from its previous owners, you will need a LOT of units to completely suppress any chance of it flipping.
Also remember total culture counts here, too. So if you're warmongering and have very low total culture this will hurt you in city-flipping calculations.
OTOH, if the city is equidistant between the capitals of the two cities in question, neither of you have ever produced any culture in it, and your total cultures are on par with each other, you might only need a couple of units.Link to post (http://forums.civfanatics.com/showthread.php?postid=190320#post190320).
Note that in that thread they are discussing Civ3 1.17 patch, and the post by Dan Magaha clearly states that total civ culture and local culture are factors.
The 'one liner' comment from Soren is true when certain conditions are met (like culture ratios). In fact, allowing for local culture to be greater for the AI (in a recently captured city), Sorens comment about needing 2 garrison for every foreign national is true.
Again, I *want* to believe you, I *want* it to be true, but none of the links provide any evidence of this formula.
Here's to hoping we find out for sure. To help us in the quest for knowledge I made a thread in GD:
Minimum garrison required to stop a flip? (http://forums.civfanatics.com/showthread.php?s=&threadid=53877)
Gen, I would appreciate you posting there to help stimulate some feedback.
Sirp May 21, 2003, 05:53 AM I'm not sure which is the case, but I have always followed the principle that if G > (F + T) * H then the city can *never* flip, and I have never had a city flip on me when I have followed that principle (since the patch where they changed how it works).
Has anyone had a flip under such conditions?
-Sirp.
anarres May 21, 2003, 06:12 AM Hmm, if no-one has answered my questions with hard fact or experimantal data by tonight I will run a scenario to test it.
Remember Sirp, unless the culture ratios are very big the chance of a flip will be very small, often well under 1%. It probably isn't hard to not get a flip under these conditions.
TheNiceOne May 21, 2003, 06:19 AM Contrary to Sirp, I've always thought that
G = (F+T)*Cc*H*(Cte/Cty) is the correct formula for number of garrisons necessary. It certainly seems so from Dan Magaha's input. But I haven't tested it though.
I haven't tested your flip calc anarres (I just got informed about it from your thread in General Discussions), so I'm not sure whether it caps the distance ratio correctly. The distance to capital ratio is capped at 1:4, so "D" in the formula must be between 500 and 8000.
Sirp May 21, 2003, 06:26 AM anarres: Yes I realize that, so I'm wondering if anyone else has had a flip under such conditions :)
Because still, not having even *one* after all the turns I've played is reasonably hard. And, I generally play on Deity or at least Emperor, so I am usually badly outgunned in terms of culture by the AIs, so the ratio is in their favor.
TheNiceOne: Yes, I realize that Dan Magaha said that, but I think they might have changed it in a patch after what he said.
Certainly, flips are LOTS less likely as of recent versions.
-Sirp.
aaglo May 21, 2003, 06:33 AM I have one question:
How do people use these culture flip calculators?
Can they see the enemy cities? Well, with spies you can :)
Or is this tool for the scenario makers - like "you have to do anything you can to prevent those three cities in the another continent to prevent from flipping"?
In my games I haven't seen any useful situation to use this kind of calculator. Well, maybe sometimes, when I've wondered about some stubborn city not converting... :)
Sirp May 21, 2003, 06:36 AM aaglo: you can see how many tiles in the city radius are under your control, and you'd have a good idea if they have any of your population in the city.
So you can calculate it without seeing inside the city. You can also see inside the city using an embassy, no need for a spy.
Further, it can be used to determine the chance of one of your cities flipping to another civilization, which is the more common usage for it, at least on high levels.
-Sirp.
aaglo May 21, 2003, 06:39 AM Oh yes, I forgot it works both ways :D
anarres May 21, 2003, 06:41 AM TNO, the distance ratio is capped between 0.25 and 4 for calculations.
Even though it will let you enter a value of 5 it will still use 4 in the calculation. :)
Certainly, flips are LOTS less likely as of recent versions.Sirp, is this observation or fact? I ask only because others have said it too, but AFAIK the last change to flip formula was in Civ2 1.17f...
Wow, I seem like a real 'naysayer' but all I want is something to back up the ideas the culture flips are not as stated by Soren over a year ago.
Sirp May 21, 2003, 06:45 AM anarres: it's purely anecdotal, but seeing as how many people say it, it sounds like it's fact.
Of course I suppose it could just be that people have learnt to deal with flips better...
-Sirp.
anarres May 21, 2003, 06:47 AM aaglo and Hygro,
The reason there is no 'enemy city' flag to check to see if you can flip the enemy is because the calc is designed to be used for the city under chance of flip, by the occupying force.
In the calc replace all instances of the word "AI" with the word "the other civ", and you can see it will work for the AI city if you pretend to be an AI person using the calc.
If that didn't make sense I am sorry, but communication was never my strong point. :crazyeye:
Hygro May 21, 2003, 04:44 PM Well I know what you're trying to say, even if I'm having trouble reading it (my reading not your writing is where the problem lies).
Dr Alimentado May 22, 2003, 11:29 AM Excellent utility anarres :goodjob: I have never worried about flips too much in PTW, but it's very useful to have the actual numbers. I can see that I have often actually been running a real risk (esp. over 20 turns or so)... scary!
A question: am I right in thinking that the relative culture values have to be entered as integers? The reason I ask is that I initially entered values of 1.1 and 1, but this gives a different flip probability to entering 11 and 10... In fact a quick test shows it's rounding the values to the nearest integer (although .5 down), is it feasible to allow fractional entries here? np if not, but if I'm guesstimating the relative culture values they end up in my head as fractions not integers :)
Also a couple of (very minor) suggestions for the interface: I would suggest making the Calculate button the default button so that if you press enter it does a prob calculation regardless of which box has the focus. You could also make it so that when you Tab the focus it selects the current text in the next box (instead of just giving the focus) so you can enter a new value without having to delete the current text. And just from a perfectionist POV you could make the two probability textboxes labels as they don't need to take input :D this is nitpicking I know! So rest assured it is a dam good job ;)
Cartouche Bee May 22, 2003, 12:08 PM Sorry if this is covered some where else in the thread.
What happens when the AI does not have a capitol (settler in galley)? How numbers do you enter for the distance ratio for that situation? I know that there is an allowance in the basic equation for this cause I did have a city flip under this condition once. :(
anarres May 22, 2003, 12:12 PM The distance calculation is capped between 0.25 and 4.
The scaling factor in the 'D' in the equation is 2000, so with no capital the flip equation comes out as:
P=[(F+T)*Cc*H*(Cte/Cty) - G]/500
Funnily enough I only recently found out about the distance capping myself. Until then I thought it impossible to get a flip without an enemy capital.
Cartouche Bee May 22, 2003, 12:30 PM OK, so punch in 4. Believe me it was darn irritating when it happened, and I was scouring the face of the earth looking for that galley after that and it was a huge map.
anarres Jun 21, 2003, 07:47 PM Changes:
- Added a 'Minimum Garrison' field.
- Made the whole form dynamic. If all fields have valid values the calculations will be done automatically. If any fields are invalid 'n/a' is displayed, click 'Calculate' to see which one.
- Culture numbers now can be decimals instead of just whole numbers, this is so you can enter a ratio in like 2.5 : 1.
- Distance dialog box now keeps it's data when you close and re-open it.
http://www.civfanatics.net/uploads4/FlipCalc_1-4.jpg
anarres Jun 26, 2003, 04:33 PM Look what I found:
Posted by alexman
Corruption calculations do not use Euclidean geometry, nor unit movement points, to get distance. Instead, the distance is based on the shortest path, where each orthogonal move costs 1.0 and each diagonal move costs 1.5. Another way of writing the distance formula is Distance = max(x,y) + 0.5*min(x,y), where x and y are the distance in the NW/SE and NE/SW directions, respectively. (Discovered by DaviddesJ)This is from alexman's Do you think you understand corruption? (http://forums.civfanatics.com/showthread.php?s=&threadid=19922) strategy article.
At the moment the FlipCalc uses Euclidian distance, which we all used to believe Civ used as well. :crazyeye:
It looks like I will need to update it to use the 'Civ' definition of distance...
Chieftess Jun 26, 2003, 05:19 PM I guess this means mine will be needing an upgrade, too. ;) Looks like we're going to have to figure this out in MSN IM for both of our programs.
anarres Jun 26, 2003, 06:43 PM Changes:
- Changed distance formula from:
http://www.civfanatics.net/uploads4/FC.distance.jpg
to:
max(x,y) + 0.5*min(x,y)
Please note that this is a significant change, you should upgrade to Version 1.5 straight away.
anarres Jun 26, 2003, 06:58 PM Chieftess, here is the function I wrote for distance, pretty trivial:
Private Function Distance(ByVal i As Integer, ByVal j As Integer) As Double
Dim min As Integer
Dim max As Integer
If i < j Then
min = i
max = j
Else
min = j
max = i
End If
Distance = CDbl(max) + 0.5 *CDbl(min)
End Function
Edit: No matter whether I use tabs or spaces, I can't get it to indent. :mad:
Edit2: So that's what the code tag is for....
Harrier Oct 24, 2003, 07:45 PM All this technical detail goes over me. I just do not understand it.
However, a trick I have learnt on regular civ3, (I do not have PTW)
is that if you have done a save game before end of turn, and you get a culture flip of one of your cities. Re-load the game and move all your units (or leave 1) out of that city - if they have movement points. On replaying the end of turn it will not usually culture flip. Although a different city may do so, but not always.
So IMHO the AI must also take into account how many of your units it can destroy (an AI cheat!!) if it performs a culture flip.
So, if you need say 30 ground units to prevent a culture flip, but you have only between 2 to 29 it will occur.
However if you have 0 or 1 ground unit in the city it is unlikely to occur. But you now run the risk of being attacked by the AI, if the city is near AI units.
Padma Oct 24, 2003, 10:50 PM It's not an AI cheat. The movement of troops out of the city apparantly causes the AI to do things differently on its turn, thereby altering the RNG seed value. Thus, when the check is made for the flip, a different value is produced. (And the probability of a flip on any given turn is normally so low that it wouldn't take much of a change in the generated number. ;) )
anarres Oct 25, 2003, 07:58 AM Harrier - the reason I made the FlipCalc was so that people don't have to fully understand the calculations to be able to use it and see what the chances of flip are.
You can try putting in different values and see how things like garrison, distance, AI pop in the city and overall culture levels can affect the chance of flip - you may be suprised by som e of the numbers.
The main effect making this calc had on my play is that now I always starve to size 1 if I am keeping an AI city - it's just not worth the risk most of the time...
Globetrotter Nov 05, 2003, 11:53 AM Anarres
Nice tool!
:goodjob:
However, i had this crash a couple of times (see attached)
It always occured when i enter a high AI culture, and mine is low.
The error message reads (t'is in french):
Execution Error '6':
Capacity overflow
This is the 1.5 version
Thx
Edit: can you PM me please when you get to see it?
Thx
anarres Nov 05, 2003, 12:29 PM On it Globetrotter - I know from the error it is an overflow problem. I must have assigned something to a 16-bit integer instead of a 32-bit one. Give me a day or so (PBEM's to play ;))
Globetrotter Nov 05, 2003, 12:46 PM Originally posted by anarres
On it Globetrotter - I know from the error it is an overflow problem. I must have assigned something to a 16-bit integer instead of a 32-bit one. Give me a day or so (PBEM's to play ;))
Take your time
No worries... We're here for a looooooooong time... ;)
Thx again
royfurr Nov 19, 2003, 08:35 PM anarres,
any idea how well/accruately the Mighty FlipClac will work in C3 Conquests?
anarres Nov 20, 2003, 02:49 AM I don't have C3C yet (not released yet in the UK), but if someone wanted to test flip chances for me I would be grateful. :D
Failing that I will do it when I have a few hours to spare (and once I have Conquests of course)....
Globetrotter - I will release a version without the overflow problem this week.
royfurr Nov 21, 2003, 06:29 AM Sorry, anarres, can't help yet- don't yet have C3C. I will at some point (else I wouldn't be interested in how FlipCalc will work in the new version of the game)!
Good luck, hopefully others can help or you get it quicker then I (budget is quite tight right now!).
Maybe Santa Caus will help me out ...
anarres Dec 08, 2003, 02:02 PM Globetrotter,
Sorry for the delay, it slipped past me in the excitement for Conquests....
I've put the values in form your pic and I don't get the error. I can get it by putting in 99999 for the AI culture and 0.00000000000001 for your culture. I can fix the problem I found, but I am interested in how you got it? :confused:
subbss Dec 28, 2003, 12:44 PM Is there a way to reverse the process to find out the chance an enemy city will culture flip to you. (i.e. you get their city)
Could that be done with this program or would a new one have to be made?
Great job on the program, btw:cool: .
Greebley Apr 20, 2004, 08:27 AM I was using your flip calculator and think I noticed a subtle difficulty.
It is my believe that civ distances are integer. The support for this belief is that in RCP you could place cities at civ distance 4 or 4.5 and still get the benefit of RCP for all cities. If 4 and 4.5 were different distances this would not be true.
I tried putting in 5 NW and 1 NE which gave 5.5. I guessed the capitol to be 15 squares NE. The ratio your calculator gave was 2.78. However, if I am correct, then the 5.5 should be rounded to 5 giving a ratio of 3.
anarres Apr 20, 2004, 09:30 AM Ahh yes! Indeed I made the Calc before it was realised that distances were integer.
I will make an update. Thanks! :)
Moonsinger Apr 20, 2004, 12:39 PM Hi Anarres,
Have you considered taking this utility to the next level? For example, you could turn it into a floating icon on top of Civ3 and read the save game file to display a list of city for us to select (alphabetically sorted, etc). Base on the user selection (multiple cities selection may be supported), display the probability of culture flips, etc.
I'm sure Ainwood would love to incorporate this this feature into his Trade Assist utility too.:mischief: I hope that he or someone else does because it would be nice to have all the collection of these wonderful tools at one place.
anarres Apr 20, 2004, 01:20 PM I have indeed thought of this, but when I tried SpiderZord for help I didn't get quite as much as I needed, just some basic memory offsets.
If someone is offering to provide dll's to help read active memory I'm all ears! :D
Kevin Ar18 Apr 24, 2004, 01:06 AM I noticed something while using the Filp Calculator today.
I am running Windows XP Home.
It seems that it uses up a lot of the CPU: 60 - 97 % on Windows XP
It doesn't cause a slowdown or anything (since I'm guessing the CPU is not really working that hard), however it does cause my power supply fan to kick in to a faster speed.
Anyways, I just thought I'd mention it. I think some other programs have had similar problems when run on Windows XP. In one of the programs, the issue was caused by how the messages were handled. I don't know if the cause is the same for FlipCalc or not.
anarres Apr 24, 2004, 08:14 AM Unfortunately I did FlipCalc in VB6 so I could write it in an afternoon (it's nearly all GUI).
The downside is that you have to use the DoEvents() function which "releases" CPU cycles in a message thread. This makes CPU eat up empty cycles if no other app is using them and so the CPU is high even though it is doing nothing.
The upside is (as you say) is that nothign is actually slowed down - as soon as another app needs the CPU it is given. Your CPU shouldn't actually heat up in this time, so if you care about fans then you could invest in a cheap temperature fan-controlling system. I have one that sits in a CD bay and only turns the fans on over a certain temperature - that way it matters not what the CPU activity is, only how hot it is. FWIW my sensor system controls up to 8 fans individually and costed only £20 online.
A permanent solution is for me to re-write in c++ or c#, but I vowed no more c++ or vb6 recently so it may have to be c#, which maybe I will do when I get time.
HTH
anarres Apr 24, 2004, 08:31 AM I just thought that I could add a 50ms wait in the DoEvents() loop, that may drop the CPU a bit - I will do some testing. :)
Kevin Ar18 Apr 26, 2004, 02:32 PM Originally posted by anarres
I just thought that I could add a 50ms wait in the DoEvents() loop, that may drop the CPU a bit - I will do some testing. :)
Alternatively, if you could provide me with the calculations, I can also make an html/javascript version -- although that has the downside of more memory usage.
On the other hand, converting to C++ would also take very little time, but I too am not programming right now either.
classical_hero Dec 07, 2004, 08:18 AM Anarres, is it possible to upload the utility because I cannot download it properly as an attachment.
anarres Dec 07, 2004, 08:31 AM http://www.civfanatics.net/uploads8/flipcalc_1-5.zip
Personally, I got very good at doing close estimates in my head (I can do sums quite well). Now I use CRPSuite for SP games to see flip chances (although there have been a couple of issues so far where it has been wrong, so I also check with flipcalc too if it is important).
Dianthus Dec 07, 2004, 08:34 AM Now I use CRPSuite for SP games to see flip chances (although there have been a couple of issues so far where it has been wrong, so I also check with flipcalc too if it is important).
Could you let me know if you see any more examples of these? I'm happy to fix bugs, if I know about them...
anarres Dec 07, 2004, 08:59 AM hehe, you've seen the main one I was thinking about and fixed it. The main reason I check is just to be safe (I only bother checking when odds are > 1%). :)
AFAIK, one thing CRPSuite doesn't do yet is give the flip values for each civ it could flip to, and it doesn't tell you the chance of enemy cities flipping to you, but these are very minor things. Note I could be wrong - I've not had time to play much civ at all recently (the last 3 months), so most of what I say these days is from memory only.
P.S. How do you calculate distance? I use 1 and 1.5 distances and round down like for corruption, and I assume you do the same.
Dianthus Dec 07, 2004, 09:08 AM AFAIK, one thing CRPSuite doesn't do yet is give the flip values for each civ it could flip to...
Correct. I only tell you about the civ that the city has the highest chance of flipping to. Hmm, I was originally thinking that this was all you would need to know, but I'm wondering if maybe it would be useful to also show the total chance of flipping to any civ?
... and it doesn't tell you the chance of enemy cities flipping to you...
True. I couldn't think of a spoiler safe way to do this. I.e. don't know number of foreignors/resistors/garissoned troops.
P.S. How do you calculate distance? I use 1 and 1.5 distances and round down like for corruption, and I assume you do the same.
Affirmitive.
AFAIK there is only one outstanding (not good, remaining ;)) bug to do with flipping in that I'm currently including non-military units and artillery type units as MP :blush:.
classical_hero Dec 09, 2004, 07:17 AM @ Anarres, :thanx:
1889 Apr 21, 2005, 01:07 PM Does the number of citizens of your own race have any affect? Could I add workers to a captured city to make it less likely to flip?
MOTH Apr 22, 2005, 10:23 AM @1889,
No there is no affect from adding native citizens.
MRick Apr 26, 2005, 10:46 AM I think this utility will be very usefull in the "Domination Without War" variant I plan to do soon... ;-)
anarres Apr 26, 2005, 12:05 PM Guys, I have to admit that I use CRPSuite now for flip calcs - it's truely an impressive utility that does flips and much more.
If you've not seen it yet and you like the FlipCalc....
Dianthus Apr 26, 2005, 12:18 PM Thanks for the advert anarres! I think MRick wants to know the probability of an AI city flipping to him though, and CRpSuite doesn't do that (yet).
anarres Apr 26, 2005, 12:27 PM Yeah well, something to add. ;)
Also you need to add flip chances for all civs..... :mischief:
Eetu Pellonpää May 01, 2005, 04:07 AM Now this is very good utility to have! It's much easier to make decicions from concrete data.
:thanx:
subbss May 02, 2005, 11:48 AM No one ever answered my question. It is pretty simple.
Here is my earlier post. (http://forums.civfanatics.com/showpost.php?p=1468420&postcount=84)
daufoi Sep 07, 2005, 11:13 PM Couple of questions:
1) how do you determine yours/AI culture? I can only see the culture leader when hitting F8.
2) City tiles under AI influence? would this be 21 or less?
3) is this calcultor used when the AI owns the city and you're trying to steal it or when you own the city and trying to garrison troops so it won't flip to the AI? If it's the latter, how does #2 apply?
Thanks.
Zenobia42 Dec 09, 2007, 03:52 PM Thanks for the formula! :goodjob:
One of the things the formula taught me do to help prevent the flip of a recent conquest is to hurry culture in my hard-won cities. AIs tend to space out their cities, so if I hurry a library as soon as the resistance is over, and a temple 2 turns later, I expand my borders in 3 turns bringing the number of city tiles under foreign control way down, sometimes to zero. If I can get a road/RR to it that turn, I keep outdated units around to disband in my new city to get that library without waiting for the resistance to end.
|
|