LGames
Class Agent

java.lang.Object
  |
  +--LGames.Agent
Direct Known Subclasses:
CompositionalAgent2, HolisticAgent, HolisticAgent2

public abstract class Agent
extends java.lang.Object

The Agent class implements the agent's structure and behaviours. It is constructed, initialised and controlled from the thsim main class.

Copyright (c) 2004 Paul Vogt


Field Summary
protected  int age
           
protected  Context cxt
           
protected  int DG
           
protected  int dimension
           
protected  int id
           
protected  int nrDGSuccess
           
protected  int topic
           
protected  Meaning TOPIC
           
protected  int topicID
           
protected  Symbols utterance
           
 
Constructor Summary
Agent()
           
Agent(int n, int a, double e, double s)
          Constucts an agent with identity n
Agent(int n, int a, double e, double s, int m, int M)
           
 
Method Summary
abstract  void adaptLexiconHearer(Symbols u, int T, char type, char utype)
          Adaptation function for the hearer
abstract  void adaptLexiconSpeaker(Symbols u, int T, char type, char utype)
          Adaptation function for the speaker
protected  boolean context_member(int id)
          Function to check whether a category relates to an object in the context
protected abstract  void forget(char type)
          This function implements the search for elements that can be forgotten based on their effectiveness
protected abstract  void forget(char type, char rc, int n)
          This function implements the removal of categories or symbols in case of forgetting.
 int getAge()
          returns the age of the agent
 int getDim()
          Returns the dimensionality of the feature/conceptual space
 double getDS()
           
 double[] getFV()
          Returns the feature vector of the topic
abstract  java.lang.String getGame()
          Constructs a string that can be written to the logfile
 int getID()
          Returns the agent's id
 java.lang.String getLabels()
          Returns a string representation of the features that are selected.
 int getMaxLayer()
           
 java.lang.String getMeaning(java.lang.String word, char type)
          This function is used to find the meaning that best fits a given word.
 double[][] getMeanings(java.lang.String w, char t)
          This function returns a matrix representation for the meanings of word w and is used for the UI showLexicon
 int getTopic()
          Returns the integer value of the topic
 Meaning getTOPIC()
          Returns the pointer to the topic
 java.lang.String getUtterance()
          Returns the utterance produced by the speaker or interpreted by the hearer.
 java.lang.String[] getWords()
          This function returns a String array with all the words, used for the UI showLexicon
 void getWords(java.util.List bag)
          This function is used to produce a bag of words that are used by the entire population
 Symbols guess(Symbols u, char utype)
          This function processes the interpretation of the hearer for the guessing and selfish game.
abstract  Symbols hear(Symbols u, char type)
          This function processes the interpretation of the hearer for the observational game.
 void initDGame()
          Initialise the discrimination game.
 void initialise()
          Used to initialise some settings for testing
 void merge(int dim, char type)
          This function implements the merging of meanings.
abstract  void playDGame(char type, char uType, boolean adapt)
          This function lets the agent play a discrimination game
 void playDGame(char type, char uType, int layer, boolean adapt)
          This function lets the hierarchical agent play a discrimination game
 void playDGame(char type, char uType, int layer, int n, boolean adapt)
          This function lets the hierarchical agent play a discrimination game
 void print()
          Prints "AgentN", where N is the agent's id
 void print(java.io.PrintWriter outfile, char type)
          This function prints the ontology and lexicon of the agent to a file
 void printLexiconColumns(java.io.PrintWriter ofile, char type, int lg)
          prints the lexicon as in columns
 void printLexiconLatexTabel(java.io.PrintWriter ofile, char type, int lg)
          prints the lexicon as a table
 void printScore(java.io.PrintWriter outfile, char type, java.lang.String u, int lg)
          prints the scores of the lexical entry specified by u
 void setContext(Context C, double noise)
          Sets the context to C and adds noise
 void setTopic(int t)
          Sets the topic to the value t
abstract  Symbols speak(double probability, char type)
          This function produces an utterance for the speaker
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

protected int id

cxt

protected Context cxt

nrDGSuccess

protected int nrDGSuccess

DG

protected int DG

topic

protected int topic

utterance

protected Symbols utterance

TOPIC

protected Meaning TOPIC

topicID

protected int topicID

age

protected int age

dimension

protected int dimension
Constructor Detail

Agent

public Agent()

Agent

public Agent(int n,
             int a,
             double e,
             double s)
Constucts an agent with identity n

Parameters:
n - the identity of the agent
a - the agent's `birthdate' (i.e. language game nr.)
e - the standard learning rate eta
s - the learning rate eta for the speakers in case we wish to distinguish

Agent

public Agent(int n,
             int a,
             double e,
             double s,
             int m,
             int M)
Method Detail

initialise

public void initialise()
Used to initialise some settings for testing


setContext

public void setContext(Context C,
                       double noise)
Sets the context to C and adds noise

Parameters:
C - the context
noise - the perceptual noise

getTopic

public int getTopic()
Returns the integer value of the topic

Returns:
topic

setTopic

public void setTopic(int t)
Sets the topic to the value t

Parameters:
t - the topic number to be set

getFV

public double[] getFV()
Returns the feature vector of the topic


getTOPIC

public Meaning getTOPIC()
Returns the pointer to the topic

Returns:
TOPIC the whole meaning structure of the topic

getID

public int getID()
Returns the agent's id

Returns:
id the identity

