1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Caveman 2 Cosmos (ideas/discussions thread)

Discussion in 'Civ4 - Caveman 2 Cosmos' started by strategyonly, Sep 3, 2010.

  1. Dancing Hoskuld

    Dancing Hoskuld Warlord

    Joined:
    Jul 5, 2004
    Messages:
    23,290
    Gender:
    Male
    Location:
    Canberra, Australia
    The schema used for validating by C2CXmlValidator an XML file is the one defined at the top of the file. This is why it can be used by any Civ IV mod no matter how different to C2C they are.
     
  2. Toffer90

    Toffer90 C2C Modder

    Joined:
    Oct 16, 2011
    Messages:
    6,089
    Location:
    Norway
    It does, but after I got TB to add the unit that settles the city as an argument to the python function call event that happens every time a city is built, I switched out the xml implementation with a python implementation that looks like this:
    for iPromo, iBuilding in gCultureList:
    if -1 in (iPromo, iBuilding): continue
    if CyUnit.isHasPromotion(iPromo):
    CyCity.setNumRealBuilding(iBuilding, 1)​

    In that modmod I have changed how cultures spread a lot, so if you for example is playing an African civ and conquer an European city where you then train a settler, the new city that settler found will gain the European culture instead of the African culture.
    Several cultures can accompany a settler from the city it is trained in, but only cultures that exist locally in that city. Spreading new local cultures to a city requires the new culture to be adopted by your civ nationally, then you will be able to construct the local culture in a city that doesn't have it, each local culture built in your nation increase the hammer cost of building another local culture in a city, and building one European local culture increase the cost of the next European local culture less than it increases the cost for a different culture group like African.
    When you get enough foreign local cultures a specific autobuild will appear that signifies that that new culture has been adopted, the amount needed scales by the map size.
    It's all a bit complex though, there's a local culture building that can be built if the culture is active in your civ, a native culture building, an adopted culture building, and an active culture building, as well as a special version of the native culture building that follows the palace around based on what civ you started your game with. One of each of those buildings exist per native culture type in the game. ^^

    @Anq: I'm still not convinced that it's a good idea to use the DOM format for any tags that use the expression system...
    Is it possible to mix the current format and the DOM format so that some tags use DOM while others, like those with the expression system, keep the current format?
    Some of them can be quite complex like this one:
    Spoiler example from C2C :
    Code:
                    <PropertyPropagator>
                        <PropertyPropagatorType>PROPERTYPROPAGATOR_DIFFUSE</PropertyPropagatorType>
                        <PropertyType>PROPERTY_WATER_POLLUTION</PropertyType>
                        <GameObjectType>GAMEOBJECT_PLOT</GameObjectType>
                        <TargetObjectType>GAMEOBJECT_PLOT</TargetObjectType>
                        <TargetRelationType>RELATION_NEAR</TargetRelationType>
                        <iTargetDistance>1</iTargetDistance>
                        <iPercent>4</iPercent>
                        <TargetCondition>
                            <Or>
                                <Is>TAG_WATER</Is>
                                <Is>TAG_FRESH_WATER</Is>
                                <Is>TAG_CITY</Is>
                            </Or>
                        </TargetCondition>
                        <Active>
                            <Not>
                                <Or>
                                    <Has>
                                        <GOMType>GOM_TERRAIN</GOMType>
                                        <ID>TERRAIN_OCEAN</ID>
                                    </Has>
                                    <Has>
                                        <GOMType>GOM_TERRAIN</GOMType>
                                        <ID>TERRAIN_OCEAN_TROPICAL</ID>
                                    </Has>
                                    <Has>
                                        <GOMType>GOM_TERRAIN</GOMType>
                                        <ID>TERRAIN_OCEAN_POLAR</ID>
                                    </Has>
                                    <Has>
                                        <GOMType>GOM_TERRAIN</GOMType>
                                        <ID>TERRAIN_TRENCH</ID>
                                    </Has>
                                    <Has>
                                        <GOMType>GOM_TERRAIN</GOMType>
                                        <ID>TERRAIN_TRENCH_POLAR</ID>
                                    </Has>
                                    <Has>
                                        <GOMType>GOM_TERRAIN</GOMType>
                                        <ID>TERRAIN_TRENCH_TROPICAL</ID>
                                    </Has>
                                </Or>
                            </Not>
                        </Active>
                    </PropertyPropagator>
    Condensing that stuff too much will be horrific to work with, both to read and to write.
     
    Last edited: May 26, 2019
    Anq likes this.
  3. Anq

    Anq Chieftain

    Joined:
    Apr 14, 2019
    Messages:
    351
    Gender:
    Male
    Location:
    Anser (geese) HQ
    @Dancing Hoskuld, If it's a good validator, it will compare against everything from the schema that's standard to the specification on the schema's header,
    Code:
    <Schema xmlns="urn:schemas-microsoft-com:xml-data" xmlns:dt="urn:schemas-microsoft-com:datatypes">
    So that it will automatically validate the tag attributes if we supply with correct schema information (see previous post).
    I guess then, our mod components would not be easily graft-able to other mod projects, and so do the mod components outside C2C that we want to integrate. This is a serious hit. Unless the new system gets broadly adopted across the Civ4 community ...

    I suggest to break the negator onto individual statements, that Not(Any) becomes All(Not), see my previous example. But then, it's better at this stage to not get the expression system involved.
     
    Last edited: May 25, 2019
  4. Toffer90

    Toffer90 C2C Modder

    Joined:
    Oct 16, 2011
    Messages:
    6,089
    Location:
    Norway
    Found this:

    DOM

    • Tree model parser (Object based) (Tree of nodes).
    • DOM loads the file into the memory and then parse- the file.
    • Has memory constraints since it loads the whole XML file before parsing.
    • DOM is read and write (can insert or delete nodes).
    • If the XML content is small, then prefer DOM parser.
    • Backward and forward search is possible for searching the tags and evaluation of the information inside the tags. So this gives the ease of navigation.
    • Slower at run time.
    SAX
    • Event based parser (Sequence of events).
    • SAX parses the file as it reads it, i.e. parses node by node.
    • No memory constraints as it does not store the XML content in the memory.
    • SAX is read only i.e. can’t insert or delete the node.
    • Use SAX parser when memory content is large.
    • SAX reads the XML file from top to bottom and backward navigation is not possible.
    • Faster at run time.
    I bolded out that which I consider most significant for our case and have to say that we should keep the SAX format.
    The memory part probably ain't an issue as this only happens during game launch and then is cleared from ram after the xml parsing is complete.
    However, it doesn't sound like the best implementation imo, considering the sizes of some of our xmls.
    The speed issue is what I care about in this case, which may be significant considering the amount of xml we load into this game.
     
    Last edited: May 25, 2019
  5. Anq

    Anq Chieftain

    Joined:
    Apr 14, 2019
    Messages:
    351
    Gender:
    Male
    Location:
    Anser (geese) HQ
    They are different approaches to parse the XML tree. Unfortunately, the XML Utility tells xerces to use the DOM model (xerces has the option to use SAX, though). It's well over my limit, to try to convert the utility to use SAX. The aspects are a lot different and I'll need to read the SAX specs thoroughly for this project for there is little code sample I can mimic. Although SAX consumes the documents in small chunks, I'm afraid it's the total amount that eventually matters.
    This disables us to traverse from children nodes back to their parents, and we'll have to store the parent nodes on the stack, which is over my technical limit and we'll eventually reach an implementation that's already done in DOM parser (and much better done).
     
    Last edited: May 25, 2019
  6. Toffer90

    Toffer90 C2C Modder

    Joined:
    Oct 16, 2011
    Messages:
    6,089
    Location:
    Norway
    I see, I thought we were using SAX already.... Forget what I said then, I'm out of my depth on this matter anyway. ^^
     
  7. Dancing Hoskuld

    Dancing Hoskuld Warlord

    Joined:
    Jul 5, 2004
    Messages:
    23,290
    Gender:
    Male
    Location:
    Canberra, Australia
    Does this mean that the problem with the AI not having the information about the unit that creates a city has been fixed?
     
  8. Toffer90

    Toffer90 C2C Modder

    Joined:
    Oct 16, 2011
    Messages:
    6,089
    Location:
    Norway
    No, but I don't see why the AI needs to be aware of an automatic system that not even the human player have a shred of control over.
    The human player can however plan out better how to spread specific cultures than the AI can by training the settler in the appropriate city, while the AI will not consider what cultures the city has before deciding where to train a settler.
    But the same is true for so much else in this game, e.g. the AI doesn't build only military wonders in one city to make a super unit producing city. It's rather quite random what wonders an AI put in a specific city and no planning on which wonders may have strong synergy effects together if in the same city.
     
    Last edited: May 26, 2019
  9. Dancing Hoskuld

    Dancing Hoskuld Warlord

    Joined:
    Jul 5, 2004
    Messages:
    23,290
    Gender:
    Male
    Location:
    Canberra, Australia
    We had to remove a mod based on the unit that built a city because it did not work for the AI. The unit building the city was not available to Python if it was the AI's action. Only when the Player built a city was the unit info available to Python.
     
  10. Toffer90

    Toffer90 C2C Modder

    Joined:
    Oct 16, 2011
    Messages:
    6,089
    Location:
    Norway
    You probably used a different python event call then, like the "cityAquired" event, I know some of those events only fires for the human player.
    The "cityBuilt" python event fires when the AI build cities, I checked that in-game.
    I use the same method to award the tribal guardian to the first city in PPIO too, with a promotion on the settler that builds it. That is because I made it so that if the capital is demolished the tribal guardian is removed and represented as a promotion on the settler unit that appear when you demolish a city. This made sense as the Tribal Guardian cannot move, but if you want to move your first and only city in the start of the game it would be strange to leave the tribal guardian standing around where the city once was. All the AI does get a Tribal Guardian in their capital with PPIO.
     
    Last edited: May 26, 2019
  11. Dancing Hoskuld

    Dancing Hoskuld Warlord

    Joined:
    Jul 5, 2004
    Messages:
    23,290
    Gender:
    Male
    Location:
    Canberra, Australia
    No "we", I got the mod from a reputable source, used the "cityBuilt" event. The problem (Platyping pointed out the problem) was that the method of getting the unit that built the city (something like "get selected unit") returned a null if it was the AI but the unit if it was the player. This meant that it looked like it was working when testing, if you forgot to check what was happening in the AI cities.
     
  12. Toffer90

    Toffer90 C2C Modder

    Joined:
    Oct 16, 2011
    Messages:
    6,089
    Location:
    Norway
    That's because the AI doesn't actually select units.
    The problem you pointed out there was pretty much the whole reason why I wanted TB to add the unit as argument to the python call event, so that settler promotions could be used to define the new city in some way.

    There was another way to do this before the unit was added as an argument.
    One could loop through all the units on the plot until a settler was found and use its promotions for the city, but this was a crude method, not very elegant, because if there were more than one settler on the plot this code would simply pick the first it found regardless of which settler actually founded the soon to be new city.
     
    Last edited: May 26, 2019
  13. DC0

    DC0 Chieftain

    Joined:
    Dec 20, 2008
    Messages:
    251
    Gender:
    Male
    Location:
    Russia, Moscow
    About "Buildings make themselves cheaper" as written here.
    It should be the other way around. Such mechanics was implemented in Alpha Centauri game: prototype. First unit created was prototype and had a cost like +10% to normal unit cost.
    Same is in real life. Prototypes are always more expensive. Later building algorithms are improved and units (or buildings) become cheaper. But only to a certain point. You still have to spend certain amount of materials and labor to make something. Even if it has been made before many times.

    So suggestion is to make first unit or building a prototype, requiring +10...+15% more :hammers:. All later same units/buildings will require normal amount of :hammers:.
     
  14. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    26,116
    Gender:
    Male
    Location:
    Las Vegas
    Most of that strikes me as semantics and otherwise the same as what was done. However, the last statement clarifies the difference and I think, in general, I do agree. The cheapening can only take place so much before it hits a plateau of optimum expense. Not sure how it's implemented now but that consideration should be kept in mind, as you suggest. It also makes some sense to say it's just the first one or two that are MORE expensive rather than making further ones beyond that LESS expensive, though that may be DH's reaction to his sense of the baseline expense being what he feels is generally high.
     
  15. Dancing Hoskuld

    Dancing Hoskuld Warlord

    Joined:
    Jul 5, 2004
    Messages:
    23,290
    Gender:
    Male
    Location:
    Canberra, Australia
    This is what I wanted to do but it is not possible with simple XML coding that will be visible to the AI.
    I have no problem with the current costs of buildings. I wanted to see if doing this was meaningful and possible. I should not have put it in the XML. Certianly not in the World View module and I will remove it.

    To gereralize it we would need a new tag set. Possible just a bPrototypeCostsMore and then just use the same adjustment values for all buildings or a group PrototypeCosts with elements PrototypeCostPercent. The number of entries would allow for any number of prototypes. It would contain the % increase in cost for that building and when the list runs out there is no increase.
    EG for a building that requires 3 prototypes before the cost becomes the same as in the iCost field
    <PrototypeCosts>
    <PrototypeCostPercent>15</PrototypeCostPercent>
    <PrototypeCostPercent>10</PrototypeCostPercent>
    <PrototypeCostPercent>0</PrototypeCostPercent>​
    </PrototypeCosts>​
     
  16. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    26,116
    Gender:
    Male
    Location:
    Las Vegas
    Well that's the other issue, that you're working with what you have available to you and you can't be faulted if it's only slightly flawed as a result. Is there any way to limit how effective the cost reduction is? I'm not sure how you went about it. I don't actually disagree with the concept but I can't say I'd be able to address a new tag any time soon.
     
  17. Toffer90

    Toffer90 C2C Modder

    Joined:
    Oct 16, 2011
    Messages:
    6,089
    Location:
    Norway
    I don't think a tag like this is worth the extra RAM usage per building, buildings already have a bit too many properties as it is, another tag for it would have to bring something quite valuable to the gameplay experience to be worth it.
    I think the abstraction of building costs we currently have is an adequate simulation of cities productivity effort.
    The new suggested tag may not even make it all that much a more precise simulation.
    Building schools/hospitals/railway/factories is not really a production line, where the next one is a simple continuation of the last one.
    Each construction job is unique, we still make prototype for every building we build through models and blueprints, the first school built in a country may very well be much cheaper than the last school built in that nation even though it may not really be less effective as a school than the last one will be.
    The first school may have been a simple re-purposing of an old building (like a city hall) which came at a low building cost while the last one may be an overambitious project built in difficult terrain with difficult building materials, without actually resulting in a better school than the first one did.

    I consider the small scale prototypes, or proof of concept, of buildings to already have been built in a nation during the turns you were inventing the tech that allows those buildings, so that when you as a player can actually build these buildings in your cities they have already existed in your nation on an experimental low scale for a limited time before you can actually build them for real in cities.

    If this tag had been implemented for units then it may also make sense to make sure that the first couple of units built have less strength than those trained later as they may have inferior equipment that break down and is harder to maintain, and because their training was worse than those trained later when the military found out how to properly train someone to use the newest equipment in a combat situation.

    This concept makes more sense for volumetric resources, that there should be some inertia in how many turns it takes before you get the full amount of resources from an improved map resource or from a building that provides manufactured bonuses after they started functioning.

    This is just my (long) opinion stated for the record, I won't protest on the matter if someone decides to actually implement the suggested tag.
     
    sunrisereader likes this.
  18. DC0

    DC0 Chieftain

    Joined:
    Dec 20, 2008
    Messages:
    251
    Gender:
    Male
    Location:
    Russia, Moscow
    Maybe just drop the concept of building becoming gradually cheaper altogether? We can pretend that higher :hammers: cost of first buildings is leveled out by lower cost of subsequent buildings. So every same type building has the same cost.
     
  19. raxo2222

    raxo2222 Time Traveller

    Joined:
    Jun 10, 2011
    Messages:
    6,158
    Location:
    Poland
    @Thunderbrd or @Toffer90 When city grows it assigns specialist at some point of growth.

    Is it possible to make city assign specialist to least used job where applicable?
    Citizen would be fall back if all other places were filled.
    Civ4BeyondSword 2019-06-06 13-15-04-28.png
    In this case I have civics that let unlimited amount of artists and priests.
    Here at next pop city should assign artist.
     
  20. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    26,116
    Gender:
    Male
    Location:
    Las Vegas
    Not really because then you're messing with the AI's assignment of civics, which the player cities use unless you override it. That process is a matter of finding the most valuable assignment, among all the options and tags and some other predictive reasoning, for the next specialist. If we change it for the player, it would change it for the AI. The formula needs updating now and then and I've been trying to figure out how to update it for the XP they bring but so far have struggled to create valid syntax for that. Probably was a little too inexperienced when I was trying it last and should look into it again but I'm having trouble asking the city what it currently has queued.
     
    raxo2222 likes this.

Share This Page