United Kingdom
Asked — Edited

Artificial Intelligence

Hoping this will spark a huge discussion on what everyone is looking for when it comes to their robot's AI.

AI is something I've been working on since before I even learned of EZ-Robots. My JARVIS replica from IronMan is coming up to being 3 years old come December and, while not started in ARC, over the last few months I've been porting parts over to ARC and those which are beyond the capabilities of ARC are integrated via Telnet. These include such things as voice controlled media playback, voice activated control of appliances, lights etc. and, well to be honest, far more than I can really explain right now.

Basically, up until now it is entirely built around home automation and automated media acquisition, storage, playback and logging. Recently I have been integrating and porting over parts of it in to ARC and where ARC is not capable of carrying out the actions, integration via Telnet so that ARC (and it's scripts) are aware of everything they need to be aware of (i.e. if media playback starts, EventGhost sends ARC a script command $mediaplayback = 1, when it's finished it sends $mediaplayback = 0 (that's a very simple example, it also sends more info on the media). This will be demonstrated soon by Melvin when I get around to making the video of him knowing what's on TV.

Like I said, so far it's mainly based around Media and Home Automation. What I want to discuss is...

What do you want in your robot's AI?

What do you want him/her to be able to do without human interaction? What do you want him/her to react or respond to? What do you want the AI to enhance? Why do you want AI?

And, for anyone who already has some kind of AI running; What does your AI add to your robot?

Hopefully this will spark up some interesting conversation, get some ideas out there, inspire others (and myself) to push on with the AI and make robots more intelligent:)


ARC Pro

Upgrade to ARC Pro

Synthiam ARC Pro is a new tool that will help unleash your creativity with programming robots in just seconds!

#113  

Well, looking through the code , I don't see how this would work. But, I will trust you on that. I would like the arduino info file. I guess from looking at it, it is an arduino "c" file. I have removed the happy faces and replaced them with ")" bracket.

I think this method still applies but, if we could find a reasonable "Fuzzy Logic" algorithm it might work better.

Thank You on this.

Mel

#114  

Ooops post the wrong code snippet... Corrected above... Now the code works perfectly Mel... As mentioned it will need to be ported and tweaked to use in ARC and in individual projects... The code above is written for the Arduino.... It is a decent "learning" algorithm that has many uses in our robotics....

#115  

That is a LOT of converting/porting. For some reason (maybe I need medical intervention?) it sounds like a fun project to port it over and apply the basic functions in ARC. I'm starting to port it. Anyone else want to help?

#116  

This type of AI is call a Knowledge base, first publicly known as a program called Animals. Where the computer would guess the animal you were thinking of. I know this is not the same application but it is using Decent Knowledge base flow.

If you are wanting to make a port you may want to search for a program called Animals , it has been ported to almost every language known to man.

and you will have more references to base your port on.

#117  

I didn't draw the conclusion that its a Knowledge Base type of program. I use knowledge base type logic at work often and I consider it more structurally similar to IF/THEN where you front load information. Or like an Expert System.

For example, if I recall the Animals program (the one I remember seeing an example of) asked questions like "Does the Animal have 4 legs?". Depending on the answer y/n it would then pose a follow up questions and each time narrow down the list of possible animals from a given list.

Can you explain what you see in the code that makes it appear like a knowledge base?

#118  

First stab at a port to ARC. It's not finished!

My questions for the next steps are what to replace the Serial.Print in/out with and I'm not sure what to replace "RETURN" with. Looks like Return might be used as a print command? And then the gcd function Ardiuno, Greatest Common Divisor...not sure what to use there.

Last Updated 9/5/14


# Interactive AI program based on a variable structure stochastic learning automaton (VSLA)
# http:scholar.lib.vt.edu/theses/available/etd-5414132139711101/unrestricted/ch3.pdf
# include <Entropy.h> http:forum.arduino.cc/index.php/topic,108380.0.html  
# Originally Written by Markus Bindhammer, 2013 for Arduino 
#
# Ported to EZ-Robot Script by Justin Ratliff (and other EZ-Robot Forum Members) 2014

#************ Global variables ************
$beta = "0"          #variable for the environment input
$randomnumber = "0"  #variable for generated random number
$t_1 = "0"  	     #define initial denominators and numerators of probability value for action alpha_1
$y_1 = "0"  
$t_2 = "0"           #define initial denominators and numerators of probability value for action alpha_2
$y_2 = "0"  
$t_3 = "0"           #define initial denominators and numerators of probability value for action alpha_3
$y_3 = "0"  
$t_4 = "0"           #define initial denominators and numerators of probability value for action alpha_4
$y_4 = "0"  
$p_total = "0"       #sum of all probabilities
$p_1 = "0"           #probabilities as floating-point numbers
$p_2 = "0" 
$p_3 = "0" 
$p_4 = "0"  
$euclid = "0"        #variable for the gcd (greatest common divisor)

#************ Global constants ************
$u = "1.0" #numerator of learning parameter. u must be a natural number >0
$v = "2.0" #denominator of learning parameter. v must be a natural number >0
$a = ABS($u / $v) #define learning parameter a as a fraction of u and v. a must be >0 and <1
$r = "4"   #number of desired actions

:setup 
 #Entropy.Initialize() 
 #initialize random function - need to re-write the above line for a random function process
  $t_1 = "1.0"       #define initial denominators and numerators of probability values
  $t_2 = "1.0"
  $t_3 = "1.0"
  $t_4 = "1.0"
  $y_1 = "4.0"
  $y_2 = "4.0"
  $y_3 = "4.0"
  $y_4 = "4.0"

:loop 
#===== Calculating results =====
  $p_1 = ABS($t_1 / $y_1)
  $p_2 = ABS($t_2 / $y_2)
  $p_3 = ABS($t_3 / $y_3)
  $p_4 = ABS($t_4 / $y_4)
  $p_total = ABS($t_1 / $y_1 + $t_2 / $y_2 + $t_3 / $y_3 + $t_4 / $y_4)
  
#===== Printing results =====
  PRINT("current probability values:")
   #old example PRINT($p_1, 4)
   #ardiuno example of why ,4 is in there to show the decimal spot 4 spaces
   #Example: Serial.println(1.23456, 4) would print "1.2346" 
   #ARC can do this with the ROUND() command 
  $szp_1 = Round($p_1, 4)
  $szp_2 = Round($p_2, 4)
  $szp_3 = Round($p_3, 4)
  $szp_4 = Round($p_4, 4)
  PRINT("p_1 = " + $szp_1) 
  PRINT("p_2 = " + $szp_2) 
  PRINT("p_3 = " + $szp_3) 
  PRINT("p_4 = " + $szp_4) 
  PRINT("________________") 
  PRINT("p_total = " + $p_total)  
  PRINT(" ") 
  
#===== Choice algorithm =====
#selection sorting algorithm
 #not sure about this array setup
 $maxprob($p_1, $p_2, $p_3, $p_4, 3) #create according array
          #the number '3' must be always kept in the array to prevent wrong ranking in case probabilities are equal to 0
  $temp = ""
  $mini = ""  #variable used to hold the assumed minimum element
  $i = ""
  $j = ""
 RepeatWhile($i=0 $i < $r $i++)  #outer FOR loop
    $mini = $i #first pass of FOR loop assumes 0th element as minimum, second pass assumes 1st element as minimum and so on
    RepeatWhile($j=0 $j < $r $j++)  #inner FOR loop
      IF($maxprob[$mini] > $maxprob[$j]) #compares the minimum element with all, other members using inner FOR loop
        $temp=$maxprob[$j]             #exchanges the elements   
        $maxprob[$j] = $maxprob[$mini]
        $maxprob[$mini] = $temp
        ENDIF
 EndRepeatWhile
    EndRepeatWhile
      
    
   
  $k = "0"   #identIFier which action was chosen
 RepeatWhile($i = 0 $i < $r i++) 
    IF ($maxprob[$i] == $p_1 && $maxprob[$i+1] != $p_1) 
      $randomnumber = $Entropy.random(1, $y_1 + 1)
      ENDIF
      IF ($randomnumber <= $t_1) 
        PRINT("action alpha_1 chosen")
        PRINT(" ")
        $k=1
        ENDIF
 EndRepeatWhile
     
    IF ($maxprob[$i] == $p_2 && $maxprob [$i + 1] != $p_2)
       $randomnumber = $Entropy.random(1, $y_2 + 1)
       ENDIF
       IF ($randomnumber <= $t_2)
         PRINT("action alpha_2 chosen")
         PRINT(" ")
         $k=2
         ENDIF
      
    IF ($maxprob[$i] == $p_3 && $maxprob [$i + 1] != $p_3) 
      $randomnumber = $Entropy.random(1, $y_3 + 1)
      ENDIF
      IF ($randomnumber <= $t_3) 
        PRINT("action alpha_3 chosen")
        PRINT(" ")
        $k=3
        ENDIF
       
     IF ($maxprob [$i] == $p_4 && $maxprob [$i + 1] != $p_4)
      $randomnumber = $Entropy.random(1, $y_4 + 1)
      ENDIF
      IF ($randomnumber <= $t_4)
        PRINT("action alpha_4 chosen")
        PRINT(" ")
        $k=4
        ENDIF
      
     # Add here statements from p_5 to p_... IF desired
  
  RepeatWhile($k == 0)
      IF($maxprob [$r - 1] == $p_1)
      PRINT("action alpha_1 chosen")
      PRINT(" ")
      $k=1
     elseIF ($maxprob [$r - 1] == $p_2)
       PRINT("action alpha_2 chosen")
       PRINT(" ")
       $k=2
     elseIF ($maxprob [$r  -1] == $p_3)
       PRINT("action alpha_3 chosen")
       PRINT(" ")
       $k=3
     else
       $maxprob [$r - 1] == $p_4
       PRINT("action alpha_4 chosen")
       PRINT(" ")
       $k=4
       ENDIF
 EndRepeatWhile

     # Add here statements from p_5 to p_... IF desired
  

#===== Input from environment =====
  PRINT(please decide IF chosen action was favorable or unfavorable) #instructions for the user
  PRINT(send 0 IF action was favorable)
  PRINT(send 1 IF action was unfavorable)
  PRINT(" ")

 :check_input     #check input from serial monitor. IF input is not equal to 0 or 1, go back to 'check_input' label
                  #Serial.read needs to be replaced with a scripted input for testing
 $ser = "function to wait for input"
  IF($ser == "0") 
     $beta = "0"
     PRINT(b = 0, action was favorable)
     PRINT(" ")
  elseIF($ser == "1") 
     $beta = "1"
     PRINT(b = 1, action was unfavorable)
     PRINT(" ")
  else 
    goto(check_input)
  ENDIF
  

#===== Updating rule T =====
#updating rule for probability action alpha_1 
  IF ($k == "1" && $beta == "0")
      $t_1 = ABS(($v * $t_1) + ($u * ($y_1 - $t_1))) #according updating rule when action alpha_1 was chosen and beta=0 (j=i)
      $y_1 = ABS($v * $y_1)
  ENDIF
  IF ($k == "1" && $beta == "1")
      $t_1 = ABS(t_1 * ($v - $u)) #according updating rule when action alpha_1 was chosen and beta=1 (j=i)
      $y_1 = ABS($v * $y_1)
  ENDIF
  IF ($k! = "1" && $beta == "0")
      $t_1 = ABS($t_1 * ($v - $u)) #according updating rule when action alpha_1 was not chosen and beta=0 (j?i)
      $y_1 = ABS($v * $y_1)
  ENDIF
  IF ($k! = "1" && $beta == "1")
      $t_1 = ABS(($y_1 * $u) + ($t_1 * ($r - 1) * ($v - $u))) #according updating rule when action alpha_1 was not chosen and beta=1 (j?i)
      $y_1 = ABS($y_1 * $v * ($r - 1))
  ENDIF
  
#updating rule for probability action alpha_2 
  IF ($k == "2" && $beta == "0")
      $t_2 = ABS(($v * $t_2) + ($u * ($y_2 - $t_2))) #according updating rule when action alpha_2 was chosen and beta=0 (j=i)
      $y_2 = ABS($v * $y_2)
  ENDIF
  IF ($k == "2" && $beta == "1")
      $t_2 = ABS($t_2 * ($v - $u)) #according updating rule when action alpha_2 was chosen and beta=1 (j=i)
      $y_2 = ABS($v * $y_2)
  ENDIF
  IF ($k! = "2" && $beta == "0")
      $t_2 = ABS($t_2 * ($v - $u)) #according updating rule when action alpha_2 was not chosen and beta=0 (j?i)
      $y_2 = ABS($v * $y_2)
  ENDIF
  IF ($k! = "2" && $beta == "1")
      $t_2 = ABS(($y_2 * $u) + ($t_2 * ($r - 1) * ($v - $u))) #according updating rule when action alpha_2 was not chosen and beta=1 (j?i)
      $y_2 = ABS($y_2 * $v* ($r - 1))
  ENDIF
  
#updating rule for probability action alpha_3 
  IF ($k == "3" && $beta == "0")
      $t_3 = ABS(($v * t_3) + ($u * ($y_3 - $t_3))) #according updating rule when action alpha_3 was chosen and beta=0 (j=i)
      $y_3 = ABS($v * $y_3)
  ENDIF
  IF ($k == "3" && $beta == "1")
      $t_3 = ABS($t_3 * ($v - $u)) #according updating rule when action alpha_3 was chosen and beta=1 (j=i)
      $y_3 = ABS($v * $y_3)
  ENDIF
  IF ($k! ="3" && $beta == "0")
      $t_3 = ABS($t_3 * ($v - $u)) #according updating rule when action alpha_3 was not chosen and beta=0 (j?i)
      $y_3 = ABS($v * $y_3)
  ENDIF
  IF ($k! = "3" && $beta == "1")
      $t_3 = ABS(($y_3 * $u) + ($t_3 * ($r - 1) * ($v - $u))) #according updating rule when action alpha_3 was not chosen and beta=1 (j?i)
      $y_3 = ABS($y_3 * $v * ($r - 1))
  ENDIF
 
#updating rule for probability action alpha_4 
  IF ($k == "4" && $beta == "0")
      $t_4 = ABS(($v * $t_4) + ($u * ($y_4 - $t_4))) #according updating rule when action alpha_4 was chosen and beta=0 (j=i)
      $y_4 = ABS($v * $y_4)
  ENDIF
  IF ($k == "4" && $beta == "1")
      $t_4 = ABS($t_4 * ($v - $u)) #according updating rule when action alpha_4 was chosen and beta=1 (j=i)
      $y_4 = ABS($v * $y_4)
  ENDIF
  IF ($k! = "4" && $beta == "0")
      $t_4 = ABS($t_4 * ($v - $u)) #according updating rule when action alpha_4 was not chosen and beta=0 (j?i)
      $y_4 = ABS($v * $y_4)
  ENDIF
  IF ($k! = "4" && $beta == "1")
      $t_4 = ABS(($y_4 * $u) + ($t_4 * ($r - 1) *($v - $u))) #according updating rule when action alpha_4 was not chosen and beta=1 (j?i)
      $y_4 = ABS($y_4 * $v * ($r - 1))
  ENDIF

  # Add here statements from p_5 to p_... IF desired

#===== gcd calculation ======
 $euclid = (gcd($y_1, $t_1)) #find greatest common divisor (gcd) and devide denominators and numerators by gcd to reduce fraction
  $y_1 = ABS($y_1 / $euclid)
  $t_1 = ABS($t_1 / $euclid)
 $euclid = (gcd($y_2, $t_2)) 
  $y_2 = ABS($y_2 / $euclid)
  $t_2 = ABS($t_2 / $euclid)
 $euclid = (gcd($y_3, $t_3)) 
  $y_3 = ABS($y_3 / $euclid)
  $t_3 = ABS($t_3 / $euclid)
 $euclid = (gcd($y_4, $t_4)) 
  $y_4 = ABS($y_4 / $euclid)
  $t_4 = ABS($t_4 / $euclid)

  # Add here statements from p_5 to p_... IF desired

#************ Functions ************
#===== Euclidean algorithm ======
#need a function to find greatest common divisor
#Need a function for this - gcd($a, $b)
  IF ($b == "0")
    #return a
    PRINT(a)
  ENDIF
  IF ($b == "1")
    #return 1
    PRINT(1)
  #return gcd(b, a % b)
  PRINT $gcd($b, $a % $b)
  ENDIF
#119  

Wow Justin, you got some serious patience.... I am glad you're attempting it though... If you have an arduino, try it out... or if you get it ported and try it.... I can see a real use for a basic learning algorithm...

#120  

Just learned Serial.print is like ARC Print. Serial.println does the same, but adds a carriage return. Serial.read is meant to read in data on the serial port...I'm going to chuck that and replicate input via script to virtually represent incoming data. So that's not so awful.

Some of the math is a little if-e right now. The part I'm pondering is "gcd" which should not be a variable like I have it listed. It appears to be a math function in the Arduino to find the Greatest Common Divisor. I could probably use some help tackling how to do that.