TripleA Logo TripleA Forum
    • TripleA Website
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Tags
    • Register
    • Login

    Categories and/or tags

    Scheduled Pinned Locked Moved Feature Requests & Ideas
    57 Posts 9 Posters 23.2k Views 9 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • wc_sumptonW Offline
      wc_sumpton
      last edited by

      @redrum
      I can see a lot of uses for this. I do have one question. In you example for the unitAttachment, under the "Players" variable, the last element was left blank so that when creating the attachment that value would be left out. This I understand, but what would happen if the blank value was not there?

      In my map 'Invasion USA' there are 30 Victory Cities, with 'Denver' being the only city with both 'city' and 'mountain' effects. So if I created a list 'AllCities':

      	<variableList>
      		<variable name="AllCities">
      			<element name="Denver"/>
      			<element name="Washington D.C."/>
      			<element name="New York"/>
      			<element name="Boston"/>
      			<element name="Philadelphia"/>
      			<element name="Buffalo"/>
      			<element name="Pittsburgh"/>
      			<element name="San Diego"/>
      			<element name="Memphis"/>
      			<element name="Indianapolis"/>
      			<element name="New Orleans"/>
      			<element name="Los Angeles"/>
      			<element name="Milwaukee"/>
      			<element name="Detroit"/>
      			<element name="Houston"/>
      			<element name="Chicago"/>
      			<element name="San Francisco"/>
      			<element name="Portland"/>
      			<element name="Tampa"/>
      			<element name="Kansas City"/>
      			<element name="St. Louis"/>
      			<element name="Salt Lake City"/>
      			<element name="Seattle"/>
      			<element name="San Antonio"/>
      			<element name="Dallas"/>
      			<element name="Phoenix"/>
      			<element name="Minneapolis"/>
      			<element name="Atlanta"/>
      			<element name="Miami"/>
      			<element name="Cleveland"/>
      		</variable>
      

      And the add another list for territoryEffect:

      		<variable name="MountainOnly">
      			<element name="mountain"/>
      		</variable>
      	</variableList>
      

      And the for my territoryAttachments I used:

      	<attachment foreach="AllCities:MountainOnly" name="territoryAttachment" attachTo="$AllCities$" javaClass="games.strategy.triplea.attachments.TerritoryAttachment" type="territory">
      		<option name="production" value="6"/>
      		<option name="unitProduction" value="2"/>
      		<option name="resources" value="1:VCs"/>
      		<option name="territoryEffect" value="city"/>
      		<option name="territoryEffect" value="$MountainOnly$"/>
      		<option name="capital" value="Americans"/>                        
      	</attachment>
      

      Would it create the following attachments?

      		<attachment name="territoryAttachment" attachTo="Denver" javaClass="games.strategy.triplea.attachments.TerritoryAttachment" type="territory">
      			<option name="production" value="6"/>
      			<option name="unitProduction" value="2"/>
      			<option name="resources" value="1:VCs"/>
      			<option name="territoryEffect" value="city"/>
      			<option name="territoryEffect" value="mountain"/>
      			<option name="capital" value="Americans"/>                        
      		</attachment>
      
      		<attachment name="territoryAttachment" attachTo="Washington D.C." javaClass="games.strategy.triplea.attachments.TerritoryAttachment" type="territory">
      			<option name="production" value="6"/>
      			<option name="unitProduction" value="2"/>
      			<option name="resources" value="1:VCs"/>
      			<option name="territoryEffect" value="city"/>
      			<option name="capital" value="Americans"/>                        
      		</attachment>
      

      Or would I have to add the 29 extra blank elements?

      Cheers...

      redrumR 1 Reply Last reply Reply Quote 1
      • redrumR Offline
        redrum Admin @wc_sumpton
        last edited by redrum

        @wc_sumpton Right now I'm enforcing that all variables used in the same foreach must be the same length. For this particular example, I would just define Denver separately if its the only 1 like that otherwise you would need to add 29 empty elements. Here is what I would probably do:

        		<variable name="AllCities">
        			<element name="Washington D.C."/>
        			<element name="New York"/>
        			<element name="Boston"/>
        			<element name="Philadelphia"/>
        			<element name="Buffalo"/>
        			<element name="Pittsburgh"/>
        			<element name="San Diego"/>
        			<element name="Memphis"/>
        			<element name="Indianapolis"/>
        			<element name="New Orleans"/>
        			<element name="Los Angeles"/>
        			<element name="Milwaukee"/>
        			<element name="Detroit"/>
        			<element name="Houston"/>
        			<element name="Chicago"/>
        			<element name="San Francisco"/>
        			<element name="Portland"/>
        			<element name="Tampa"/>
        			<element name="Kansas City"/>
        			<element name="St. Louis"/>
        			<element name="Salt Lake City"/>
        			<element name="Seattle"/>
        			<element name="San Antonio"/>
        			<element name="Dallas"/>
        			<element name="Phoenix"/>
        			<element name="Minneapolis"/>
        			<element name="Atlanta"/>
        			<element name="Miami"/>
        			<element name="Cleveland"/>
        		</variable>
        
        	<attachment foreach="$AllCities$" name="territoryAttachment" attachTo="@AllCities@" javaClass="games.strategy.triplea.attachments.TerritoryAttachment" type="territory">
        		<option name="production" value="6"/>
        		<option name="unitProduction" value="2"/>
        		<option name="resources" value="1:VCs"/>
        		<option name="territoryEffect" value="city"/>
        		<option name="capital" value="Americans"/>                        
        	</attachment>
        
        	<attachment name="territoryAttachment" attachTo="Denver" javaClass="games.strategy.triplea.attachments.TerritoryAttachment" type="territory">
        		<option name="production" value="6"/>
        		<option name="unitProduction" value="2"/>
        		<option name="resources" value="1:VCs"/>
        		<option name="territoryEffect" value="city"/>
        		<option name="territoryEffect" value="mountain"/>
        		<option name="capital" value="Americans"/>                        
        	</attachment>
        

        TripleA Developer with a Passion for AI: https://forums.triplea-game.org/topic/105/ai-development-discussion-and-feedback

        HeppsH 1 Reply Last reply Reply Quote 2
        • HeppsH Offline
          Hepps Lobby Moderators @redrum
          last edited by

          @redrum That edit was an important one. 😃

          "A joyous heart sours with the burden of expectation"
          Hepster

          redrumR 1 Reply Last reply Reply Quote 0
          • redrumR Offline
            redrum Admin @Hepps
            last edited by

            @Hepps Yeah, misunderstood what he was trying to do the first read through.

            TripleA Developer with a Passion for AI: https://forums.triplea-game.org/topic/105/ai-development-discussion-and-feedback

            1 Reply Last reply Reply Quote 0
            • wc_sumptonW Offline
              wc_sumpton
              last edited by

              @redrum
              Got-ya! Thanks for the quick reply! Wondering when you plan to implement this. Would love to play around with some ideas!

              Cheers...

              1 Reply Last reply Reply Quote 0
              • redrumR Offline
                redrum Admin
                last edited by

                PR: https://github.com/triplea-game/triplea/pull/4791

                As soon as that's merged, you can test it in the pre-release.

                TripleA Developer with a Passion for AI: https://forums.triplea-game.org/topic/105/ai-development-discussion-and-feedback

                1 Reply Last reply Reply Quote 4
                • redrumR Offline
                  redrum Admin
                  last edited by

                  This is now available in the pre-release. I've updated the first post to reflect examples of how to use it and will be adding similar ones to POS2 XML.

                  TripleA Developer with a Passion for AI: https://forums.triplea-game.org/topic/105/ai-development-discussion-and-feedback

                  1 Reply Last reply Reply Quote 4
                  • FrostionF Offline
                    Frostion Admin
                    last edited by

                    @redrum I am looking forward to testing 😄

                    Question: Can the names of the variableLists be used instead of unit listing in attachments like targetsAA, repairsUnits, unitType etc.? Like:

                    <option name="targetsAA" value="PlayerLandUnits:AILandUnits"/>
                    Or
                    <option name="repairsUnits" value="1:PlayerHeroUnits:PlayerMultipleHPUnits:Dragon"/>

                    Map maker of: Star Wars: Galactic War + Star Wars: Tatooine War + Caribbean Trade War + Dragon War + Age of Tribes + Star Trek: Dilithium War + Iron War + Iron War: Europe + Warcraft: War Heroes

                    redrumR 1 Reply Last reply Reply Quote 1
                    • redrumR Offline
                      redrum Admin @Frostion
                      last edited by redrum

                      @Frostion Yes. Though I updated the original proposal slightly. Any time you reference a variable you need to put $variableName$. So for you example it would be like this:

                      <option name="targetsAA" value="$PlayerLandUnits$:$AILandUnits$"/>
                      

                      Here is an example I'm doing for some mystery map in development 🙂

                              <variable name="MajorPlayers">
                                  <element name="Bolsheviks"/>
                                  <element name="France"/>
                                  <element name="Britain"/>
                                  <element name="Russia"/>
                                  <element name="Germany"/>
                                  <element name="Austria-Hungary"/>
                                  <element name="Ottomans"/>
                                  <element name="Usa"/>
                                  <element name="Italy"/>
                              </variable>
                      
                              <attachment name="unitAttachment" attachTo="RecruitmentCenter" javaClass="UnitAttachment" type="unitType">
                                  <option name="movement" value="0"/>
                                  <option name="attack" value="0"/>
                                  <option name="defense" value="0"/>           
                                  <option name="isInfrastructure" value="true"/>
                                  <option name="canBeDamaged" value="true"/>
                                  <option name="maxDamage" value="10"/>
                                  <option name="maxOperationalDamage" value="8"/>
                                  <option name="destroyedWhenCapturedBy" value="$MajorPlayers$"/>
                                  <option name="canDieFromReachingMaxDamage" value="true"/>            
                                  <option name="isConstruction" value="true"/>
                                  <option name="constructionType" value="rcProduction"/>
                                  <option name="constructionsPerTerrPerTypePerTurn" value="1"/>
                                  <option name="maxConstructionsPerTypePerTerr" value="1"/>           
                              </attachment>
                      

                      TripleA Developer with a Passion for AI: https://forums.triplea-game.org/topic/105/ai-development-discussion-and-feedback

                      1 Reply Last reply Reply Quote 1
                      • wc_sumptonW Offline
                        wc_sumpton
                        last edited by

                        @redrum
                        Been playing around with this on the 'Invasion U.S.A.' map.

                        Real nice Job!!

                        Have you thought anymore on being able to do a 'foreach' inside a 'foreach'?

                        Cheers...

                        1 Reply Last reply Reply Quote 0
                        • redrumR Offline
                          redrum Admin
                          last edited by

                          @wc_sumpton A little bit. Most likely it'll only allow 2 levels of foreach (any more than that is just generating probably more attachments then you should be). It'll look something like this:

                          <attachment foreach="$Players$^$Territories$"/>
                          

                          Where if I had say 5 players and 100 territories then this would loop over each of those to create 500 attachments, 1 for each pair of player and territory.

                          TripleA Developer with a Passion for AI: https://forums.triplea-game.org/topic/105/ai-development-discussion-and-feedback

                          wc_sumptonW 1 Reply Last reply Reply Quote 0
                          • wc_sumptonW Offline
                            wc_sumpton @redrum
                            last edited by

                            @redrum
                            Yep, have the players territories loop. Sounds good thanks for the quick answer!

                            Cheers...

                            1 Reply Last reply Reply Quote 0
                            • FrostionF Offline
                              Frostion Admin
                              last edited by Frostion

                              @redrum I have tried to implement this new feature but I cant get it to work. There are no errors but the rules that I set do not seem to be taken into account during play. This is the top code I have in the XML:

                              <?xml version="1.0"?>
                              <!DOCTYPE game SYSTEM "game.dtd">
                              <game>
                                <info name="World of War Heroes" version="0.0.1"/>
                                <loader javaClass="games.strategy.triplea.TripleA"/>
                                <triplea minimumVersion="1.9"/>
                                <diceSides value="10"/>
                              
                                  <variableList>
                                      <variable name="PlayerLandUnits">
                                         <element name="Irregulars"/>
                                         <element name="Footmen"/>
                                         <element name="Pikemen"/>
                                         <element name="Bowmen"/>
                                         <element name="Crossbowmen"/>
                                         <element name="Cavalry"/>
                                         <element name="Ballista"/>
                                         <element name="Catapult"/>
                                         <element name="Trebuchet"/>
                                         <element name="Battering-Ram"/>
                                         <element name="Siege-Tower"/>
                                         <element name="Alliance-Footmen"/>
                                         <element name="High-Elves"/>
                                         <element name="Dryads"/>
                                         <element name="Horde-Footmen"/>
                                         <element name="Blood-Elves"/>
                                         <element name="Ogres"/>
                                         <element name="Ent"/>
                                         <element name="Bombard"/>
                                         <element name="Water-Elemental"/>
                                         <element name="Fire-Elemental"/>
                                         <element name="Earth-Elemental"/>
                                         <element name="Air-Elemental"/>
                                         <element name="Fel-Elemental"/>
                                      </variable>
                                      <variable name="PlayerSeaUnits">
                                         <element name="Workboat"/>
                                         <element name="Troopship"/>
                                         <element name="Warship"/>
                                         <element name="The-Moonspray"/>
                                      </variable>
                                      <variable name="PlayerAirUnits">
                                         <element name="Gryphon-Transport"/>
                                      </variable>
                                      <variable name="PlayerHeroUnits">
                                         <element name="Arthur"/>
                                         <element name="Khorman"/>
                                         <element name="Marryk"/>
                                         <element name="Ayanna"/>
                                         <element name="Thrall"/>
                                         <element name="Gart"/>
                                         <element name="Sevis"/>
                                         <element name="Sian-tsu"/>
                                      </variable>
                                      <variable name="AILandUnits">
                                         <element name="Outlaws"/>
                                         <element name="Worgen-Stalkers"/>
                                         <element name="Centaur-Outrunners"/>
                                         <element name="Defias-Thugs"/>
                                         <element name="Draenei-Mutants"/>
                                         <element name="Ettin-Giant"/>
                                         <element name="Fel-Beasts"/>
                                         <element name="Wraith"/>
                                         <element name="Gnoll-Brutes"/>
                                         <element name="Worgen-Raiders"/>
                                         <element name="Harpy-Witches"/>
                                         <element name="Kobold-Miners"/>
                                         <element name="Mad-Furbolgs"/>
                                         <element name="Murloc-Tiderunners"/>
                                         <element name="Naga-Warriors"/>
                                         <element name="Pirate-Goons"/>
                                         <element name="Pirate-Ship"/>
                                         <element name="Satyr-Minions"/>
                                         <element name="Oozes"/>
                                         <element name="Trogg-Savages"/>
                                         <element name="Enraged-Wildkin"/>
                                         <element name="Wretched-Monks"/>
                                         <element name="Zombie-Walkers"/>
                                         <element name="Red-Dragon"/>
                                         <element name="Blue-Dragon"/>
                                         <element name="Bronze-Dragon"/>
                                      </variable>
                                      <variable name="AISeaUnits">
                                         <element name="Pirate-Ship"/>
                                      </variable>
                                  </variableList>
                              
                                  <map>
                                    <territory name="Aboraz Beach" water="true"/>
                                    <territory name="Abyssal Sands"/>
                                    <territory name="Aerie Peak"/>
                                    <territory name="Agamagor"/>
                              

                              For example these two settings do not work while playing:

                                     <attachment name="territoryEffectAttachment" attachTo="Mountains" javaClass="games.strategy.triplea.attachments.TerritoryEffectAttachment" type="territoryEffect">
                                         <option name="noBlitz" value="$PlayerLandUnits$:$PlayerHeroUnits$:$AILandUnits$"/>
                                     </attachment>
                              
                                     <attachment name="supportAttachmentGhost" attachTo="Wraith" javaClass="games.strategy.triplea.attachments.UnitSupportAttachment" type="unitType"><option name="faction" value="enemy"/>
                                         <option name="faction" value="enemy"/>
                                         <option name="side" value="offence:defence"/>
                                         <option name="dice" value="strength"/>
                                         <option name="bonus" value="-2"/>
                                         <option name="number" value="1"/>
                                         <option name="unitType" value="$PlayerLandUnits$:$PlayerAirUnits$:$PlayerHeroUnits$:$AILandUnits$"/>
                                         <option name="bonusType" value="Fear"/>
                                     </attachment>
                              

                              I am pretty sure all other variableList code does not work either. What am I doing wrong?

                              Map maker of: Star Wars: Galactic War + Star Wars: Tatooine War + Caribbean Trade War + Dragon War + Age of Tribes + Star Trek: Dilithium War + Iron War + Iron War: Europe + Warcraft: War Heroes

                              redrumR 1 Reply Last reply Reply Quote 1
                              • redrumR Offline
                                redrum Admin @Frostion
                                last edited by redrum

                                @Frostion Looks alright. Do you get any errors?

                                If you can send me the XML or zip then I can do a quick test to see. You should also be able to go to Export > Game Xml (or something like that) to export the game XML which will show the variable values added into the attachments.

                                Also your support attachment has "faction" defined twice (1 hanging out at the end of the first line).

                                TripleA Developer with a Passion for AI: https://forums.triplea-game.org/topic/105/ai-development-discussion-and-feedback

                                1 Reply Last reply Reply Quote 0
                                • wc_sumptonW Offline
                                  wc_sumpton
                                  last edited by

                                  @redrum
                                  Been playing around with this in 'Invasion U.S.A'. So far I have reduced the code line count from over 21000 to less then 7000. This makes the xml easier to read and debug. Great improvement!!

                                  Cheers...

                                  1 Reply Last reply Reply Quote 3
                                  • redrumR Offline
                                    redrum Admin
                                    last edited by redrum

                                    Alright so the next major improvement is here! You can now do a nested foreach loop (limited to just 1 level though) using the '^' character in order to generate even more conditions/triggers with less XML! So if I defined say 2 variables 'Territories' and 'Players' then I could do a nested loop to generate say a trigger for all combinations of territories and players:

                                    foreach="$Territories$^$Players$"
                                    

                                    Example:
                                    I want to replace (add/remove) a certain unit type with a different unit type for many territories and all players. In this example, I want to replace "Factories" with "NavalFactories" for any territories that are designated as "PortTerritories". I have ~50 port territories and ~10 different players so not using this feature it would require 500 conditions, 500 remove factory triggers, and 500 add naval factory triggers for a total of 1500 conditions/triggers.

                                    But now with a nested foreach loop I can achieve this with 3 conditions/triggers:

                                            <attachment foreach="$PortTerritories$^$MajorPlayers$:$PlayerPrefixes$" name="conditionAttachmentHas@PlayerPrefixes@Factory@PortTerritories@" attachTo="@MajorPlayers@" javaClass="RulesAttachment" type="player">
                                                <option name="directPresenceTerritories" value="@PortTerritories@"/>
                                                <option name="unitPresence" value="@PlayerPrefixes@Factory" count="1"/>
                                            </attachment>
                                            <attachment foreach="$PortTerritories$^$MajorPlayers$:$PlayerPrefixes$" name="triggerAttachmentAdd@PlayerPrefixes@NavalFactory@PortTerritories@" attachTo="@MajorPlayers@" javaClass="TriggerAttachment" type="player">
                                                <option name="conditions" value="conditionAttachmentHas@PlayerPrefixes@Factory@PortTerritories@"/>
                                                <option name="when" value="after:@PlayerPrefixes@Place"/>
                                                <option name="placement" value="@PortTerritories@:@PlayerPrefixes@NavalFactory"/>     
                                            </attachment>
                                            <attachment foreach="$PortTerritories$^$MajorPlayers$:$PlayerPrefixes$" name="triggerAttachmentRemove@PlayerPrefixes@Factory@PortTerritories@" attachTo="@MajorPlayers@" javaClass="TriggerAttachment" type="player">
                                                <option name="conditions" value="conditionAttachmentHas@PlayerPrefixes@Factory@PortTerritories@"/>
                                                <option name="when" value="after:@PlayerPrefixes@Place"/>
                                                <option name="removeUnits" value="@PortTerritories@:@PlayerPrefixes@Factory"/>     
                                            </attachment>
                                    

                                    $PortTerritories$ = list of all territories that I want to have naval factories
                                    $MajorPlayers$ = list of all players (Germany, Russia, etc)
                                    $PlayerPrefixes$ = list of unit nationality prefixes (German, Russian, etc)

                                    TripleA Developer with a Passion for AI: https://forums.triplea-game.org/topic/105/ai-development-discussion-and-feedback

                                    RogerCooperR 1 Reply Last reply Reply Quote 3
                                    • redrumR Offline
                                      redrum Admin
                                      last edited by

                                      Here is the PR: https://github.com/triplea-game/triplea/pull/4822

                                      TripleA Developer with a Passion for AI: https://forums.triplea-game.org/topic/105/ai-development-discussion-and-feedback

                                      B 1 Reply Last reply Reply Quote 3
                                      • B Online
                                        beelee @redrum
                                        last edited by

                                        @redrum

                                        Outstanding !!!

                                        1 Reply Last reply Reply Quote 0
                                        • redrumR Offline
                                          redrum Admin
                                          last edited by

                                          This is now merged and can be tested in the latest pre-release. Here is the POS2 XML explanation as well: https://github.com/triplea-maps/the_pact_of_steel/pull/31/files

                                          TripleA Developer with a Passion for AI: https://forums.triplea-game.org/topic/105/ai-development-discussion-and-feedback

                                          1 Reply Last reply Reply Quote 3
                                          • RogerCooperR Offline
                                            RogerCooper @redrum
                                            last edited by

                                            @redrum Is there any problem with using the same variable in a nested foreach loop? I want to do a relationshipinitialize where all the players start out neutral to each other.

                                            redrumR 1 Reply Last reply Reply Quote 0

                                            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                            With your input, this post could be even better 💗

                                            Register Login
                                            • 1
                                            • 2
                                            • 3
                                            • 3 / 3
                                            • First post
                                              Last post
                                            Powered by NodeBB Forums