getDim

public int getDim()
Returns the dimensionality of the feature/conceptual space

Returns:
dimension

getAge

public int getAge()
returns the age of the agent

Returns:
age

getUtterance

public java.lang.String getUtterance()
Returns the utterance produced by the speaker or interpreted by the hearer.

Returns:
null if no utterance is produced or interpreted

getLabels

public java.lang.String getLabels()
Returns a string representation of the features that are selected. These may include RGBSXY

See Also:
Context.getLabels()

forget

protected abstract void forget(char type,
                               char rc,
                               int n)
This function implements the removal of categories or symbols in case of forgetting.

Parameters:
type - type of the game that is being played
rc - indicates whether it concerns a category (o) or symbol (otherwise)
n - the index of the element to be removed

forget

protected abstract void forget(char type)
This function implements the search for elements that can be forgotten based on their effectiveness

Parameters:
type - type of game that is being played

speak

public abstract Symbols speak(double probability,
                              char type)
This function produces an utterance for the speaker

Parameters:
probability - The word-creation probability
type - The type of game being played ('s' - selfish game, 'g' - guessing game, 'o' - observational game)
Returns:
Symbols representation of the utterance

hear

public abstract Symbols hear(Symbols u,
                             char type)
This function processes the interpretation of the hearer for the observational game.

Parameters:
u - The Symbols representation of the speaker's utterance
Returns:
Symbols representation of the hearer's utterance (interpretatation)

guess

public Symbols guess(Symbols u,
                     char utype)
This function processes the interpretation of the hearer for the guessing and selfish game.

Parameters:
u - The Symbols representation of the speaker's utterance
Returns:
Symbols representation of the hearer's utterance (interpretatation)

context_member

protected boolean context_member(int id)
Function to check whether a category relates to an object in the context

Parameters:
id - ID of the category to be checked.
Returns:
true if category belongs to the context, false otherwise

adaptLexiconSpeaker

public abstract void adaptLexiconSpeaker(Symbols u,
                                         int T,
                                         char type,
                                         char utype)
Adaptation function for the speaker

Parameters:
u - utterance of the hearer
T - the topic
type - the type of game

adaptLexiconHearer

public abstract void adaptLexiconHearer(Symbols u,
                                        int T,
                                        char type,
                                        char utype)
Adaptation function for the hearer

Parameters:
u - utterance of the speaker
T - the topic
type - the type of game

playDGame

public abstract void playDGame(char type,
                               char uType,
                               boolean adapt)
This function lets the agent play a discrimination game

Parameters:
type - the type of game
uType - the type of update score- or usage-based
adapt - boolean to indicate whether or not to adapt the ontology

playDGame

public void playDGame(char type,
                      char uType,
                      int layer,
                      boolean adapt)
This function lets the hierarchical agent play a discrimination game

Parameters:
type - the type of game
uType - the type of update score- or usage-based
layer - the layer at which the game is played
adapt - boolean to indicate whether or not to adapt the ontology

playDGame

public void playDGame(char type,
                      char uType,
                      int layer,
                      int n,
                      boolean adapt)
This function lets the hierarchical agent play a discrimination game

Parameters:
type - the type of game
uType - the type of update score- or usage-based
layer - the layer at which the game is played
n - language game number
adapt - boolean to indicate whether or not to adapt the ontology

initDGame

public void initDGame()
Initialise the discrimination game. Sets in the context all categories to not distinctive. Required in hierarchical layered games.


getMaxLayer

public int getMaxLayer()
Returns:
maxLayer the maximum layer currently represented by the hierarchical agent

merge

public void merge(int dim,
                  char type)
This function implements the merging of meanings.


getDS

public double getDS()
Returns:
DS the level of discriminative success (0 failure, N for N successful games)

print

public void print()
Prints "AgentN", where N is the agent's id


getGame

public abstract java.lang.String getGame()
Constructs a string that can be written to the logfile


print

public void print(java.io.PrintWriter outfile,
                  char type)
This function prints the ontology and lexicon of the agent to a file

Parameters:
outfile - The file to which the data is written
type - the type of update (score- or usage-based)

printLexiconLatexTabel

public void printLexiconLatexTabel(java.io.PrintWriter ofile,
                                   char type,
                                   int lg)
prints the lexicon as a table

Parameters:
type - the type of update (score- or usage-based)
lg - the language game number

printLexiconColumns

public void printLexiconColumns(java.io.PrintWriter ofile,
                                char type,
                                int lg)
prints the lexicon as in columns

Parameters:
type - the type of update (score- or usage-based)
lg - the language game number

printScore

public void printScore(java.io.PrintWriter outfile,
                       char type,
                       java.lang.String u,
                       int lg)
prints the scores of the lexical entry specified by u

Parameters:
outfile - The file to which the data is written
type - the type of update (score- or usage-based)
u - the word of the lexical entry
lg - the language game number

getWords

public void getWords(java.util.List bag)
This function is used to produce a bag of words that are used by the entire population


getWords

public java.lang.String[] getWords()
This function returns a String array with all the words, used for the UI showLexicon


getMeaning

public java.lang.String getMeaning(java.lang.String word,
                                   char type)
This function is used to find the meaning that best fits a given word.


getMeanings

public double[][] getMeanings(java.lang.String w,
                              char t)
This function returns a matrix representation for the meanings of word w and is used for the UI showLexicon

Parameters:
w - the word
t - type of score-update