[BTS] Basic Limited Religions (mod comp)

I dunno why only in my mod Earth 35 civs this features works for half.

I dont understand this statement? Half of what?

I can FOUND ONLY ONE RELIGION, BUT if I discover a religious technology, no other civs can found religions with that technology.


I mean i discover Meditation + Polyteism and get 1 religion (by meditation)
all other civs that discover Polyteism DON'T FOUND nothing cause I still discovered Polyteism!

Any Ideas?
:confused::confused::confused::confused:


This sounds exactly how the mod works in default mode. Each religion is tied to a technology, and the first to that tech founds the religion. You can only found one religion.

By selecting choose religions upon game start you can enable choosing the one religion you found instead of the fixed tech/religion relationship.
 
No, he wonders why other people cannot found hinduism by discovering polyteism because he did NOT found hinduism. This has nothing do to with choosing the religion.

The second who is discovering polyteism should found hinduism (without choosing religions).
 
Dude are you sure that this mod WORKS with BTS 3.19 with LIMITED RELIGION FEATURE? :confused:

I tried just now a BTS 3.19 VANILLA game, just using this mod and CHOOSE RELIGION FEATURE...

After I founded the 1st religion, No other Civs founds religions in over 50 turns...

Check yourself pls and let me know...

edit _Cv4Config writing:
; Set to 1 for no python exception popups
HidePythonExceptions = 1

I had the following errors...

File "CvEventInferface", line 23, in OnEvent
File "CvEventManager", line 192, in HandelEvent
File "CvEventManager", line 709, in OnTechAcquired
 
No, he wonders why other people cannot found hinduism by discovering polyteism because he did NOT found hinduism. This has nothing do to with choosing the religion.

The second who is discovering polyteism should found hinduism (without choosing religions).

Hmm. so he founded a previous religion, then got a second religious tech before anyone else, and because of that no one else ever founds the second religion?

I'll check into this scenario. I have not run into this issue, and I use this mod in my expanded mod. Im in the middle of a game in the year 2053 and all religions were founded.
 
Hmm. so he founded a previous religion, then got a second religious tech before anyone else, and because of that no one else ever founds the second religion?

Yes! By the way use the python exception popups for your mod and you will see theese errors.

edit _Cv4Config writing:
; Set to 1 for no python exception popups
HidePythonExceptions = 1

and then launch ONLY your Basic Limited Religion mod:

File "CvEventInferface", line 23, in OnEvent
File "CvEventManager", line 192, in HandelEvent
File "CvEventManager", line 709, in OnTechAcquired

Looks like some code is missing!!!
 
Yes! By the way use the python exception popups for your mod and you will see theese errors.

edit _Cv4Config writing:
; Set to 1 for no python exception popups
HidePythonExceptions = 1

and then launch ONLY your Basic Limited Religion mod:



Looks like some code is missing!!!

i turned on logging in my ini file and didnt see any errors. strange. ill keep looking.
 
I was looking at the code in this mod and found a couple problems and had some questions. First off, I have not actually run the mod--only looked at the code.

Choose Religion

1. It doesn't check if the technology founds a religion, so every tech acquired should found a religion. You need to check the CvReligionInfos before testing for holy cities and such.

Code:
for iRelCheck in gc.getNumReligionInfos():
	if gc.getReligionInfo(iRelCheck).getTechPrereq() == iTechType:
		break
else:
	iRelCheck = -1
if iRelCheck != -1:
	...

2. The option looks like it will break the mod. In this block of code:

Code:
if gc.getPlayer(iPlayer).isHuman( ):
	self.doPickReligionPopup(iPlayer, iRelCheck)
else:
	iNewReligion = self.AI_chooseReligion(iPlayer)
	if iNewReligion > -1:
		gc.getPlayer(iPlayer).foundReligion(iNewReligion, iRelCheck, True)

iRelCheck that is used in both the if and else clauses has not been initialized. I believe that it should be set to the religion that the technology normally founds, so the above code in (1) will fix this by setting iRelCheck appropriately.

3. It looks like there is no check to see if the player is first to acquire the tech before founding a religion. Once you fix (1) so players don't found religions by acquiring The Wheel, you still need to address this problem so you don't get seven players founding one religion each as they acquire Polytheism.

CvGameUtils

Why is the code in doHolyCityTech() needed given that onTechAcquired() handles founding the religion. Perhaps it should return False without checking for existing holy cities because the player will always have a holy city by this point (either from a previous tech, conquest, or this tech).

Final Code

I rewrote the code in onTechAcquired(). If you want, replace the religion code in that function with this untested code and see what happens.

Code:
# find which religion this tech founds
for iRelCheck in range(gc.getNumReligionInfos()):
	if gc.getReligionInfo(iRelCheck).getTechPrereq() == iTechType:
		# found it
		break
