Super Forts

Super Forts now has over 70 downloads! I have a small request for everyone out there who has played through a game of Super Forts. Please post your observations of the AI's behavior when attacking you and your forts. This will help me to improve the AI for future versions.

I am already aware the AI does a poor job defending forts and that should soon be fixed. This request is specifically about the AI's behavior when at war with you. I would like to know things like:
  • Does the AI attack and capture your forts?
  • Have you seen AI weaken your forts' defense with bombard before attacking?
  • If you have an undefended fort does the AI quickly move to capture it?
  • Have you seen the AI pillage any forts?
  • Have you seen the AI do anything weird due to forts?
  • Any other observations of the AI's war/attacking behavior around forts...

Thanks everyone!
 
Super Forts now has over 70 downloads! I have a small request for everyone out there who has played through a game of Super Forts. Please post your observations of the AI's behavior when attacking you and your forts. This will help me to improve the AI for future versions.

I am already aware the AI does a poor job defending forts and that should soon be fixed. This request is specifically about the AI's behavior when at war with you. I would like to know things like:
  • Does the AI attack and capture your forts?
  • Have you seen AI weaken your forts' defense with bombard before attacking?
  • If you have an undefended fort does the AI quickly move to capture it?
  • Have you seen the AI pillage any forts?
  • Have you seen the AI do anything weird due to forts?
  • Any other observations of the AI's war/attacking behavior around forts...

Thanks everyone!

Hi, Red Key. I do not want to be offensive. Your mod is good idea but play it single is a bit :mischief:
If you know somebody who can add your forts function to my library, I will glad post you my observations :)
 
New Version Released

I have released version 1.01! The AI has been modded to better defend forts.

I also added in some text to go along with improvements that use the bUpgradeRequiresFortify tag. Now they will read "Must fortify to become..." instead of "City must work to become..." which was inaccurate.

I have also used phungus' installation script to create an installer for the mod. I have never used installation scripts before, so let me know if there are problems. The script will install the mod to "/Mods/Super Forts" in your BTS directory. If you installed the mod previously to a different directory such as "/Mods/super_forts", then you may want to go delete the old version after installing the new one.

This may be the final version of Super Forts. I currently do not plan on making any more versions unless bugs are found.

Happy New Year! :newyear:
 
You will start another project?

Yep. I should have mentioned that. I am finalizing Super Forts so I can start working on another mod.

I want to make a mod based off the game Age of Wonders, and Super Forts will be merged into it.
 
I merged in parts of Super Forts (skipped the bombardment & upgrade parts as I don't need them). Here are my comments so far:

- the way you comment the code can be a bit inconvenient when merging with other mods with modified code - it's difficult to guess what's what when there's just comment at the top, while lines & brackets below aren't commented; I'd suggest enclosing every block & commenting single lines/brackets
- none of the new improvement features appear in the Civilopedia
- despite the AI tweaks, the AI doesn't seem to care about defending Forts (although I'm talking about a scenario where both forts & units are pre-placed). It seems that eventually it just shifts all defenders to cities. I might add some kind of new, immobile UNITAI type (CITY_SPECIAL doesn't seem to work) just with pre-placed fort defenders in mind.
- EDIT: it doesn't seem to care about capturing them either, even if they are undefended, unless they happen to stand in the unit's path
- other than that, works like a charm and solves my problems, THANK YOU :)
- it's great that the culture range works even with iCulture=0, since I'd rather not have influence accumulated from forts :)
 
Here's a screenshot showing the effects of no-defence & no-capture. Some forts are pre-built, some were built by the AI (the ones with bonus). Yellow dude captured the purple dude's city, there's also a formerly purple fort now owned by barbarians, but they left as well. One new purple fort is defended.



I guess it needs some kind of new routine to specifically target forts, like cities, while not spending too much forces on them...
 

Attachments

  • superforts1.jpg
    superforts1.jpg
    161.5 KB · Views: 341
