Goal achieving logic


#1

First part of a long post that I made on Slack:

OK, that comes to the other idea that I wanted to discuss, regarding Mycroft’s architecture:
What you guys just did was offer various solutions to one problem. It doesn’t matter which one works best in this case, it matters that there are many ways to achieve same goal.
I think that Mycroft should be introduced to a concept of a “goal”, some sort of desired state, and the concept of a “way”, a chain of events that produces the desired state.
One of suggestions that I just got was "why don’t you use a tool that is commonly used to achieve what you currently want to achieve?"
Yes, that’s the best way for me currently. Instead of writing a script or making Mycroft skill from scratch, I can use Jenkins and be done with it.
But as I am lazy AF, I would still prefer that Mycroft does it for me.
Now, if I want Mycroft to achieve the goal I set, I have to teach it how to achieve it.
Will I make some wizard-level skill that does all the checking and compiling or will I teach Mycroft to use Jenkins?
OK, maybe bad example, since Jenkins is many times used to set up a process and forget about it.
Second example:
What if user wants Mycroft to increase the contrast of a picture.
Will we make Mycroft go trough the source data of the image and do some unoptimised math wizardry or will we teach it to use GIMP’s CLI functionality (the Script-Fu stuff)
Both ways should produce the same result, it just depends on the situation which of them is more efficient. If we have 20x20 px icon then unoptimized method would still take less time than starting GIMP, but if you have 500 MB image to process, it’s worth taking time to open GIMP or some other proper image manipulation tool to get the work done.

That’s why I think that once Mycroft grows more and gets more skills, it should know which of the possible solutions is best for user’s intent.
I’m talking some advanced Adapt here, which also calculates how appropriate the skill is, not just how well it matches intent’s keywords.

What are your thoughts on this?


#2

i’ve been thinking a bit about this, a first-tought about possible work flow:

  • ways would be the intent handling functions
  • goals could have multiple intents (“increase contrast with python” , “increase contrast with gimp”) and decision ruleset dummy function (choose random intent to execute by default, overrided when needed, in skill)
  • maybe associate a probability of choosing each intent for a goal
  • on error try other way until no ways left

so goals are in essence a intent disambiguation when multiple implementations are in place, but we can still use any intent independently and auto-fall back to backup when something fails

where in the code should this be implemented? i dont mind hacking a bit around in jarbas just to get/discard some ideas, its my coding playground after all

is this a good direction of tought at all?


#3

ok, ive been messing some more with this, dont think in this exact way it will make it into mycrof but here is my setup:

  • objectives -> a general “mission” for mycroft that can be attained trough various goals
  • goals -> different available ways to achieve to achieve a result
    -ways -> intents to be executed

a simple example

Objective : Troll
Goals to achieve objective: VideoTroll , WebsiteTroll, Sound Troll
Ways for videotroll:
SearchWebsiteIntent - search term 1
SearchWebsiteIntent - search term 2
SearchWebsiteIntent - search term 3
SearchWebsiteIntent - search term 4
Ways for websitetroll:
LaunchWebsiteIntent - troll website 1
LaunchWebsiteIntent - troll website 2
LaunchWebsiteIntent - troll website 3
LaunchWebsiteIntent - troll website 4
Ways for soundtroll:
PlaySoundIntent - annoying sound 1

objectives can be built with code or imported from a config file

I am implementing this in my freewill service, for example i have a word bank and i create a adquire knowedge objective that adds ways to search wikipedia for those words and save result on disk, i did the same for DreamAbout objective so my deepdream skill searches random pictures (from word bank combinatins search terms), this gives me a million search terms / dream_sources, i am currently refactoring my freewill to use only objectives instead of intents

currently goals and ways are both picked randomly, but a function over-riding choice method can be passed for different choice criteria for different objectives

example code:
https://github.com/JarbasAI/mycroft---objectives---goals---ways

I tried to avoid messing with core files, i think this can be implemented as a standalone skill for now, eventually some similar/or not aproach can make it into core


#4

i did some more work in this direction

skills can now register objectives almost the same has an intent would be registered with ObjectiveBuilder class

implementing a feedback skill

feedback skill adjusts probabilities for each way executing, so you can “train” mycroft to choosing the correct way trough reinforcement words

this is co-existing / dependent on regular intents, but skills can instead implement everything with objectives giving a larger degree of freedom

examples of training:

user - play chill playlist
mycroft - playing songX
user - awesome
mycroft - probability of choosing songX increased
mycroft - next chill songY playing
user - that was terrible
mycroft - probability of choosing songY decreased