stop Angband from stacking commands

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Derakon
    Prophet
    • Dec 2009
    • 9022

    #16
    You clearly know enough about programming to be dangerous, so like I said earlier, I encourage you to download the source code and take a stab at implementing it yourself. I don't think people would object to having the functionality you're talking about, so long as it doesn't interfere with normal playstyles. But I don't think you're going to be able to convince anyone to implement it for you. So you're on your own on this one, champ.

    Comment

    • AnonymousHero
      Veteran
      • Jun 2007
      • 1393

      #17
      Originally posted by Sky
      you are telling me that

      10 execute command
      20 purge commands
      30 goto 10

      is too hard ?
      Really? That's the level of discourse now?

      Comment

      • AnonymousHero
        Veteran
        • Jun 2007
        • 1393

        #18
        Originally posted by Sky
        ok, let's be constructive. solutions, not problems.

        you need have a list of commands, right?? e.g. press 8 -> move up.
        what language is angband built in? C+ ? how does it stack commands? does it tell the OS "i have not finished with this command yet" , or does it actually buffer internally the commands? let's assume the former, your basic commands should look something like press 8 -> move up, getchar();
        or char buffer[1].
        There's no such thing as "C+". There's "C" or "C++". The rest of your comment makes no more sense than that.

        Look, can you plainly explain the "use case"? I don't buy "I have my keyboard set to repeat at 500kps". I you had that you'd be complaining to Microsoft/GNOME/KDE or whatever, because nothing handles *that*. (And, also, you'd *still* be dead even if Angband had a "don't buffer keypresses" policy.)

        Comment

        • Sky
          Veteran
          • Oct 2016
          • 2321

          #19
          there is an option in the control panel to set how your keyboard repeats commands. by default it's set on medium, and i have set on fast. again, this is not a registry hack, the repeat values are set within Microsoft's standards. it's no different than setting your mouse to move faster.

          now, as mage or ranger, occasionally rogue, there will be times where you simply need the fire command repeated many times. maybe you are just killing trolls. if this is a directional, non targeted command (cast acidbolt east) the game will happily repeat commands even when a key is not pressed.

          this must be because the commands stack - if you use the keyboard to tell angband (fire 15 bolts east) then angband will tell the system "i will now fire as many bolts east as you have told me" instead of "ok i see that you want a command done, i will do it and then i will wait for new instructions".

          the command i wrote above is whatever google first gave me for "purge keyboard I/O buffer" which apparently is what other coders have used to resolve the same problem.
          "i can take this dracolich"

          Comment

          • wobbly
            Prophet
            • May 2012
            • 2627

            #20
            Programming issues aside I'm not sure whether I'd even want the change you are asking for. If I've just told the game to fire 15 bolts east it's probably because I want the game to fire 15 bolts east. I mean 15 seems a bit over the top but under safe enough circumstances I might actually want to repeat an action a few times with out using the repeat command.

            Comment

            • Sky
              Veteran
              • Oct 2016
              • 2321

              #21
              But it would still do that. It only distinguishes between commands received before and after an action.
              "i can take this dracolich"

              Comment

              • Derakon
                Prophet
                • Dec 2009
                • 9022

                #22
                Originally posted by Sky
                now, as mage or ranger, occasionally rogue, there will be times where you simply need the fire command repeated many times. maybe you are just killing trolls. if this is a directional, non targeted command (cast acidbolt east) the game will happily repeat commands even when a key is not pressed.
                I seriously question the amount of time you save by holding a button down vs. just hitting it 15 times in rapid succession. It's not too hard to hit a key 5 times a second; are you really that hard-pressed for time that you need to save 2 seconds (remembering that it takes a bit for key repeat to kick in) while fighting trolls?

                Comment

                • kandrc
                  Swordsman
                  • Dec 2007
                  • 299

                  #23
                  Originally posted by Sky
                  But it would still do that. It only distinguishes between commands received before and after an action.
                  Often I'm honestly not certain if you're serious, or if you're a very clever troll.

                  Comment

                  • takkaria
                    Veteran
                    • Apr 2007
                    • 1951

                    #24
                    Originally posted by Sky
                    this must be because the commands stack - if you use the keyboard to tell angband (fire 15 bolts east) then angband will tell the system "i will now fire as many bolts east as you have told me" instead of "ok i see that you want a command done, i will do it and then i will wait for new instructions".
                    I don't think there's any concept of commands 'stacking' in Angband like you say. Angband gets told by its frontend, which gets told by the OS, that a key got pressed. Angband does an instruction, and then goes back to the frontend to ask for another command. It goes like this:

                    Angband: 'I need a keypress now.'
                    Frontend: 'Just wait a minute... OK, it's s'
                    Angband: <does command> 'I need a keypress now.'
                    Frontend: 'Just wait a minute... OK, it's R'
                    Angband: <does command> 'I need a keypress now.'

                    etc.

                    Angband doesn't get one instruction saying 'fire 15 bolts east', it gets 15 keypresses and it processes each in turn. The OS/graphics library does the keypress buffering for us, and it's good, like kandrc tried to explain. If you don't buffer, you risk losing input, which in a game like Angband would be pretty terrible.
                    takkaria whispers something about options. -more-

                    Comment

                    • kaypy
                      Swordsman
                      • May 2009
                      • 294

                      #25
                      Hmm

                      Angband does have the concept of flushing the input buffer. (grep the source for flush and look for something with both "flush" and "input" in proximity)

                      If someone were sufficiently motivated to hack in a command to flush the buffer, then a macro along the lines of cast-acid-bolt-at-nearest-target-then-flush-the-input-buffer might have interesting effects...

                      Comment

                      • takkaria
                        Veteran
                        • Apr 2007
                        • 1951

                        #26
                        Originally posted by kaypy
                        If someone were sufficiently motivated to hack in a command to flush the buffer, then a macro along the lines of cast-acid-bolt-at-nearest-target-then-flush-the-input-buffer might have interesting effects...
                        Yeah, that sounds like it might work. In fact, you don't need to hack anything in, you can just put a Control-R after the command because redrawing forces a flush.
                        takkaria whispers something about options. -more-

                        Comment

                        • t4nk
                          Swordsman
                          • May 2016
                          • 336

                          #27
                          I must say you all are unfair to Sky. Throttling keyboard repeat rate is reasonable, possible and easy.
                          takkaria, unsurprisingly, even figured out how to do it

                          Originally posted by takkaria
                          You could imagine a check where if the current command is the same as the previous one, then you check if the key is held down. But then if you pressed [f1] two times in a row manually (as opposed to with auto-repeat), this wouldn't be the desired behaviour either. You could, I guess, take a note of the time when each keypress comes through and compare it to the time of the previous command, and if they're really close together turn on scanning behaviour. But I imagine that will be pretty error-prone too, and would feel pretty non-deterministic to the player.
                          The best typists can type about 600 symbols per minute. (I heard in typing competitions they use stenography, and special keyboards with "chords" - no idea what that is - and then can show about 1200 symbols/min, but 600 is a pretty reasonable limit for a normal human with a standard keyboard). That's 10 symbols/sec, or 1 symbol in 100 milliseconds, which is a considerable time... Of course, 600 is average, and peak speed is higher than that, but if keypresses come faster than, say, once per 50 msecs, it means that the user is holding down a key, or pressed several keys (almost) simultaneously. So the pseudocode looks like:
                          Code:
                          void get_input() {
                              static time_t previous_time;
                          
                              while (true) {
                                  key k = get_key();
                                  time_t t = get_time();
                          
                                  if (t - previous_time >= KEY_REPEAT_RATE_IN_MSECS) {
                                      Term_keypress(k);
                                      previous_time = t;
                                      return;
                                  }
                                  // else just forget this key, and read the new one
                              }
                          }
                          You can also memorize the previous key, and only discard the new key if the time is not right and the new key is the same as the previous one (so that "movement delay" would work).

                          I implemented that in textui2 (but I forgot the previous key thing). That's how all key repeat limiters work, and it doesn't feel non deterministic or anything, if it allows, say, 20 keys per second. After that the difference can only be percieved when holding down a key.

                          As for flushing the input queue, you can just read from it until it's empty, and, btw, Angband already has TERM_XTRA_FLUSH, which is supposed to do exactly that.

                          Comment

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