I merged in parts of Super Forts (skipped the bombardment & upgrade parts as I don't need them). Here are my comments so far:

Thanks for the feedback embryo! It was hard for me to see where things were still lacking on my own. I will definitely try to improve some of the things you brought up. The screenshot was helpful too.

- the way you comment the code can be a bit inconvenient when merging with other mods with modified code - it's difficult to guess what's what when there's just comment at the top, while lines & brackets below aren't commented; I'd suggest enclosing every block & commenting single lines/brackets

Sorry about the poor commenting. This is my first mod, and I haven't done any merging yet, so I am blissfully unaware of what coding style makes things easier for merging. I tried to enclose multi-line changes in the code with //Super Forts begin ... //Super Forts end. If a change was only a single line with perhaps some brackets then I just put a single //Super Forts comment.

Is there a tutorial somewhere to help me improve my commenting? or perhaps a mod that is a good example of proper commenting? I have RevDCM and FFH2 downloaded and could look at their code if one of them is a good example.

- none of the new improvement features appear in the Civilopedia

That was completely neglected now that you mention it. I will fix that in the next version.

- despite the AI tweaks, the AI doesn't seem to care about defending Forts (although I'm talking about a scenario where both forts & units are pre-placed). It seems that eventually it just shifts all defenders to cities. I might add some kind of new, immobile UNITAI type (CITY_SPECIAL doesn't seem to work) just with pre-placed fort defenders in mind.

I probably need to add calls to the function that determines if a unit should defend a fort in more of the AI types. I believe only CITY_DEFENSE and RESERVE currently call it, and that was how it already was in the vanilla code. It would probably also be simple for me to tweak the AI so that if a unit is the only one defending a fort it will not leave its post.

When I was play testing, the AI was poor at defending forts in the early game when they had fewer units, but after they had built up their units in cities they put plenty of defenders in forts. For example, I razed a city next to some iron, and planned on building a fort on the iron. However, one of the other AI players built a fort on the iron before I could, and then promptly put 4 units in the fort to protect it.

- EDIT: it doesn't seem to care about capturing them either, even if they are undefended, unless they happen to stand in the unit's path

That was something I was concerned about, and was something I requested feedback on in an earlier post. It was hard for me to play test the AI's behavior by myself. I will do what I can to fix that in the next version.

- other than that, works like a charm and solves my problems, THANK YOU :)
- it's great that the culture range works even with iCulture=0, since I'd rather not have influence accumulated from forts :)

I tried to make things as flexible as possible because I knew not everyone would want all the new features. I'm glad you like it. :)
 
Sorry about the poor commenting. This is my first mod, and I haven't done any merging yet, so I am blissfully unaware of what coding style makes things easier for merging. I tried to enclose multi-line changes in the code with //Super Forts begin ... //Super Forts end. If a change was only a single line with perhaps some brackets then I just put a single //Super Forts comment.

It's mostly fine, I think there were two instances of new code with just one comment above, and one had new brackets without any comments, with the closing one being in a later part of original code, that was the confusing part.

Is there a tutorial somewhere to help me improve my commenting? or perhaps a mod that is a good example of proper commenting? I have RevDCM and FFH2 downloaded and could look at their code if one of them is a good example.

You can do use the big, clear blocks that RevDCM & its modcomps have, or use the concise begin... end comments, doesn't really matter. I'd just make sure that if it's not within a block of new code, then every line, including single curly brackets, are clearly marked as part of the mod.

BTW I think stuff like ePlayer = getOwnerINLINE() is redundant since it's just replaced with m_eOwner anyway

I probably need to add calls to the function that determines if a unit should defend a fort in more of the AI types. I believe only CITY_DEFENSE and RESERVE currently call it, and that was how it already was in the vanilla code. It would probably also be simple for me to tweak the AI so that if a unit is the only one defending a fort it will not leave its post.

When I was play testing, the AI was poor at defending forts in the early game when they had fewer units, but after they had built up their units in cities they put plenty of defenders in forts. For example, I razed a city next to some iron, and planned on building a fort on the iron. However, one of the other AI players built a fort on the iron before I could, and then promptly put 4 units in the fort to protect it.

I think it makes sense for just these two UNITAIs to be used to defend forts. It's possible that there's just a deficit of defenders in my scenario, although many forts remain empty throughout the game. I've also seen stuff like, AI putting 4 good defensive units in one fort, while leaving other naked.

The biggest problem is no capturing right now, although iCulture=0 eventually produces satisfactory borders since it makes flipping of undefended forts much easier.

As a side-note, I'm also using Influence Driven War, which goes well with this modcomp, but with iCulture=0 it can take away that 1 point of static culture, making "holes" in fort borders. I fixed that by using iCulture=1 but with a maximum of 10 culture / plot. Another way would be to simply make sure that 1 point of static culture is re-added every turn, if it's not there.

I also noticed forts are disappearing sometimes, even though they are placed in locations where nothing else can be built. I'm wondering how is that even possible... Considering that forts are now owned, it'd mean the AI is pillaging its own forts for some reason.
 
Hi. I made a litle test. In war go enemy first try capture city. I managed to add units to the city and enemy as second act was captured my fort.
It´s good succes I think.


I am still interested in this mod and looking for someone to incorporate into my library sdk
thanks, Hrochland
 