else:
	# it doesn't found a religion
	iRelCheck = -1
if iRelCheck != -1:
	game = CyGame()
	# make sure this tech hasn't founded a religion already
	if not game.isReligionSlotTaken(iRelCheck):
		# check if player has any holy cities
		for iReligion in range(gc.getNumReligionInfos()):
			pCity = game.getHolyCity(iReligion)
			if pCity is not None and pCity.getOwner() == iPlayer:
				bHasHolyCity = True
				break
		else:
			bHasHolyCity = False
		if not bHasHolyCity:
			# found a religion
			if game.isOption(GameOptionTypes.GAMEOPTION_PICK_RELIGION):
				if gc.getPlayer(iPlayer).isHuman():
					self.doPickReligionPopup(iPlayer, iRelCheck)
				else:
					iNewReligion = self.AI_chooseReligion(iPlayer)
					if iNewReligion != -1:
						gc.getPlayer(iPlayer).foundReligion(iNewReligion, iRelCheck, True)
			else:
				if not game.isReligionFounded(iRelCheck):
					gc.getPlayer(iPlayer).foundReligion(iRelCheck, iRelCheck, True)

Eventually it would be nice to modify the SDK to teach the AI not to pursue religious techs once it already has one religion.
 
I confirm:

The uploaded 1.2 mod DOESN'T WORK!

And i can't test your code emperor cause... I'm noob in python :D and don't know where EXACTLY I need to START TO COPY it in CvEventmanager - def onTechAcquired(self, argsList): :) :) :)

I have a modified version of EmporerFools code, Modifieda4's code and my code. Initial test was successful! It appears to be the most efficient limited religions to date, but to make sure, I need to run a few more tests. If it all works, I will post it tonight.

Sincerely,

Orion Veteran :cool:
 
I confirm:

The uploaded 1.2 mod DOESN'T WORK!

And i can't test your code emperor cause... I'm noob in python :D and don't know where EXACTLY I need to START TO COPY it in CvEventmanager - def onTechAcquired(self, argsList): :) :) :)

please be more descriptive. to be honest, i get no errors. I have logging on via the mod .ini file. the logs are clear. I'm looking in my docs\my games\bts\logs\PythonErr2.log

when does the error occur? what file is capturing the error log? what are your game settings?

here's a sample game i just played with choose religions on:




 
Why is the code in doHolyCityTech() needed given that onTechAcquired() handles founding the religion. Perhaps it should return False without checking for existing holy cities because the player will always have a holy city by this point (either from a previous tech, conquest, or this tech).

EmperorFool I appreciate your examining of the code.:goodjob: I can't directly comment on the most of what you pointed out right now...but you touched on a section ive played with (quoted above).

I experimented awhile ago how religions are founded in the above quote. returning false preempts follow on code. Limited religions can never work with that section returning false...the default code is to return false.

this post from the original inquisition thread starts the investigation:
http://forums.civfanatics.com/showpost.php?p=7290500&postcount=279
My learnings summarized:
Spoiler :

for future reference: how limited religions 'works' in the python files (behavior noted after extensive testing):


  • def doHolyCity(self): AND def doHolyCityTech(self,argsList): IN CvGameUtils.py must return True in order to block religion from founding. Default is return False, handled in the gamecore DLL
  • def doHolyCityTech(self,argsList): gets called first, and only when a religion tech is discovered for the first time BY ANY PLAYER<----IMPORTANT! Plus its the only one that gets the argsList passed to it, so its the only one that can hold any real code.
  • def doHolyCity(self): gets called second, and is called when any religious tech is discovered by any player. The modded code sets this to return True always
  • !!! Absolutely ANY errors in the above sub routines will cause the routine to return False and thus Default behavior. NO ERRORS will be in the python err log!!!

Changing only these two sections is a working limited religions variant.

BUT, unless a player is the first to discover a religion tech, that religion WILL NOT be founded. Hence the need to alter def onTechAcquired(self, argsList): IN CvEventManager.py


def onTechAcquired(self, argsList): takes care of the above condition by:
  • checking if a religious tech was researched
  • checking if a player has any holy cities
  • checking if corresponding said religion has been founded <--new code
  • founds religion

so I hope this helps someone in the future. In my test scenarios each AI founded its own religion which creates many factions which is the purpose of limited religions. I even saw an AI switch to a competing religion even though it had founded one.

I probably will package this code into my own standalone limited religion mod.
 
the default code is to return false.

Yeah, I meant to say return True without checking for any holy cities: Block all default religion founding and handle it all in onTechAcquired().

hmm. i just did some reading on the 319 update. It seems it breaks alot of mods? I'm playing 317 still. is this the issue?

