Author Topic: Trying to have a list of command prefixes called in any arrangement at once  (Read 878 times)

Enduriel

  • Newbie
  • *
  • Posts: 4
Eg: apples, oranges and bananas do this
apples do that
bananas and oranges do something

I'm unsure how to approach such a system due to the unreliability of the ordering of wildcards, as well as the asynchronous nature of command execution.
Is there any way for me to handle a variable length list of command prefixes as listed above and guarantee that they are fully executed before the command suffixes I outline? The latter part of this is where wildcards fall apart for me.

Would really appreciate some help, thank you for your time ^^.

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
In summary, what you're trying to do is a little outside of what the software is intended to do.  However, with a little legwork you'll probably be able to get at least close to what you're wanting to do.

If I'm reading it right (and going by your example in another thread) what you're wanting to do is be able to say a random set of phrases and have VA execute specific commands (in order, executing one after the next), based on those phrases.  Out of the box, that's not really how this software is outfitted, mostly because of speech engine requirements/limitations.  VA does provide wildcards, but only as as a way to *possibly* get something done if you really don't have any other way. That is, wildcards were not part of the initial implementation *because* it would be highly (unbearably) unreliable - users asked if it could be implemented anyway so they could at least make the decision themselves about how unreliable that may be, and take the 'risk' on themselves (if that makes sense).  Wildcards were then implemented, but implemented as, 'unsupported' as a functioning feature.

For accuracy and speed, the speech engine is going to need exact phrases.  For accuracy, exact words means less words to focus on to make a decision.  For speed, exact words means no time spent contextually figuring out the phrase (like dictation - takes a relative eternity).  This is why within this environment wildcards by nature are not really reliable. In addition to wildcards, you're throwing asynchronous commands in there because you're using several commands at the same time to try to get something done.  Asynchronous commands are just that - by design they'll all run together.

So, for your case, the only suggestion I can make is if you have a relatively small set, you'll need to make a command for each combination (e.g. 'Infantry charge archers', 'infantry charge', 'charge', etc) or a single command using dynamic command phrases (e.g. '[archers;infantry;charge][archers;infantry;]') with if/else statements.  Each could execute their subcommands in order using the, 'wait until finished' option, or, you can add the subcommands to a command queue (and then run the queue).  This would make the commands run synchronously.

Hope that helps some.  If you press F1 while VA is in focus, that will bring up the help document.  You'll want to look over using dynamic command sections and command queues so that you'll know what's available to you.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
You'd need to compile a list of all the possible permutations, and list them as options in the "When I say" field.

For the example of three items, that's doable, E.G. using this calculator (which, unfortunately, does not allow spaces, though you could substitute underscores and replace them later on)

You'd want the permutations for three items, two items, and a single item, which when combined result in
Code: [Select]
apples
oranges
bananas
apples, oranges
apples, bananas
oranges, apples
oranges, bananas
bananas, apples
bananas, oranges
apples, oranges, bananas
apples, bananas, oranges
oranges, apples, bananas
oranges, bananas, apples
bananas, apples, oranges
bananas, oranges, apples

A text editor with a robust find and replace feature (E.G. Notepad++) can then be used to turn this into a list of command phrases, with the proper separators:
Code: [Select]
apples;oranges;bananas;apples oranges;apples bananas;oranges apples;oranges bananas;bananas apples;bananas oranges;apples oranges bananas;apples bananas oranges;oranges apples bananas;oranges bananas apples;bananas apples oranges;bananas oranges apples
This result is achieved by replace "\r\n" with ";" (with the search mode set to extended in Notepad++), and replacing "," with "" (blank) to remove the commas (this step can be optional)

Copying the list the linked website outputs adds "    " in front of each entry, which can also be removed using find/replace in this manner.


If you want to add "and" for the last item, you'd need to use a regular expression, like this:
Code: [Select]
(?!.+ )(making sure to set the search mode to regular expression)
replacing with " and " (note the spaces wrapping the word)

Run that replace first, before the others (it can technically be done after replacing the commas, but not after replacing the newline characters, however you might as well do it first)

Running all three would result in
Code: [Select]
apples;oranges;bananas;apples and oranges;apples and bananas;oranges and apples;oranges and bananas;bananas and apples;bananas and oranges;apples oranges and bananas;apples bananas and oranges;oranges apples and bananas;oranges bananas and apples;bananas apples and oranges;bananas oranges and apples
Notepad++ does allow you to record macro sequences, so the steps could be automated.


Do note that adding more items rapidly increases the amount of permutations, and thus the phrases that must be passed to the speech recognition engine.
E.G. the three items in the example result in 15 phrases, but adding a fourth increases the total to 64 phrases.

Adding even a single optional dynamic command section, E.G. "[do this;do that]", doubles the input item count to eight, however the output shoots up to well over 100000 phrases, which the online tools I could find won't output.


Generating all the variations ahead of time as shown could be simpler than trying to determine which combinations of dynamic sections generate which combinations.
If you are going to use the latter technique, this command could be useful to visualize what will be generated.


The exponential increase in possible phrases should be kept in mind regardless, as at a certain point profile loading times will get quite long (depending on your hardware), and in more extreme cases, VoiceAttack (or the speech recognition engine itself, in the 64bit version) will run out of memory.

Enduriel

  • Newbie
  • *
  • Posts: 4
Thank you Gary for the explanation of the limitations of the system and Pfeil for detailing how I could work on the explicit approach suggested by Gary. I have looked at the help documentation of course and it was helpful for a couple of other things I wanted to look through but this specific scenario didn't really seem to have a solution so I came here ^^.

Unfortunately due to the nature of the game I'm trying to make this for (Bannerlord) there are 9 total categories (albeit 4 basic ones), and I was trying to make the perfect profile for it. Writing out all the combinations wouldn't be a problem for me, as writing a python script or similar to for all the combinations would be trivial, but I really wanted an approach that isn't brute forcing the problem, and with 9 elements there are just under a million possible combinations.

After thinking about it some more however, it would be highly unrealistic for a user to spell out more than 3 or 4 troop types at the same time, usually it would likely just be 2. I guess I will do some experimentation with 600 and 3,600 possible combinations and see how it goes. Maybe that will be good enough.

One more question regarding wildcards, I understand that they're unsupported, but how come they always run in parallel while other commands need to have an option specifically enabled for it? I understand if this is a case of 'unsupported feature = not worth the time' but if it was a minor thing an update to this would be really great ^^.