Resource icon

C3X: EXE Mod including Bug Fixes, Stack Bombard, and Much More Release 24

Does this ever happen with a ship in port? My best guess is the pathfinder plots the city tile as 'navigable' without recognizing there's a city or garrison.

It may also explain how ships are attacking a land tile when that's supposed to be illegal.
 
Hi Everyone, has anybody encountered this issue with v.23? I noticed a weird issue while testing a mod (in progress), and not sure what this might be; I test my mod on C3X v19, but recently changed to v23, and what I see is that when a great leader appears, this cannot create an army; The create army button is there, but when clicked, the leader disappears and no army is created; changing back to v19, and the army gets created; That is a bit strange; Has anyone noticed a similar problem? / Thanks
 
@WildWeazel

I figured out what causes AI naval units to attack cities. It's a bug in the pathfinder, and turns out not be all that subtle like I was worried it might be. The issue occurs when the game has found a path and is attempting to return it. It is returned by being written into the unit object in an array of up to 256 bytes, each byte storing one direction for one move along the path. Because of the way the pathfinder keeps its internal data, the final path has to be reconstructed backwards. You begin at the destination tile, determine the direction the unit would move to get there and add it to the list in the array, then from the neighbor along that direction, you determine the direction to get there and add it to the list, and so on, until you reach the starting tile.

The bug is that the pathfinder gives up doing that once it's added 256 directions to the list. Presumably whoever wrote that figured that's a sensible stopping point since the unit can only store a list of up to 256 moves. However, that doesn't work because the path is generated backwards and so the unit gets left with the last 256 moves starting from somewhere in the middle of the path. That causes it to wander off in a nonsensical direction. The game does some double checking of the validity of each move, for example naval units can't move onto land even if the pathfinder directs them there, but that double check doesn't stop naval units from moving onto tiles with cities.

Fortunately, this bug is easy to fix. All I have to do is allow the pathfinder to reconstruct more moves along the path. There is no issue with the array of moves being limited to 256 entries since the method to add moves to that array correctly handles that. When the array is full, it starts dropping the oldest moves to make space for new ones. So when the whole path is more than 256 moves, the unit will be left with the first 256 moves from its starting location instead of, incorrectly, the last 256 moves leading up to the destination.

Hi Everyone, has anybody encountered this issue with v.23? I noticed a weird issue while testing a mod (in progress), and not sure what this might be; I test my mod on C3X v19, but recently changed to v23, and what I see is that when a great leader appears, this cannot create an army; The create army button is there, but when clicked, the leader disappears and no army is created; changing back to v19, and the army gets created; That is a bit strange; Has anyone noticed a similar problem? / Thanks
That is strange, I can't think of anything I've changed recently that would block unit spawning, especially of armies in particular. I haven't gotten any other reports about this. Can you post a save?
 
The pathfinder's algorithm is recursive in spirit, but it's not implemented with recursive calls. At each tile, it finds and records the cost of the shortest path leading there and the incoming direction along that shortest path. It's recursive in that, if you know the shortest path to a tile, you can update the shortest paths to its neighbors by imagining taking that shortest path plus one step to each of them. Then you do the same thing for the neighbors of neighbors and so on, branching outward until you reach the destination tile. At that point, you have to follow the incoming directions backwards to the starting tile to construct the whole path.

Go-to orders of more than 256 moves work for the human player. The game simply stores the destination tile and recomputes the path along the way. If I'm reading the code right, it actually recomputes it after every single move.
 
Flintlock updated C3X with a new update entry:

Release 24

New in this version:
- Option to share wonders among human players in hotseat mode, setting named share_wonders_in_hotseat
- AI routine for "caravan units", which are modded units whose purpose is to be disbanded for shields
--- Controlled by config option enable_caravan_unit_ai
- Experimental option to move the game's trade net object to a different location in memory named move_trade_net_object
- Delete any AI units that somehow end up off the map to fix a rare crash, setting named...

Read the rest of this update entry...



Edit:

There are a lot of bug fixes in this version and I still have more to fix but I'm posting a new version now to keep the releases rolling. Here's the changelog with extra info about each addition:
  • Option to share wonders among human players in hotseat mode, setting named share_wonders_in_hotseat -- If any human player in a hotseat game builds a wonder, all other human players will share its effects, if it makes sense to share them. For example, if any builds the Temple of Artemis, all cities on that continent owned by any human player will get a free temple, if any build Leonardo's, all get half price upgrades, and so on. The bonus commerce effect from Colossus is not shared since it only applies to one city. Small wonders are also shared, both their effects and requirements. For example, all human players are able to build Battlefield Medicine once they have 5 hospitals combined, and once any of them builds it, all their units may heal in enemy territory.
  • AI routine for "caravan units", which are modded units whose purpose is to be disbanded for shields -- This is like the custom unit AI for pop units, only for modded units that add shields instead of pop points. To be considered a caravan unit (the name comes from Civ 2), a unit must use the terraform AI strategy, have no worker actions enabled, have the ability to disband, and have zero attack, defense, & bombard strengths. The AI will move such units to an appropriate city and disband them for shields. The AI logic is relatively simple, it tries to get the full shield value from disbanding, prioritizes less corrupt cities when disbanding into infrastructure, and is smart enough not to try to disband into wonders.
  • Experimental option to move the game's trade net object to a different location in memory named move_trade_net_object -- This is the first step toward lifting the city limit. Doing so requires enlarging the trade net object but that's not easy since the object implementing the preferences screen is located immediately after it in the program's memory. So expanding the trade net requires moving it, and moving it requires patching all locations to its old location to refer instead to its new one. That's what this option does, it creates a new trade net object and redirects all references to it. If it works properly, nothing will change, the game will operate exactly as it normally does since the location of the trade net in memory shouldn't affect anything. If this option doesn't work somehow, it's likely to crash the game. I've left it off since it does nothing other than possibly crash, but you can turn it on if you want to help me out a bit. If you do so and the game crashes, make sure to report it to me in this thread.
  • Delete any AI units that somehow end up off the map to fix a rare crash, setting named delete_off_map_ai_units -- Alekseyev_ reported to me a save that crashes between turns. I found that the crash was caused by an AI unit that somehow ended up off the edge of the map, on a tile with y coord -1. I don't know how it ended up there, but the crash can be fixed by deleting any AI units that are off the map at the start of their turns.
  • Fix pathfinder bug (see config for details), setting named patch_premature_truncation_of_found_paths -- This is the bug I was just posting about.
  • Fix crash due to division by zero when cities have zero production, setting named patch_zero_production_crash -- Fixes bug reported here: https://forums.civfanatics.com/thre...d-and-much-more.666881/page-144#post-16842202
  • Fix icons for different kinds of specialist yields obscuring each other, setting named fix_overlapping_specialist_yield_icons -- Small fix for a graphical issue, see: https://forums.civfanatics.com/thre...d-and-much-more.666881/page-146#post-16846695
  • Correct typo in name of share_visibility_in_hotseat setting. The old, incorrect name still works as an alias.

And the short list for R25 with two bugs still to fix is:
  • Lift the city limit
  • Fix units being able to upgrade past the point in their upgrade chain where a unit type doesn't have the upgrade ability. Example, if you have cavalry set to upgrade to tanks but without the upgrade ability, knights should be able to upgrade to cavalry but not tanks.
  • Fix the AI being able to sacrifice workers without the sacrifice ability
 
How hard would it be to adapt wonder sharing to locked alliances, or even regular defensive pacts? I'm salivating at the scenario potential. :yumyum:

  • Delete any AI units that somehow end up off the map to fix a rare crash, setting named delete_off_map_ai_units -- Alekseyev_ reported to me a save that crashes between turns. I found that the crash was caused by an AI unit that somehow ended up off the edge of the map, on a tile with y coord -1. I don't know how it ended up there, but the crash can be fixed by deleting any AI units that are off the map at the start of their turns.
Could this be a miscalculation when expelling a trespasser?
 
Holy cow! Caravan units to be disbanded for shields! That's one of things I'd like to see happening but didn't think it'd be feasible enough to ask for. Does the AI know how to move them into corrupt cities to get fortifications or cultural expansions?
 
Last edited:
Back
Top Bottom