Force Borg to use an item if they find it

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Grommen
    Rookie
    • Mar 2024
    • 8

    Force Borg to use an item if they find it

    In borg.txt there is
    # NOTE: it is possible to do stupid/impossible things, like require the borg to have 3 Ringils or carry 999 potions of healing to get to level 1. there are no checks against such stupidity.

    Can I update borg.txt to force the borg to use an item if they find it? Specifically, Ringil. If so, what code do I need to add? I have never seen any of my borgs use it and have seen many times where they throw it away, even when they obviously have a lesser weapon.

    Also, is there a way to see an artifact's index number?
    Last edited by Grommen; April 13, 2024, 02:23.
  • backwardsEric
    Knight
    • Aug 2019
    • 506

    #2
    Originally posted by Grommen
    Also, is there a way to see an artifact's index number?
    It is it's position in lib/gamedata/artifact.txt so the Phial of Galadriel is 1 and the Massive Iron Crown of Morgoth is 138. Running this front the top level directory of the Angband sources in a Unix-like environment would get you a table of the indices and names:

    Code:
    sed -ne 's/^name://p' lib/gamedata/artifact.txt | cat -n

    Comment

    • Grommen
      Rookie
      • Mar 2024
      • 8

      #3
      OK. Using that to pull indexes, it looks like borg.txt from the source was not reindexed when, at some point, artifact.txt was changed and that is what I have been using. This is probably causing my issue with the borg not using Ringil (and probably a lot of other issues)

      Comment

      • agoodman
        Apprentice
        • Jan 2011
        • 80

        #4
        The latest binary has dynamic formulas disabled. I am working on re-writing but it might take a bit. Typing in all the formulas is a pain.
        the old formulas were way out of date and in a terrible format (which I invented so I don’t have to feel bad about insulting it). the new format should be less dependent on ordering and hopefully clearer and easier to read.

        Comment

        • agoodman
          Apprentice
          • Jan 2011
          • 80

          #5
          Over the weekend the borg code was updated to do dynamic calculations (phase 1). This is only currently available if you compile Angband yourself. For those who do, make sure you copy a new version of borg.txt from src/borg/borg.txt to your user directory (lib/user if you are on Windows).
          So, if you are doing this and want the borg to prioritize Ringil, the current code doesn't use artifact names but artifact activations. This is so random artifacts can be used. So we look in artifact.txt and see
          name:'Ringil'
          ...
          act:COLD_BALL100

          and search borg.txt and see:
          condition(value(activation, cold_ball100)): reward(700 * value(activation, cold_ball100));

          so cold ball 100 is giving 700 per item that has that activation. We want it to always be used so change it (I like to leave old lines in commented out):
          # condition(value(activation, cold_ball100)): reward(700 * value(activation, cold_ball100)); old line
          condition(value(activation, cold_ball100)): reward(999999 * value(activation, cold_ball100));
          ​​now Ringil will give 999999 "power" for wielding it. We can test this by running Angband, start a new character, fire up wizard mode and create Ringil
          ^ACeo
          (I also create id scrolls ^Acyg repeat till Ringil fully id'd)
          wield Ringil and ask the borg it's power
          ^zp
          I got "Current Borg Power 634713 Current home power 3573"
          Then edit borg.txt as above and reload it.
          ^z$
          and check the power again
          ^zp
          I got "Current Borg Power 1634012 Current Home power 3573"
          looks like 999999 higher than before. Works
          This doesn't FORCE him to use the item but does make it far far more likely.

          Comment

          • Grommen
            Rookie
            • Mar 2024
            • 8

            #6
            Thank you for the hard work and the reply to this post. I will start using dynamic calcs. I do have a couple questions.
            1. Does the dynamic calc logic in the new borg.txt follow the same logic as not using dynamic calcs? ie. you only need to run dynamic calcs if you make changes to them in borg.txt.
            2. Just to be clear, there is currently nothing to allow "additional" reward for artifacts that do not have an activation, eg. most of the missile weapons.
            Edit: I knew dynamic calcs would be slower, by the note in borg.txt, but I didn't expect it to be so long. My level 28 just spent over 6m in his house comparing gear, went and sold/bought some stuff and went back to his house and is comparing again.
            Last edited by Grommen; April 23, 2024, 03:53.

            Comment

            • agoodman
              Apprentice
              • Jan 2011
              • 80

              #7
              1) The current default dynamic calcs should 100% match what is being done in the code. I have run several (but not comprehensive) tests to make sure they match. This is all about giving non-coders a path to alter what the borg does. Hopefully people can read the dynamic calcs and say "wow, this rule is stupid, it should be rewarding damage like this, not like that" then test it out themselves, see that it works better and we can correct the code.
              2) Right, artifacts are activation based but also if you read through the calculations, the blows and shots and damage and resists are all calculated into the power so if, say, Amrod is compared to a bow of power it should add up to better given it having str and con and resist fire etc. Otherwise, if the bow of power gives much better damage and that is more important, well, the bow of power is what should be used. Hopefully that all makes sense.

              >My level 28 just spent over 6m in his house
              Eeek! If you can, double check that it takes a lot less time with dynamic calcs turned off. I was seeing about a 20% loss but it was an eyeball test and is going to vary based on depth and class and the CPU power and other things.

              Comment

              • agoodman
                Apprentice
                • Jan 2011
                • 80

                #8
                BTW, how are you finding the dynamic calcs to read and modify? I just made up this format on my own and am up for any feedback.
                I can (relatively) easily add
                value(artifact wielded, xxx)
                so you could do
                condition(value(artifact wielded, Ringil)): reward(90000);
                I would just need to add an array of wielded artifacts to the borg. Any "value" that is two parameters (type, distinct instance of type) can be added as long as I can make the calculation as a quick lookup of the number. Right now all values are single array lookup. Of course the more I add, the slower it might get.

                Comment

                • Grommen
                  Rookie
                  • Mar 2024
                  • 8

                  #9
                  Thank you for the clarifications.

                  I had backed up that save file where he was taking a long time in his house. It appears to happen with dynamic calcs TRUE or FALSE. So, it must be something else. I will attach the file in case you want to run some tests.
                  Attached Files

                  Comment

                  • agoodman
                    Apprentice
                    • Jan 2011
                    • 80

                    #10
                    thanks. I will take a look. I think "takes a long time in the home" is often caused by the code that tests combinations for "should I drop off these things and take out and wear these other things to get a better combo". It really needs work. It does a lot of memory copying when it could be rewritten to pointer moves or just move indexes around, the problem being that it would take a major rewrite of several parts of the code to do it right and it just never bubbled up to top priority. It is code that annoys me so eventually I am sure to get to it... eventually.
                    as a bit of entertainment, there is a flag in borg.txt for borg_slow_optimizehome which will take those 6m and change em to hours and hours as it compares every possible combination of equipment and items from the home and equipped and inventory. There is a comment in the code that says something like "enable this if we are ever running on a Cray" ... it would take a quantum computer to run that stuff.

                    Comment

                    • agoodman
                      Apprentice
                      • Jan 2011
                      • 80

                      #11
                      Ya, this guy is in the "best stuff" loop. there are a couple of issues here
                      1) the memcpy issue I mentioned above
                      2) he tests combos but switches things one at a time so sometimes he switches out one thing then, because that switch makes him less powerful, wants to switch back and gets in a loop
                      It is code that really needs work. The save items and testing purchases in general could use a once over.

                      edit: additionally with 2, the borg has a lot of trouble with combination moves. He tends to start each move "born anew" so doing things that rely on what he just did is difficult. There are a couple of places where there are special "I just tried X and failed, don't try again" things but those are real special cases.

                      Comment

                      • agoodman
                        Apprentice
                        • Jan 2011
                        • 80

                        #12
                        I should mention, since I know you are using the dynamic calcs, take a look at

                        AC between 15 and 75 not being rewarded as it should and a couple of resistances reversed (the latter is no biggie except that it conflicts with "100% same as compiled")

                        Comment

                        • Grommen
                          Rookie
                          • Mar 2024
                          • 8

                          #13
                          Thank you. I have updated my borg.txt to match those changes.

                          Comment

                          • Grommen
                            Rookie
                            • Mar 2024
                            • 8

                            #14
                            MySave - Not using Ringil 999999.zip Seems to be an issue with this save I have attached with my borg.txt. I'm using borg_uses_dynamic_calcs. I have cold_ball100 (Ringil) set to 999999 and everything else is the same except some minor changes to artifact light sources. He found Ringil at 48 and was using it. At 50, he's wearing a War Hammer (Blessed). Ringil is in his home and says it has a home power of 744437. Also, it keeps crashing. I can manually move it to a new level and it works for a bit but then crashes again.
                            Attached Files

                            Comment

                            • Grommen
                              Rookie
                              • Mar 2024
                              • 8

                              #15
                              Errors uploading files again

                              Comment

                              Working...
                              😀
                              😂
                              🥰
                              😘
                              🤢
                              😎
                              😞
                              😡
                              👍
                              👎