Most, if not all, artificial intelligence [ AI ] is done by programming logic. Essentially a computer knows two states zero or one - one being true, zero being false.
For an object to respond to interactions, the programmer needs to anticipate all actions that could possible be performed on that object.
In your example, you would need two methods - one that determine if the object [dog] is being pet, and another to move the tail. The "is being pet" method will return a boolean value [either true or false] then you can use that value to create the logic:
Code:
if ( isBeingPet() ) {
wagTale();
}
So once you know how to make a tail wag and listen to events, making the AI is just a bunch of logic.
Bookmarks
Algorithms and Data Structures
Java tutorials
Algorithms Forum