Iam Library

From AI Wiki

Jump to: navigation, search

Contents

Iam Framework behaviors

Before going on to describe the behaviors in the Iam Library, let's introduce a few behaviors that are so standard that they are actually in the IamFramework JAR.

NullBehavior

This is a behavior that does absolutely nothing. Completely useless then, you might think. But it actually comes in quite handy if you want to temporarily switch of certain behaviors for a large group of Iams while debugging them.

NavigatingBehavior

Any behavior that wants to use the built-in path-finding algorithm for moving around should sub-class this behavior.

TargetingBehavior

Many behaviors will try to target a certain other avatar or player and direct their actions towards this entity. This is achieved by sub-classing this behavior, which is a sub-class of NavigatingBehavior. When it receives a command like "follow" or "target me" it will 'target' the entity that just said that. When it receives 'target <name>' it will target the entity with that name. TargetingBehavior is an abstract class that requires sub-classes to implement the method setTarget(String targetId) which is the method that will be called whenever a target is selected. TargetingBehavior has two special attributes:

  • leaderName is the name of the entity it listens to. If left empty it will listen to anyone.
  • focalPoint is a Location object that can be used to make the Iam face a certain direction. Like focusing on its target.

Iam Library behaviors

Below there's a list of all the behaviors currently in the Iam Library, including a brief description of what the behavior does and what attributes can be used to configure them. All these behaviors are member of the package com.avatar_reality.blue_mars.iam.behavior.implementations.

AvoidingBehavior

Whenever the Iam finds itself at the same location as another avatar, it will step aside in a random direction. This part is identical to EvadingBehavior. Furthermore it will anticipate when another avatar is moving towards it and step aside to avoid a collision. This behavior has not attributes.

ChatLBehavior

This behavior uses a .chatl file to pass to a ChatProcessor (as discussed on the Natural Language Processing page) and use it to reply to things said to it. It only reacts to avatars speaking within a 5 meter radius. And it has an interval in which it will spontaneously say something from its collection of gambit rules. So there are two attributes:

  • chatLFile indicating which CHAT-L file to use.
  • phraseInterval is the interval in which it will spontaneously say something (in seconds)

Generally, the reply by the ChatProcessor will be handled by the default reply() method. You have to make a sub-class to allow custom functions to be called. In that case you should be aware that you can also override two methods called handleNoMatch() which is called if no CHAT-L rule matched the input, and handleError() which will be called in case of an unexpected error.

EchoBehavior

This behavior echoes whatever any other avatar says, like in the example in the introduction. Not a very useful behavior in itself, but it occasionally comes in handy for testing.

EvadingBehavior

Whenever the Iam finds itself at the same location as another avatar, it will step aside in a random direction. See also AvoidingBehavior.

FollowingBehavior

This is a sub-class of the TargetingBehavior mentioned above. If it has a target, it will follow it around. It has two attributes

  • minimumDistance is the minimum distance that it will keep from its target.
  • maximumDistance is the maximum distance between it and its target that will cause it to move closer.

So if you set these to 2 and 5 respectively, the Iam will initially move to within 2 meters of its target. But it will not track every little move of its target and only move again when the target moves away more than 5 meters.

InteractingBehavior

This is a simple behavior that will automatically accept any request for an interaction.

InteractionDenialBehavior

Does the opposite of InteractingBehavior and automatically refuses any request for interactions.

MimicBehavior

Another sub-class of TargetingBehavior that will mimic anything said or done by the target. (It only mimics animations and things said, not movements.)

SurveyingBehavior

This class was explained in the section about moving and maps. It will observe other player's avatars and deduce the surroundings from their movements and build a map-file.

SittingBehavior

Can be used indirectly by another behavior to make an Iam sit in a chair and animate while sitting. See Sitting.

WanderingBehavior

This behavior will pick a random location on its map and navigate there. After it walked to its destination, it will rest for an equal amount of time that it was walking.

XMLScriptBehavior

This behavior reads an XML file containing lists of phrases and / or animations or combinations of phrases and animations. Every so often it will randomly pick one from the list and say the phrase, perform an animation or both. Below is what the script looked like for the notorious groupies once roaming Beach City:

<AvatarActions>
	<Animation animationName="AR_BlowKissOneHand-01"/>
	<Animation animationName="AR_BlowKissTwoHands-01"/>
	<Animation animationName="AR_CatchBlownKiss-01"/>
	<Animation animationName="AR_Clap-01"/>
	<Animation animationName="AR_ClapWild-01"/>
	<Animation animationName="AR_ClapWild-01"/>
	<Animation animationName="AR_ClapWild-01"/>
	<Animation animationName="AR_Dance-01"/>
	<Animation animationName="AR_Dance-02"/>
	<Animation animationName="AR_Dance-03"/>
	<Animation animationName="AR_Gasp-01"/>
	<Animation animationName="AR_Giggle-01"/>
	<Animation animationName="AR_Smile-01"/>
	<Animation animationName="AR_SmileTiltHead-01"/>
	<Animation animationName="AR_Wave-01"/>
	<Animation animationName="AR_WaveSmall-01"/>
	<Phrase text="Oh! There he is!"/>
	<Phrase text="You’re a Star!"/>
	<Phrase text="Wow!"/>
	<Phrase text="OMG!"/>
	<Phrase text="Sooo good-looking..."/>
	<Phrase text="Oh my!"/>
	<Phrase text="Hehehe"/>
	<Phrase text="Woo-hoo"/>
	<Phrase text="%3c3"/>
	<Phrase text="I %3c3 you!"/>
	<Phrase text="Oh look!"/>
	<Phrase text="I like your style."/>
	<Phrase text="You rock!"/>
</AvatarActions>
Personal tools