No, 3.19 breaks every SDK-based mod (one with a custom DLL) because much of the core C++ code changed in a totally incompatible way. However, the Python API changes are minimal and backwards compatible as far as running goes but will produce erroneous results when No Espionage is on. The only difference is that the city cultural levels are higher with NE on.

As for why it works for you and shouldn't for the code I see (again, I haven't tested it yet), my guess is that you have local differences compared to what's posted. Those two spots where iRelCheck are passed to other functions are the only locations of that variable in that module. The variable is never set, and it is an error to access it without setting it first.
 
hmm. i just did some reading on the 319 update. It seems it breaks alot of mods? I'm playing 317 still. is this the issue?

I believe it might be. I finished my tests and I'm happy to report that all bugs have been worked out. :) This mod combines Better AI (for testing) and Limited Religions (LR). This BTS 3.19 version includes python code from Modifieda4, EmporerFool and a couple of functions from Inquisitions to produce what I think should be the new standard for LR. I am definitely going to use it, as it is compact, modular and very efficient.

Enjoy!

Orion Veteran :cool:
 

Attachments

  • LimitedReligions250A.zip
    1.5 MB · Views: 86
While I was looking at the original code I had one other thought I didn't write about yet. As it stands only the first person to acquire a founding tech can found a religion with that tech. If they already have a holy city, that religion slot will go unfilled. This means there could be fewer religions in the game overall--especially if the AI isn't taught not to pursue further founding techs.

It wouldn't be too much work to add an option to allow the first AI without a holy city to acquire the tech to found a religion. Is this desired?

For example, Isabella is the first to research Polytheism--founding Bhuddism--and then Monotheism. She doesn't found a religion with that as per normal rules. Next to acquire Monotheism is Saladin. Under this option, he would found a religion. It would mean all seven religions get founded eventually, just by different AIs.

Oh, actually I think this is the way it works already now that I think of it because there's no way to fill the slot of a religion without actually founding one. I could add a simple change to CyGame that exposes the setReligionSlotFilled() (or whatever it's called) function to Python.
 
While I was looking at the original code I had one other thought I didn't write about yet. As it stands only the first person to acquire a founding tech can found a religion with that tech. If they already have a holy city, that religion slot will go unfilled. This means there could be fewer religions in the game overall--especially if the AI isn't taught not to pursue further founding techs.

It wouldn't be too much work to add an option to allow the first AI without a holy city to acquire the tech to found a religion. Is this desired?

For example, Isabella is the first to research Polytheism--founding Bhuddism--and then Monotheism. She doesn't found a religion with that as per normal rules. Next to acquire Monotheism is Saladin. Under this option, he would found a religion. It would mean all seven religions get founded eventually, just by different AIs.

Oh, actually I think this is the way it works already now that I think of it because there's no way to fill the slot of a religion without actually founding one. I could add a simple change to CyGame that exposes the setReligionSlotFilled() (or whatever it's called) function to Python.

We definitely want to allow the first Civ or AI without a holy city to acquire the tech to found a religion. I believe I fixed the unfilled slot issue in my new version I just posted. On second thought, I just played through a huge game and one religion was not founded. Bummer. I'll take another look at the Python.

Orion Veteran :cool:
 
For whats its worth I'm 99% sure limited religion mod as its written (updated) works on my setup.


I played far into a game with this code added to the function onTechAcquired in CvEventManager.py

Code:
CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'%s was finished by Player %d' %(PyInfo.TechnologyInfo(iTechType).getDescription(), iPlayer),'AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/TerrainFeatures/Forest.dds',ColorTypes(8),0,0,False,False)

Basically it pops a notification on the screen when ever ANY player completes a tech. I watched what happened when a religious tech was achieved by the AIs. It worked as planned. I deliberately raced to each religious tech, AIs still founded religions when they got to a religious tech I already had, but since I founded one earlier, they were able to found the requisite religion.

I get no errors, and the game play as intended as far as I can tell. :confused:

I have no idea why other people are having issues.

My setup:
BTS 317
Wolfs game core
 
Yeah, I meant to say return True without checking for any holy cities: Block all default religion founding and handle it all in onTechAcquired().



No, 3.19 breaks every SDK-based mod (one with a custom DLL) because much of the core C++ code changed in a totally incompatible way. However, the Python API changes are minimal and backwards compatible as far as running goes but will produce erroneous results when No Espionage is on. The only difference is that the city cultural levels are higher with NE on.

As for why it works for you and shouldn't for the code I see (again, I haven't tested it yet), my guess is that you have local differences compared to what's posted. Those two spots where iRelCheck are passed to other functions are the only locations of that variable in that module. The variable is never set, and it is an error to access it without setting it first.

I'll check out the iRelCheck issue. Thanks for the input...would you mind trying the notification code I just posted to see how you see things working?
 
Top Bottom