Skip to content

Commit

Permalink
rename c4jason to jaca
Browse files Browse the repository at this point in the history
  • Loading branch information
jomifred committed Dec 6, 2016
1 parent 0aea9c5 commit 4512b9b
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 2,943 deletions.
20 changes: 11 additions & 9 deletions doc/tutorials/hello-bdi/code/Calendar.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import cartago.tools.GUIArtifact;

public class Calendar extends GUIArtifact {
Term[] days = {
Term[] days = {
ASSyntax.createAtom("sunday"),
ASSyntax.createAtom("monday"),
ASSyntax.createAtom("tuesday"),
Expand All @@ -24,18 +24,18 @@ public class Calendar extends GUIArtifact {
ASSyntax.createAtom("friday"),
ASSyntax.createAtom("saturday")
};


public void setup() {
defineObsProperty("today", days[0]);
initGUI();
}

JSlider s = new JSlider();

void initGUI() {
JFrame f = new JFrame("Calendar");

s.setMinimum(0);
s.setMaximum(6);
s.setPaintTicks(true);
Expand All @@ -51,23 +51,25 @@ void initGUI() {
lbs.put(6, new JLabel("S"));
s.setLabelTable(lbs);
linkChangeEventToOp(s, "updateDay");

f.add(s);
f.pack();
f.setVisible(true);
}


/*
protected void linkChangeEventToOp(JSlider source, String opName){
insertEventToOp(source,"stateChanged",opName);
source.addChangeListener((ChangeListener) getEventListenerInstance());
}

*/

@INTERNAL_OPERATION void updateDay(ChangeEvent ev) {
try {
ObsProperty prop = getObsProperty("today");
prop.updateValue(days[ (int)s.getValue() ]);
} catch (Exception e2) {
e2.printStackTrace();
}
}
}
}
11 changes: 5 additions & 6 deletions doc/tutorials/hello-bdi/code/bdi_hw.mas2j
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/* Jason Project */

MAS bdi_hw {
environment: c4jason.CartagoEnvironment

agents:
bob agentArchClass c4jason.CAgentArch;
alice agentArchClass c4jason.CAgentArch;
environment: jaca.CartagoEnvironment

}
agents:
bob agentArchClass jaca.CAgentArch;
alice agentArchClass jaca.CAgentArch;

}
3 changes: 1 addition & 2 deletions doc/tutorials/hello-bdi/code/bob.asl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ sincere(alice).

+!say(X) : today(friday) <- .print(X,"!!!!!"); .wait(500); !say(X).
+!say(X) : not today(monday) <- .print(X); .wait(math.random(400)+100); !say(X).
+!say(X) <- !say(X).
+!say(X) <- !say(X).

+today(wednesday) <- .print("**** Let's slow down.... **** (only 2 intentions)"); !enter_lazy_mode.
+today(friday) <- .print("**** Let's finish the work!"); !resume_all.
Expand All @@ -31,4 +31,3 @@ sincere(alice).
<- .resume(say(_));
!resume_all.
+!resume_all.

19 changes: 10 additions & 9 deletions doc/tutorials/hello-bdi/readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,11 @@ a|
MAS bdi_hw {
// CArtAgO environment
environment: c4jason.CartagoEnvironment
environment: jaca.CartagoEnvironment
// Agent architecture for CArtAgO
agents:
bob agentArchClass c4jason.CAgentArch;
bob agentArchClass jaca.CAgentArch;
}
--------------------------

Expand Down Expand Up @@ -292,7 +292,7 @@ with failure, since the agent has a desire without a suitable plan.
The following program for Bob includes alternative plans for the events
`+happy(H)` and `+!say(X)`.

----------------------------------------------------------------------------------------
-----
sincere(alice).
!create_calendar.
Expand All @@ -303,8 +303,8 @@ sincere(alice).
+!say(X) : today(friday) <- .print(X,"!!!!!"); .wait(math.random(400)+100); !say(X).
+!say(X) : not today(monday) <- .print(X); .wait(math.random(400)+100); !say(X).
+!say(X) <- !say(X).
----------------------------------------------------------------------------------------
+!say(X) <- !say(X).
-----

For each event, *one* plan is selected according to the context: the
first plan with a context that holds is selected to create the intention
Expand All @@ -316,9 +316,9 @@ of `happy(H)` is sincere
is true if the value of `H` is the name of the agent executing that
internal action). The second plan is used otherwise. The first plan for
`+!say(X)` is used in days other than Monday and the second on Fridays.
(Notice that there is a plan for Mondays that does not actually say anything
(Notice that there is a plan for Mondays that does not actually say anything
but just keeps the intention alive. Without it Bob would find no plan for
`say(X)` on Monday and the intention for `say(X)` would not be re-added. Bob
`say(X)` on Monday and the intention for `say(X)` would not be re-added. Bob
would have to remain mute ever after.)

Instead of using REPL, we will add a new agent, called Alice, to run
Expand Down Expand Up @@ -404,7 +404,7 @@ be suspended.
2. On Fridays, suspended intentions are resumed.
3. On Saturdays, all intentions are dropped.

------------------------------------------------------------------------------------------------
-----
sincere(alice).
!create_calendar.
Expand All @@ -419,6 +419,7 @@ sincere(alice).
+!say(X) : today(friday) <- .print(X,"!!!!!"); .wait(500); !say(X).
+!say(X) : not today(monday) <- .print(X); .wait(math.random(400)+100); !say(X).
+!say(X) <- !say(X).
/**** the following is NEW ****/
Expand All @@ -438,7 +439,7 @@ sincere(alice).
<- .resume(say(_));
!resume_all.
+!resume_all.
------------------------------------------------------------------------------------------------
-----

(You can refer to the
http://jason.sourceforge.net/api/jason/stdlib/package-summary.html#package.description[Jason
Expand Down
Loading

0 comments on commit 4512b9b

Please sign in to comment.