Your question is very broad and very vague. Actually, you ask two questions.
1) Is there a way to make an AI system that learns from your actions?
To the first one, the answer is obviously "yes". Let's figure out a hangman game: the AI could figure out what letters you tend to pick frequently and choose words that have few of these letters, just to annoy you. In other words, it learns from you.
This is of course a pretty simple example but still a very valid one. It is actually the simplest model, making counts/statistics about the player's behavior and then applying a counter-action accordingly.
Then, there are all kind of more advanced models, machine learning techniques, neural networks, etc.
2) Is there a way to make a program that writes it own code according to your actions as a player?
Actually, there is no need to write code to adapt to a player's actions. Most of the time, everything in the game boils down to a set of choices and numbers. You can represent the player's location, it's direction, speed, playing cards, whatever, using numbers. So basically, it's just some data crunching which will throw out a number to tell what the AI opponent should do.
Edited by creatures-of-gaia.com, 24 February 2014 - 10:44 AM.