FlipCalc

Flip Calc - Calculates the probability of culture flips 1.5

I will try both as well.
 
Do a check for 0 culture, too. That can cause a runtime overflow. (devide by 0)
 
Also leaving any field blank will yield a runtime error. That should be easy to check and rectify.
 
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
 
I'm still trying to get the algorithm down pat. :)
 
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?
 
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.
 
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.
 
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.
 
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!
 
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... :)
 
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:
 
I'd like that for mine to. Though, I'm sure Anarres' will be better than mine.
 
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.

FlipCalc1.1.jpg
 

Attachments

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?
 
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:

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.
 
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.
 
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:
 
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.

FC.icons.big.jpg


And here they are real size:

FC.icons.jpg
 
Back
Top Bottom