This document serves as the guide for writing source code for JaCaMo applications.

AgentSpeak (.asl)

Identifiers

For identifiers created in AgentSpeak and organisation (as goals, constants, variables, roles, missions), snake style is suggested. For instance: open_door (goal), My_Group (variable), bob (constant), professor (role), defense_group (group type).

to be discussed.

However, for identifiers created in Java (as observable properties and operations), the camel style is suggested. For instance: doorColor(blue), openDoor.

The word used for identifiers should be aligned with how human readers interpret them.

terms

terms in beliefs are used to identify objects, which may have predicates, may relate to others, or may be parameter for some actions, etc. So identifiers should help the reader to recognize the object. For instance:

  • door, as used in open(door)

  • bob, as used in happy(bob) or .send(bob,…​.)

beliefs

for the functor of beliefs, i.e., what precedes (, use words that are predicates. For instance:

  • warm(room), the predicate warm refers to a property of the object room. It is better than room(warm) or warming(room).

  • loves(bob,alice), the predicate refers to a relation loves between the two objects bob and alice.

  • warm, is a proposition, since there are no terms in this belief.

    Avoid, for instance bob(happy), where the term could be interpreted by the reader as a predicate and the predicate as an object.

declarative goals

use identifiers that are predicates. For instance:

  • !happy(bob), the agent intends a state of the world where bob has the predicate happy. Ideally, if the goal is achieved, then the agent believes in happy(bob).

  • !running(bob), the agent intends a state where bob is running

procedural goals

use identifiers that are verbs. For instance:

  • !run, the agent intends an activity (to run).

action

use verbs, the terms can be read as parameters in this case. For instance:

  • run

  • run("30min")

Example of plans:

+!happy(bob) : happy(bob). // my goal was already achieved
+!happy(bob)               // a declarative goal, a state is intended
    :  lonely(bob)         // alice believes that bob has predicate lonely
    <- .send(bob,tell,i_am_going_to_visit_you).
+!run(T)             // a procedural goal, the agent intends some activity
    :  sunny         // I believe that it is sunny
    <- goto(parc);   // do some action
       run(T).       // do some action

Plans

Regarding plans, simple plans should be written in a single line:

+raining : i_have_umbrella <- go.

A plan with multiple lines should follow the style:

+raining
    :  not i_have_umbrella
       & v(X) & X > 10
    <- doA;
       doB;
       .wait(something);
       !goal2.

Remarks:

  • : and <- are aligned, as well as not and doA (i.e., two spaces after :).

  • the first & is placed in the same line as v(X) & X > 10, so it makes it simples to comment out this condition.

The final . can also be place into a new line aligned with <-:

+raining
    :  not i_have_umbrella
       & v(X) & X > 10
    <- doA;
       doB;
       .wait(something);
       !some_goal;
    .

This simplifies commenting out the last line of the plan and can be seen as ending the body that started at <-. It is reminiscent of how { and } are aligned to mark the begin and end of block in some languages.

Comments

no rules for comments (?).

Artifacts

Since artifacts are written in Java, we recommend Google’s Java style guide.