Well, what did that unit do next? Did it stay there? The AI surely captures forts if they are on his way. However, there's just nothing in the code that would make it attack actual forts. You can see the AI's current mission by holding CTRL (or ALT, don't remember) in debug mode.
 
Well, what did that unit do next? Did it stay there? The AI surely captures forts if they are on his way. However, there's just nothing in the code that would make it attack actual forts. You can see the AI's current mission by holding CTRL (or ALT, don't remember) in debug mode.

I don´t know what is debug mode. I just had the pleasure of the logical step of AI. I have not tested further . I have a lot of work with models to other. I will test it done today evening.

Still no one for me to compile a library? Help me somebody, please
Thanks, Hrochland
 
I don´t know what is debug mode. I just had the pleasure of the logical step of AI. I have not tested further . I have a lot of work with models to other. I will test it done today evening.

Still no one for me to compile a library? Help me somebody, please
Thanks, Hrochland

See this thread for info on debug mode. You'll probably have to merge and compile the "library" on your own. There are tutorials for how to merge and how to compile the DLL, and don't worry if you're unfamiliar with programming because you won't have to write any code yourself.

I think it makes sense for just these two UNITAIs to be used to defend forts. It's possible that there's just a deficit of defenders in my scenario, although many forts remain empty throughout the game. I've also seen stuff like, AI putting 4 good defensive units in one fort, while leaving other naked.

I think I'll make so CITY_SPECIAL and CITY_COUNTER also guard forts.

BTW, I was going through the code again in the function AI_getPlotDefendersNeeded and discovered a part of the original code was sometimes rounding the defenders needed down to 0. It will do this when you only need one defender and there are no hostile units around. The spoiler below shows how I fixed it.

Spoiler :
Code:
if ((iNumHostiles == 0) && (iNumPlots < 4))
	{
		if (iNeeded > 1)
		{
			iNeeded = 1;
		}
		// Super Forts begin - removed code so when iNeeded is 1 it won't be changed to 0
		//else
		//{
		//	iNeeded = 0;
		//}
		// Super Forts end
	}

	return iNeeded;

I also noticed forts are disappearing sometimes, even though they are placed in locations where nothing else can be built. I'm wondering how is that even possible... Considering that forts are now owned, it'd mean the AI is pillaging its own forts for some reason.

I have never witnessed that myself. Perhaps someone took out the fort with a spy. Also, if a fort's plot becomes within range of one of the AI owner's cities then the AI will sometimes replace the fort with another improvement. I haven't seen the AI take out their own fort except when it was now in range of one of their cities and a different improvement was built to replace it.
 
AI Updated

I have released a new version with some improvements to the AI. The AI should do a little better at defending forts, and a lot better at attacking them now. Feedback from people willing to playtest would be appreciated.

I also tried to clean up some of my SDK code comments.

I believe this update will not break saved games.

edit: I will next update the civilopedia but will probably be short on time for the next little while, so I wanted to get the AI update out quickly.
 
Thanks :goodjob: The getDefendersNeeded tweak did nothing for me, but I'm getting the new update and will test this weekend. About disappearing forts, they're on plots on which nothing else can be built, so that excludes new improvements. I didn't think about Espionage though, that's probably it.
 
Thanks :goodjob: The getDefendersNeeded tweak did nothing for me, but I'm getting the new update and will test this weekend. About disappearing forts, they're on plots on which nothing else can be built, so that excludes new improvements. I didn't think about Espionage though, that's probably it.

Since your disappearing forts were on a plot where nothing else can be built, then espionage is probably the answer. However, as I was playing last night I saw an AI worker build a farm over a fort. The fort was outside of the range of any of the AI player's cities and was on top of an iron (why the AI built a farm on the iron is beyond me :confused:). Thus, when the farm was complete the AI lost ownership of the plot (which was being defended by 4 units).

In the next version I will add in checks to prevent workers from building over forts that are outside city range, and I will also see what I can do to improve unit's defending forts. The Civilopedia will also be updated, so hopefully that will be the final version of Super Forts.
 
Final (Hopefully) Version Released!

I just uploaded v1.03 and I hope it will be the final version of the Super Forts modcomp! ;)

After version 1.00, most of the changes were to the AI. v1.03 has some more adjustments to the AI's defense of forts. A new AI function has been added to hopefully help ensure each fort gets one defender while still giving cities higher priority (because of where it is called). [edit: The function will also cause the AI to put one defender on improvements that require a fortified unit to upgrade.] I will not try to adjust the AI's defense of forts again. If you find it unsatisfactory then you will have to change it yourself. It is not easy to make the AI properly defend forts while still putting the proper emphasis on cities. However, if a bug is found in my new code, then I would of course be willing to fix it.

v1.03 also makes it impossible for workers to build over a fort with another improvement IF the fort's plot is outside the culture range of all of your cities and other forts. This was done to prevent the AI from building over its forts and losing ownership of the plot. You can still build over forts that are inside the culture range of your cities or other forts.

Finally, the Civilopedia has been updated. When you use the new improvement XML tags included with Super Forts this will be seen in Civilopedia improvement entries. If anyone out there is playing in French, German, Italian, or Spanish, then please forgive my Google translations of the text I have added.

As stated I hope this will be the final version of Super Forts, so people won't have to keep waiting for better versions. I do not plan on adding anything else. I will only fix any bugs that are found in the already existing code. The one exception I will make is if the AI is still not properly attacking forts then I may adjust that code because I still have not had time to properly playtest wars with the AI after some of my changes in the previous version.
 
Top Bottom