Discussion in 'Rhye's and Fall - Dawn of Civilization' started by Leoreth, Dec 14, 2013.

1. ### TigranesArmenian

Joined:
Sep 11, 2008
Messages:
9,727
Code:
# attitude stability

iRelationStability += calculateSumScore(lAttitudes) / 2
iRelationStability += calculateSumScore(lAttitudes, 2) / 2
iRelationStability += calculateSumScore(lAttitudes, 3)

Can somebody please explain me this code?

Joined:
Oct 27, 2014
Messages:
2,767
IIRC calculateSumScore adds up all of the values in lAttitudes that meet the given absolute value threshold, default being 1.

Tigranes likes this.
3. ### TigranesArmenian

Joined:
Sep 11, 2008
Messages:
9,727
Sorry, not sure I understood. First line -- adding all the +/- 1 attitude? Second line adding +/- 2 attitudes, and then for +/- 3? Meaning if someone is -5 against me -- he will not be counted in attitude score determination? My main problem is the second argument of Sumscore function... If it represents a threshold -- in which way mathematically does it work?

Joined:
Oct 27, 2014
Messages:
2,767
The first line sums all values >= 1, the second line >= 2, and the third 3

So if you have a -5 it's absolute value is 5, which is >= 1, 2 and 3, meaning it's added on all 3 lines. I'm not sure how Python handles uneven integer division so let's assume for the sake of this example 5 / 2 = 2, we'd get -2 + -2 + -5 = -9.

5. ### LeorethFriend Next DoorModerator

Joined:
Aug 23, 2009
Messages:
35,107
Gender:
Male
Location:
Faraway
I don't have the code in front of me but iirc it counts the attitude modifiers that exceed the given threshold in the negatives or positives, instead of adding them.

6. ### mrrandomplayerHopeless Situation Warrior

Joined:
Aug 1, 2012
Messages:
3,321
Gender:
Male
Location:
The land of prequel memes
Where is the wonder limit stored? I want to try some fun one-city challenges and I'd like to disable the wonder limit for OCCs.

7. ### merijn_v1Black Belt

Joined:
Dec 29, 2008
Messages:
5,897
Location:
The city of the original vlaai
It is in CvCity.cpp, at CvCity::isWorldWondersMaxed().

However, if you enable the OCC option it should already remove the limit for human players. You can enable that option in the WB. The option only effects the human player, so it doesn't matter that it is enabled during autoplay. It is not worth making changes so it is enabled from loading the scenario, as that has no effect.

EDIT:
Ignore the wonder limit indicator (next to the city name in the cityscreen) if you do this. It still displays the original limit, but you can still build new wonders.

8. ### ManussSleeping man

Joined:
Dec 30, 2013
Messages:
1,456
Gender:
Male
Location:
Nation of public debt
Is there any way to trigger a civ rebirth through the python console? For example, the Egyptian one in the middle ages. Thanks in advance

9. ### star15389Prince

Joined:
Sep 7, 2008
Messages:
487
What where the changes that that made Orthodox spread correctly before the Reformation and that made Catholicism found more often and where they simple enough for me to slap into 1.14? I looked at Religions.py but I don't understand at all

Crimean Lord likes this.
10. ### LeorethFriend Next DoorModerator

Joined:
Aug 23, 2009
Messages:
35,107
Gender:
Male
Location:
Faraway
Religion spread was significantly reimplemented in the DLL, I think that was after 1.14.

Crimean Lord likes this.
11. ### Imp. KnoedelSimperator Knoedel

Joined:
Nov 11, 2011
Messages:
8,802
Location:
The cooler Germany
As someone who learned coding with C++ I have always had a deep suspicion for Python, so I'd like to ask for confirmation, is this code:

Code:
if iPlayer == iPolynesia or iVikings or iIndonesia or iNetherlands:
really 100% certainly just a shorter more elegant but otherwise functionally identical version of this:

Code:
if iPlayer == iPolynesia or if iPlayer == iVikings or if iPlayer == iIndonesia or if iPlayer == iNetherlands:
?

Joined:
Oct 27, 2014
Messages:
2,767
I think what you're looking for is
Code:
if iPlayer in [iNetherlands, iIndonesia, iVikings, iPolynesia]:

need my speed and Imp. Knoedel like this.
13. ### LeorethFriend Next DoorModerator

Joined:
Aug 23, 2009
Messages:
35,107
Gender:
Male
Location:
Faraway
The second is not valid Python at all, but I suppose you mean:
Code:
if iPlayer == iPolynesia or iPlayer == iVikings ...
If so the shorthand equivalent is:
Code:
if iPlayer in [iPolynesia, iVikings, ...]:
Your first example will always evaluate to true. Consider that iVikings etc. are integer values. In Python, an integer always evaluates to true unless it is zero. So the "or iVikings" parts already make the statement true.

Imp. Knoedel and 1SDAN like this.
14. ### Imp. KnoedelSimperator Knoedel

Joined:
Nov 11, 2011
Messages:
8,802
Location:
The cooler Germany
Code:
data.iSeed % 4
What does that mean exactly? What does that sinister 4 plan to do with the percentage sign to that pure unsuspecting random seed?

15. ### merijn_v1Black Belt

Joined:
Dec 29, 2008
Messages:
5,897
Location:
The city of the original vlaai
The % sign is the modulo operator in python.

Last edited: Nov 14, 2019
1SDAN and Imp. Knoedel like this.
16. ### LeorethFriend Next DoorModerator

Joined:
Aug 23, 2009
Messages:
35,107
Gender:
Male
Location:
Faraway
In Python (and many other languages), % is the modulo operator. In other words, x % y computes the remainder of dividing x / y as integers.

This is useful when you want to quickly have a random set of y different cases. For example, when you compute x % 4, the results are in the range [0, 1, 2, 3]. So if you want something to happen in 25% of all games, seed % 4 == 0 is one way to do it. Likewise, seed % 4 == 1 gives you another case with 25% probability that never occurs at the same time as the previous thing.

Why is all of this derived from the same seed instead of rolling a random number each time? Multiple reasons: sometimes you want multiple mutually exclusive outcomes, sometimes you need consistency for those cases at multiple points in time (so you don't have to store another randomly generated number), and random number generation is more computationally expensive.

need my speed, 1SDAN and Imp. Knoedel like this.

Joined:
Oct 27, 2014
Messages:
2,767
How would I go about making the corporations screen be able to scroll?

18. ### merijn_v1Black Belt

Joined:
Dec 29, 2008
Messages:
5,897
Location:
The city of the original vlaai
You could take a look at the religion advisor. The religion list is horizontally scrollable. I assume you want to make that part of the advisor scrollable.

1SDAN likes this.

Joined:
Oct 27, 2014
Messages:
2,767
Related question, I've been trying to get the scoreboard on the main screen interface scrollable but have been having trouble. Do you know of a good example I could base my code off of?

20. ### Imp. KnoedelSimperator Knoedel

Joined:
Nov 11, 2011
Messages:
8,802
Location:
The cooler Germany
Earth 2010 has one IIRC.

1SDAN likes this.