Jadex Tutorial Exercise B1

Anonymous
2011-11-19
2013-06-12

  • Anonymous
    2011-11-19

    why here he can accept only  == Null or !=null :(


    if(gword!=null)   // if(gword==eword)  doest not work ????
                      // if(gword==null)  it works alos,

    {
    System.out.println("Translating from English to German: "+eword+" - "+gword);
    }
    else.
    ,,,…………..

    anyone can help me????

     
  • Hi,

    I'm not sure if I understand your question.
    The B1 tutorial agent looks up the german word (gword) for an english word (eword) in its beliefs.
    When there exists a translation for the english word, then the german word exists (gword!=null)
    and is printed to the console.

    Why do you want to check if the english word and the german word are the same string (eword==gword).
    This does not make any sense to me.

    Hope this helps.

    Cheers,
    Alex

     

  • Anonymous
    2011-12-02

    thank u Alex ,

    it is nice from u,

    I would like to do array

    String Eng = new String {"Cat", "Dog", "Book"};
    String Ger= new String {"Katze", "Hund", "Buch"};

    String eword = (String)me.getParameter(SFipa.CONTENT).getValue();
                                     // for Example  user will enter Cat

    I have to look for it in array in Eng,
    if it is exist, then retrung me the postion

    int pos = -1;
    for ( int x = 0; x < array.lenght; x++)
    if ( eword ==  Eng)
    pos=x;

    if (x==-1)

    system,out.print("ther german word is "+ Ger);
    else
    system,out.print("the german word is not in Database);

    i mean another way,  but i got error

    just try

    int a= 2;

    ind x=2;

    if( a==x)
    system,out,print( "it works") ;

    i tried many times to avoid null , which is above but I get error

     

  • Anonymous
    2011-12-02

    sorry,

    i wanted to write
    (if x!=-1)
    ….

     
  • Ibo
    Ibo
    2011-12-03


    hier there is alternative for match <Match>

    can u explain the code match , and can we do it in another way,
    I found alternative in tutorial, can u explain

    Match element and how can I use it,is there is documention, how to use all elements ADF

     
  • Lars Braubach
    Lars Braubach
    2011-12-12

    Hi,

    in Java you cannot compare Strings for equality using ==. You need to use equals().

    Best

    Lars

     
  • Ibo
    Ibo
    2011-12-12

    thank u very much,
    now I got it
    :)

     
  • Lars Braubach
    Lars Braubach
    2011-12-12

    &amp; is just the XML symbol (entity) for &. & cannot be used in XML directly.
    Please have a look at XML entities.

    Best
    Lars

     
  • Ibo
    Ibo
    2011-12-12

    can u explain the Match in XML

    and where can i learn this language (ADF) is there any book

     
  • Ibo
    Ibo
    2011-12-12

    thank u very much Lars,

    but why I can not get answers quickly,

    i like this langauge JADEX and I wana improve myself , and I need more help, so I post a question and I get answer after 1 month or like this and this gives me Hopeless

    thank you again Lars :)

     
  • Lars Braubach
    Lars Braubach
    2011-12-12

    Matching incoming messages to defined message templates within an agent is done by comparing the constant parameter values AND the match expression. So if you cannot express it with fixed parameter values can always can use the match expression, but of course you are not forced to use it.

    Best
    Lars

     
  • Lars Braubach
    Lars Braubach
    2011-12-12

    in Jadex there are 2 similar XML languages:

    - the expression language for all kinds of expressions such as the match expression. It is plain Java with additional predefined variables that can directly be used. Details are here
    http://jadex-agents.informatik.uni-hamburg.de/xwiki/bin/view/BDI+User+Guide/10+Expressions

    - the condition language wich is Java like and must be used in all conditions such as e.g. goal condition.

    Best
    Lars

     
  • Lars Braubach
    Lars Braubach
    2011-12-12

    … sorry, we try to answer asap but sometime we are too busy. We have the general policy to answer all questions at least in a couple of days. Just keep asking if you urgently need help ;-)

    Lars

     
  • Ibo
    Ibo
    2011-12-12

    thank you very much Lars, now I am happy, i can continue to learn it, u give me encouragement,