Here’s how they work… (I’ve built a few)

Allow the program to create its own functions, based on mixing patterns of text which you input (this is the basis of the learning).
If the program did something you wanted, have a variable called “feelGood” that increments by one.
If the program did something you didn’t want, have a variable called “feelBad” that increments by one.
Have a function in your program that asks for your (the user’s) feedback and knows whether to increment “feelGood” or “feelBad” and keep track of what operations it did well and not so well.
Use a simple Hidden Markov Model algorithm to determine patterns and their “reasons”, and attempt functions that have the highest feelGood values.
If there are no satisfactory feelGood values, try to find the a better function using the Hidden Markov Model algorithm (and try to accomplish the determined “reason” via traditional computation) and receive input from the user to determine how this process is going (to save time… this is why we can feel defeat…).
Bam! A learning algorithm.
Have fun. It’s a little harder than it sounds, but you’ll be implementing it the whole time you’re trying to create it… and that can kinda be used as a guide.