(not) running into molds

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • half
    Knight
    • Jan 2009
    • 910

    (not) running into molds

    There was recently a post about modifying the 'run' algorithm to avoid running into immobile monsters like molds. I had a look at the algorithm and one just needs to add the following to run_test() before it goes into the part where it looks for an open area. I've tested it and it seems to work well.


    Code:
    	/* Look at every soon to be newly adjacent square. */
    	for (i = -max; i <= max; i++)
    	{		
    		/* New direction */
    		new_dir = cycle[chome[prev_dir] + i];
    		
    		/* New location */
    		row = py + ddy[prev_dir] + ddy[new_dir];
    		col = px + ddx[prev_dir] + ddx[new_dir];
    		
    		/* Visible immovable monsters abort running */
    		if (cave_m_idx[row][col] > 0)
    		{
    			monster_type *m_ptr = &mon_list[cave_m_idx[row][col]];
    			monster_race *r_ptr = &r_info[m_ptr->r_idx];
    			
    			/* Visible monster */
    			if (m_ptr->ml && (r_ptr->flags1 & (RF1_NEVER_MOVE))) return (TRUE);
    			
    		}
    	}
  • takkaria
    Veteran
    • Apr 2007
    • 1951

    #2
    Originally posted by half
    There was recently a post about modifying the 'run' algorithm to avoid running into immobile monsters like molds. I had a look at the algorithm and one just needs to add the following to run_test() before it goes into the part where it looks for an open area. I've tested it and it seems to work well.
    Thanks for this, when I go through fixing bugs in 3.1, I'll get this in.
    takkaria whispers something about options. -more-

    Comment

    • Magnate
      Angband Devteam member
      • May 2007
      • 5110

      #3
      Originally posted by takkaria
      Thanks for this, when I go through fixing bugs in 3.1, I'll get this in.
      Has this already been done? Looking at pathfind.c, there is some very similar code in it now (r1402), but it is applied to *any* visible monster, rather than just those with NEVER_MOVE.

      So does anything else need to be changed?
      "Been away so long I hardly knew the place, gee it's good to be back home" - The Beatles

      Comment

      • takkaria
        Veteran
        • Apr 2007
        • 1951

        #4
        Originally posted by Magnate
        Has this already been done? Looking at pathfind.c, there is some very similar code in it now (r1402), but it is applied to *any* visible monster, rather than just those with NEVER_MOVE.

        So does anything else need to be changed?
        Hm, there should be a ticket for it somewhere, but I can only guess the answer is "no" because I don't remember doing it.
        takkaria whispers something about options. -more-

        Comment

        • Cauldron
          Apprentice
          • May 2009
          • 62

          #5
          Hallelujah, cause I lost my last character to a Trapper in the middle of a room. Killt me in 1 step.

          -P
          I miss autoscum... but not that much.

          Comment

          • Magnate
            Angband Devteam member
            • May 2007
            • 5110

            #6
            Originally posted by takkaria
            Hm, there should be a ticket for it somewhere, but I can only guess the answer is "no" because I don't remember doing it.
            It's ticket #700, and I think I'm failing to understand the changes proposed in this thread. Perhaps what is needed is an additional code block as posted above, which comes before (or after) the existing code block about visible monsters. So that we look one square further away for immobile monsters. Maybe.
            "Been away so long I hardly knew the place, gee it's good to be back home" - The Beatles

            Comment

            • will_asher
              DaJAngband Maintainer
              • Apr 2007
              • 1124

              #7
              Seems like it'd be easier to add something in update_mon() which makes it disturb you whenever you're adjacent to a (visible) monster. (That's what I was going to do to address the same problem)
              Will_Asher
              aka LibraryAdventurer

              My old variant DaJAngband:
              http://sites.google.com/site/dajangbandwebsite/home (defunct and so old it's forked from Angband 3.1.0 -I think- but it's probably playable...)

              Comment

              • Magnate
                Angband Devteam member
                • May 2007
                • 5110

                #8
                Originally posted by will_asher
                Seems like it'd be easier to add something in update_mon() which makes it disturb you whenever you're adjacent to a (visible) monster. (That's what I was going to do to address the same problem)
                But by the time you're adjacent to a monster, it's too late. I think the existing code already does that. I think the suggestion proposed by the OP is to look one square further away and stop *before* we step adjacent to a monster. Since running no longer cuts corners, this should be legitimate - you'd stop in the corner if the floating eye was two squares from it, the moment it became visible.

                I just don't understand how the OP's code should be applied to the existing code, as it's not in patch format.
                "Been away so long I hardly knew the place, gee it's good to be back home" - The Beatles

                Comment

                • Magnate
                  Angband Devteam member
                  • May 2007
                  • 5110

                  #9
                  Originally posted by Magnate
                  But by the time you're adjacent to a monster, it's too late. I think the existing code already does that. I think the suggestion proposed by the OP is to look one square further away and stop *before* we step adjacent to a monster. Since running no longer cuts corners, this should be legitimate - you'd stop in the corner if the floating eye was two squares from it, the moment it became visible.

                  I just don't understand how the OP's code should be applied to the existing code, as it's not in patch format.
                  I finally worked it out. The OP wasn't talking about running into molds/eyes as you round corners - that was already working. He was talking about running into molds that you can already see. It never occurred to me that anyone would run towards a mold they could already see, so I didn't understand what he was getting at.

                  Fixed in r1413 - thanks for the patch.
                  "Been away so long I hardly knew the place, gee it's good to be back home" - The Beatles

                  Comment

                  • PowerDiver
                    Prophet
                    • Mar 2008
                    • 2820

                    #10
                    Originally posted by Magnate
                    It never occurred to me that anyone would run towards a mold they could already see,.
                    You've never run into a monster you didn't notice?

                    Damned youngsters with perfect vision and attention to detail can't understand the problems of dotards playing while under the influence of one too many Guinness.

                    Comment

                    • Magnate
                      Angband Devteam member
                      • May 2007
                      • 5110

                      #11
                      Originally posted by PowerDiver
                      You've never run into a monster you didn't notice?

                      Damned youngsters with perfect vision and attention to detail can't understand the problems of dotards playing while under the influence of one too many Guinness.
                      Heh, and there's me thinking I had about a decade on you.

                      To be pernickety, I've never *run* into a monster I didn't notice - but I have walked into many. Only yesterday I opened a door to one of those 2x2 pit rooms, greedy to get the unaware potion, and walked straight into the death mold that was sitting on it. I actually pressed the key to walk into the doorway, despite having detected monsters only a few turns before. My only defence is that the death mold hadn't shown up in red on the monster list, so I hadn't clocked it (this was at 2450').

                      Ho hum.
                      "Been away so long I hardly knew the place, gee it's good to be back home" - The Beatles

                      Comment

                      • PowerDiver
                        Prophet
                        • Mar 2008
                        • 2820

                        #12
                        Originally posted by Magnate
                        Heh, and there's me thinking I had about a decade on you.
                        Some of us lose our minds earlier than others. It's not just years. I'm mid-40s.

                        Comment

                        • Magnate
                          Angband Devteam member
                          • May 2007
                          • 5110

                          #13
                          Originally posted by PowerDiver
                          Some of us lose our minds earlier than others. It's not just years. I'm mid-40s.
                          I'm just the other side of 40, but only by a matter of months ...
                          "Been away so long I hardly knew the place, gee it's good to be back home" - The Beatles

                          Comment

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