You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
(35) |
Apr
(96) |
May
(39) |
Jun
(25) |
Jul
(7) |
Aug
(7) |
Sep
(44) |
Oct
(17) |
Nov
(14) |
Dec
(9) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(5) |
Feb
(28) |
Mar
(26) |
Apr
(14) |
May
(3) |
Jun
(3) |
Jul
(13) |
Aug
(41) |
Sep
(12) |
Oct
|
Nov
(2) |
Dec
(17) |
2010 |
Jan
(9) |
Feb
(5) |
Mar
(11) |
Apr
(3) |
May
(4) |
Jun
(2) |
Jul
(3) |
Aug
(8) |
Sep
(2) |
Oct
(11) |
Nov
(3) |
Dec
(1) |
2011 |
Jan
|
Feb
(1) |
Mar
(8) |
Apr
(4) |
May
(4) |
Jun
(5) |
Jul
(3) |
Aug
(2) |
Sep
(7) |
Oct
(4) |
Nov
(4) |
Dec
(2) |
2012 |
Jan
|
Feb
|
Mar
(4) |
Apr
(11) |
May
(8) |
Jun
(2) |
Jul
(7) |
Aug
(6) |
Sep
(2) |
Oct
(2) |
Nov
|
Dec
(3) |
2013 |
Jan
|
Feb
(1) |
Mar
(7) |
Apr
(3) |
May
(1) |
Jun
(4) |
Jul
(8) |
Aug
(4) |
Sep
(4) |
Oct
(6) |
Nov
(8) |
Dec
(6) |
2014 |
Jan
|
Feb
|
Mar
(2) |
Apr
(4) |
May
(6) |
Jun
(10) |
Jul
|
Aug
(7) |
Sep
(15) |
Oct
(4) |
Nov
(1) |
Dec
(1) |
2015 |
Jan
|
Feb
(1) |
Mar
(10) |
Apr
(4) |
May
(6) |
Jun
(1) |
Jul
|
Aug
(2) |
Sep
(2) |
Oct
(5) |
Nov
(6) |
Dec
(12) |
2016 |
Jan
(1) |
Feb
(4) |
Mar
(7) |
Apr
(30) |
May
(5) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <jom...@us...> - 2015-05-25 12:41:57
|
Revision: 1840 http://sourceforge.net/p/jason/svn/1840 Author: jomifred Date: 2015-05-25 12:41:56 +0000 (Mon, 25 May 2015) Log Message: ----------- update jars Modified Paths: -------------- trunk/lib/jacamo.jar trunk/lib/moise.jar Modified: trunk/lib/jacamo.jar =================================================================== (Binary files differ) Modified: trunk/lib/moise.jar =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2015-05-24 22:46:09
|
Revision: 1839 http://sourceforge.net/p/jason/svn/1839 Author: jomifred Date: 2015-05-24 22:46:07 +0000 (Sun, 24 May 2015) Log Message: ----------- idem Modified Paths: -------------- trunk/demos/tell-rule/receiver.asl trunk/doc/mini-tutorial/src/hello-bdi/Makefile trunk/doc/mini-tutorial/src/hello-bdi/code/Calendar.java trunk/doc/mini-tutorial/src/hello-bdi/code/alice.asl trunk/doc/mini-tutorial/src/hello-bdi/code/bdi_hw.mas2j trunk/src/jason/asSyntax/Rule.java trunk/src/jason/bb/DefaultBeliefBase.java trunk/src/jason/jeditplugin/Config.java trunk/src/jason/stdlib/asserta.java trunk/src/jason/stdlib/assertz.java trunk/src/test/BeliefBaseTest.java trunk/src/test/RuleTest.java Modified: trunk/demos/tell-rule/receiver.asl =================================================================== --- trunk/demos/tell-rule/receiver.asl 2015-05-24 22:35:21 UTC (rev 1838) +++ trunk/demos/tell-rule/receiver.asl 2015-05-24 22:46:07 UTC (rev 1839) @@ -14,7 +14,7 @@ +!kqml_received(A,tellRule,Rules,_) <- .print("Received rule(s) ",Rules, " from ",A); for ( .member(R, Rules) ) { - +R[source(A)]; + +R[source(A)]; } // get all rules and print them .relevant_rules(_,LR); Modified: trunk/doc/mini-tutorial/src/hello-bdi/Makefile =================================================================== --- trunk/doc/mini-tutorial/src/hello-bdi/Makefile 2015-05-24 22:35:21 UTC (rev 1838) +++ trunk/doc/mini-tutorial/src/hello-bdi/Makefile 2015-05-24 22:46:07 UTC (rev 1839) @@ -6,6 +6,7 @@ cp index.html ../../hello-bdi cp jcm.css ../../hello-bdi cp -R screens ../../hello-bdi + cp -R code ../../hello-bdi publish: scp index.html jomifred,ja...@we...:/home/groups/j/ja/jason/htdocs/mini-tutorial/hello-bdi Modified: trunk/doc/mini-tutorial/src/hello-bdi/code/Calendar.java =================================================================== --- trunk/doc/mini-tutorial/src/hello-bdi/code/Calendar.java 2015-05-24 22:35:21 UTC (rev 1838) +++ trunk/doc/mini-tutorial/src/hello-bdi/code/Calendar.java 2015-05-24 22:46:07 UTC (rev 1839) @@ -14,55 +14,55 @@ import cartago.tools.GUIArtifact; public class Calendar extends GUIArtifact { - Term[] days = { - ASSyntax.createAtom("sunday"), - ASSyntax.createAtom("monday"), - ASSyntax.createAtom("tuesday"), - ASSyntax.createAtom("wednesday"), - ASSyntax.createAtom("thursday"), - ASSyntax.createAtom("friday"), - ASSyntax.createAtom("saturday") - }; - - - public void setup() { - defineObsProperty("today", days[0]); - initGUI(); - } + Term[] days = { + ASSyntax.createAtom("sunday"), + ASSyntax.createAtom("monday"), + ASSyntax.createAtom("tuesday"), + ASSyntax.createAtom("wednesday"), + ASSyntax.createAtom("thursday"), + 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); - s.setPaintLabels(true); - s.setValue(0); - Dictionary<Integer, JLabel> lbs = new Hashtable<Integer, JLabel>(); - lbs.put(0, new JLabel("S")); - lbs.put(1, new JLabel("M")); - lbs.put(2, new JLabel("T")); - lbs.put(3, new JLabel("W")); - lbs.put(4, new JLabel("T")); - lbs.put(5, new JLabel("F")); - lbs.put(6, new JLabel("S")); - s.setLabelTable(lbs); - linkChangeEventToOp(s, "updateDay"); - - f.add(s); - f.pack(); - f.setVisible(true); - } - - @INTERNAL_OPERATION void updateDay(ChangeEvent ev) { - try { - ObsProperty prop = getObsProperty("today"); - prop.updateValue(days[ (int)s.getValue() ]); - } catch (Exception e2) { - e2.printStackTrace(); - } - } + JSlider s = new JSlider(); + + void initGUI() { + JFrame f = new JFrame("Calendar"); + + s.setMinimum(0); + s.setMaximum(6); + s.setPaintTicks(true); + s.setPaintLabels(true); + s.setValue(0); + Dictionary<Integer, JLabel> lbs = new Hashtable<Integer, JLabel>(); + lbs.put(0, new JLabel("S")); + lbs.put(1, new JLabel("M")); + lbs.put(2, new JLabel("T")); + lbs.put(3, new JLabel("W")); + lbs.put(4, new JLabel("T")); + lbs.put(5, new JLabel("F")); + lbs.put(6, new JLabel("S")); + s.setLabelTable(lbs); + linkChangeEventToOp(s, "updateDay"); + + f.add(s); + f.pack(); + f.setVisible(true); + } + + @INTERNAL_OPERATION void updateDay(ChangeEvent ev) { + try { + ObsProperty prop = getObsProperty("today"); + prop.updateValue(days[ (int)s.getValue() ]); + } catch (Exception e2) { + e2.printStackTrace(); + } + } } Modified: trunk/doc/mini-tutorial/src/hello-bdi/code/alice.asl =================================================================== --- trunk/doc/mini-tutorial/src/hello-bdi/code/alice.asl 2015-05-24 22:35:21 UTC (rev 1838) +++ trunk/doc/mini-tutorial/src/hello-bdi/code/alice.asl 2015-05-24 22:46:07 UTC (rev 1839) @@ -3,18 +3,18 @@ +!start <- .send(bob,tell,happy(bob)); .send(bob,tell,happy(alice1)); - .send(bob,tell,happy(alice2)); - .send(bob,tell,happy(alice3)); - .send(bob,tell,happy(alice4)); - .wait(1000); - .send(bob,tell,happy(morgana)); - .wait(1000); - /*.send(bob,tell,today(wednesday)); - .wait(3000); - .send(bob,tell,today(friday)); - .wait(3000); - .send(bob,tell,today(saturday)); - */ - //.send(bob,untell,happy(bob)); - .wait(1000); - .send(bob,untell,happy(alice)). + .send(bob,tell,happy(alice2)); + .send(bob,tell,happy(alice3)); + .send(bob,tell,happy(alice4)); + .wait(1000); + .send(bob,tell,happy(morgana)); + .wait(1000); + /*.send(bob,tell,today(wednesday)); + .wait(3000); + .send(bob,tell,today(friday)); + .wait(3000); + .send(bob,tell,today(saturday)); + */ + //.send(bob,untell,happy(bob)); + .wait(1000); + .send(bob,untell,happy(alice)). Modified: trunk/doc/mini-tutorial/src/hello-bdi/code/bdi_hw.mas2j =================================================================== --- trunk/doc/mini-tutorial/src/hello-bdi/code/bdi_hw.mas2j 2015-05-24 22:35:21 UTC (rev 1838) +++ trunk/doc/mini-tutorial/src/hello-bdi/code/bdi_hw.mas2j 2015-05-24 22:46:07 UTC (rev 1839) @@ -1,10 +1,10 @@ /* Jason Project */ MAS bdi_hw { - infrastructure: JaCaMo - + infrastructure: JaCaMo + agents: - bob; + bob; alice; } Modified: trunk/src/jason/asSyntax/Rule.java =================================================================== --- trunk/src/jason/asSyntax/Rule.java 2015-05-24 22:35:21 UTC (rev 1838) +++ trunk/src/jason/asSyntax/Rule.java 2015-05-24 22:46:07 UTC (rev 1839) @@ -73,20 +73,20 @@ @Override public boolean isAtom() { - return false; + return false; } @Override public boolean isGround() { - return false; + return false; } public void setAsTerm(boolean b) { - isTerm = b; + isTerm = b; } public boolean isTerm() { - return isTerm; + return isTerm; } @Override @@ -136,10 +136,10 @@ } public String toString() { - if (isTerm()) + if (isTerm()) return "{ " + super.toString() + " :- " + body + " }"; - else - return super.toString() + " :- " + body; + else + return super.toString() + " :- " + body; } @Override Modified: trunk/src/jason/bb/DefaultBeliefBase.java =================================================================== --- trunk/src/jason/bb/DefaultBeliefBase.java 2015-05-24 22:35:21 UTC (rev 1838) +++ trunk/src/jason/bb/DefaultBeliefBase.java 2015-05-24 22:46:07 UTC (rev 1839) @@ -320,9 +320,9 @@ public void add(Literal l, boolean addInEnd) { map.put(new LiteralWrapper(l), l); if (addInEnd) { - list.addLast(l); + list.addLast(l); } else { - list.addFirst(l); + list.addFirst(l); } } Modified: trunk/src/jason/jeditplugin/Config.java =================================================================== --- trunk/src/jason/jeditplugin/Config.java 2015-05-24 22:35:21 UTC (rev 1838) +++ trunk/src/jason/jeditplugin/Config.java 2015-05-24 22:46:07 UTC (rev 1839) @@ -356,7 +356,7 @@ } if (getProperty(SHORT_UNNAMED_VARS) == null) { - put(SHORT_UNNAMED_VARS,"true"); + put(SHORT_UNNAMED_VARS,"true"); } if (getProperty(KQML_RECEIVED_FUNCTOR) == null) { Modified: trunk/src/jason/stdlib/asserta.java =================================================================== --- trunk/src/jason/stdlib/asserta.java 2015-05-24 22:35:21 UTC (rev 1838) +++ trunk/src/jason/stdlib/asserta.java 2015-05-24 22:46:07 UTC (rev 1839) @@ -57,8 +57,8 @@ @Override protected void checkArguments(Term[] args) throws JasonException { super.checkArguments(args); // check number of arguments if (!args[0].isLiteral()) - if (!args[0].isGround() && !args[0].isRule()) - throw JasonException.createWrongArgument(this,"first argument must be a ground literal (or rule)."); + if (!args[0].isGround() && !args[0].isRule()) + throw JasonException.createWrongArgument(this,"first argument must be a ground literal (or rule)."); } @Override public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception { Modified: trunk/src/jason/stdlib/assertz.java =================================================================== --- trunk/src/jason/stdlib/assertz.java 2015-05-24 22:35:21 UTC (rev 1838) +++ trunk/src/jason/stdlib/assertz.java 2015-05-24 22:46:07 UTC (rev 1839) @@ -57,8 +57,8 @@ @Override protected void checkArguments(Term[] args) throws JasonException { super.checkArguments(args); // check number of arguments if (!args[0].isLiteral()) - if (!args[0].isGround() && !args[0].isRule()) - throw JasonException.createWrongArgument(this,"first argument must be a ground literal (or rule)."); + if (!args[0].isGround() && !args[0].isRule()) + throw JasonException.createWrongArgument(this,"first argument must be a ground literal (or rule)."); } @Override public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception { Modified: trunk/src/test/BeliefBaseTest.java =================================================================== --- trunk/src/test/BeliefBaseTest.java 2015-05-24 22:35:21 UTC (rev 1838) +++ trunk/src/test/BeliefBaseTest.java 2015-05-24 22:46:07 UTC (rev 1839) @@ -180,7 +180,7 @@ while (itl.hasNext()) { Literal l = itl.next(); if (l.getFunctor().startsWith("testRemIt")) { - itl.remove(); + itl.remove(); } } assertEquals(iteratorSize(bb.getPercepts()), 0); Modified: trunk/src/test/RuleTest.java =================================================================== --- trunk/src/test/RuleTest.java 2015-05-24 22:35:21 UTC (rev 1838) +++ trunk/src/test/RuleTest.java 2015-05-24 22:46:07 UTC (rev 1839) @@ -153,14 +153,14 @@ } public void testAsTerm() throws ParseException { - Term t = ASSyntax.parseTerm("{p :- a & b | c}"); - assertEquals("{ p :- ((a & b) | c) }", t.toString()); - t = ASSyntax.parsePlan("+!test4 <- +{ v :- p & v(2,12) }; !test4a."); - assertEquals("+!test4 <- +{ v :- (p & v(2,12)) }; !test4a.", t.toString()); - t = ASSyntax.parsePlan("+!test4 <- +{ +!g : v <- .print(ok) }; !test4a."); - assertEquals("+!test4 <- .add_plan({ +!g : v <- .print(ok) },self,begin); !test4a.", t.toString()); - t = ASSyntax.parsePlan("+!test4 <- +>{ +!g : v <- .print(ok) }; !test4a."); - assertEquals("+!test4 <- .add_plan({ +!g : v <- .print(ok) },self,end); !test4a.", t.toString()); + Term t = ASSyntax.parseTerm("{p :- a & b | c}"); + assertEquals("{ p :- ((a & b) | c) }", t.toString()); + t = ASSyntax.parsePlan("+!test4 <- +{ v :- p & v(2,12) }; !test4a."); + assertEquals("+!test4 <- +{ v :- (p & v(2,12)) }; !test4a.", t.toString()); + t = ASSyntax.parsePlan("+!test4 <- +{ +!g : v <- .print(ok) }; !test4a."); + assertEquals("+!test4 <- .add_plan({ +!g : v <- .print(ok) },self,begin); !test4a.", t.toString()); + t = ASSyntax.parsePlan("+!test4 <- +>{ +!g : v <- .print(ok) }; !test4a."); + assertEquals("+!test4 <- .add_plan({ +!g : v <- .print(ok) },self,end); !test4a.", t.toString()); } @SuppressWarnings("unchecked") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2015-05-24 22:35:23
|
Revision: 1838 http://sourceforge.net/p/jason/svn/1838 Author: jomifred Date: 2015-05-24 22:35:21 +0000 (Sun, 24 May 2015) Log Message: ----------- add missing files in publish task Modified Paths: -------------- trunk/doc/mini-tutorial/src/hello-bdi/Makefile Modified: trunk/doc/mini-tutorial/src/hello-bdi/Makefile =================================================================== --- trunk/doc/mini-tutorial/src/hello-bdi/Makefile 2015-05-24 22:32:07 UTC (rev 1837) +++ trunk/doc/mini-tutorial/src/hello-bdi/Makefile 2015-05-24 22:35:21 UTC (rev 1838) @@ -11,3 +11,4 @@ scp index.html jomifred,ja...@we...:/home/groups/j/ja/jason/htdocs/mini-tutorial/hello-bdi scp jcm.css jomifred,ja...@we...:/home/groups/j/ja/jason/htdocs/mini-tutorial/hello-bdi scp -r screens jomifred,ja...@we...:/home/groups/j/ja/jason/htdocs/mini-tutorial/hello-bdi + scp -r code jomifred,ja...@we...:/home/groups/j/ja/jason/htdocs/mini-tutorial/hello-bdi This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2015-05-24 22:32:10
|
Revision: 1837 http://sourceforge.net/p/jason/svn/1837 Author: jomifred Date: 2015-05-24 22:32:07 +0000 (Sun, 24 May 2015) Log Message: ----------- add new tutorial (BDI hello world) Modified Paths: -------------- trunk/doc/index.html trunk/examples/cleaning-robots/logging.properties trunk/src/jason/runtime/MASConsoleColorGUI.java trunk/src/jason/runtime/MASConsoleGUI.java Added Paths: ----------- trunk/doc/mini-tutorial/src/hello-bdi/ trunk/doc/mini-tutorial/src/hello-bdi/Makefile trunk/doc/mini-tutorial/src/hello-bdi/code/ trunk/doc/mini-tutorial/src/hello-bdi/code/Calendar.java trunk/doc/mini-tutorial/src/hello-bdi/code/alice.asl trunk/doc/mini-tutorial/src/hello-bdi/code/bdi_hw.mas2j trunk/doc/mini-tutorial/src/hello-bdi/code/bob.asl trunk/doc/mini-tutorial/src/hello-bdi/index.html trunk/doc/mini-tutorial/src/hello-bdi/index.org trunk/doc/mini-tutorial/src/hello-bdi/jcm.css trunk/doc/mini-tutorial/src/hello-bdi/screens/ trunk/doc/mini-tutorial/src/hello-bdi/screens/mind-1.png trunk/doc/mini-tutorial/src/hello-bdi/screens/mind-2.png Modified: trunk/doc/index.html =================================================================== --- trunk/doc/index.html 2015-05-19 16:58:56 UTC (rev 1836) +++ trunk/doc/index.html 2015-05-24 22:32:07 UTC (rev 1837) @@ -12,7 +12,8 @@ <li><a href="Jason.pdf">First Manual</a> (pdf)</li><br/> <li><a href="mini-tutorial/getting-started/index.html">Getting Started with <b><i>Jason</i></b></a> (html)</li> -<li><a href="mini-tutorial/jason-jade/index.html">Interoperating <b><i>Jason</i></b> and JADE</a> (mini-tutorial -- html)</li><br> +<li><a href="mini-tutorial/jason-jade/index.html">Interoperating <b><i>Jason</i></b> and JADE</a> (mini-tutorial -- html)</li> +<li><a href="mini-tutorial/hello-bdi/index.html">BDI concepts in <b><i>Jason</i></b></a> (html)</li><br> <li><a href="faq.html">FAQ</a> (html)</li><br/> Added: trunk/doc/mini-tutorial/src/hello-bdi/Makefile =================================================================== --- trunk/doc/mini-tutorial/src/hello-bdi/Makefile (rev 0) +++ trunk/doc/mini-tutorial/src/hello-bdi/Makefile 2015-05-24 22:32:07 UTC (rev 1837) @@ -0,0 +1,13 @@ +# +# by Jomi +# + +all: + cp index.html ../../hello-bdi + cp jcm.css ../../hello-bdi + cp -R screens ../../hello-bdi + +publish: + scp index.html jomifred,ja...@we...:/home/groups/j/ja/jason/htdocs/mini-tutorial/hello-bdi + scp jcm.css jomifred,ja...@we...:/home/groups/j/ja/jason/htdocs/mini-tutorial/hello-bdi + scp -r screens jomifred,ja...@we...:/home/groups/j/ja/jason/htdocs/mini-tutorial/hello-bdi Property changes on: trunk/doc/mini-tutorial/src/hello-bdi/Makefile ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: trunk/doc/mini-tutorial/src/hello-bdi/code/Calendar.java =================================================================== --- trunk/doc/mini-tutorial/src/hello-bdi/code/Calendar.java (rev 0) +++ trunk/doc/mini-tutorial/src/hello-bdi/code/Calendar.java 2015-05-24 22:32:07 UTC (rev 1837) @@ -0,0 +1,68 @@ +import jason.asSyntax.ASSyntax; +import jason.asSyntax.Term; + +import java.util.Dictionary; +import java.util.Hashtable; + +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JSlider; +import javax.swing.event.ChangeEvent; + +import cartago.INTERNAL_OPERATION; +import cartago.ObsProperty; +import cartago.tools.GUIArtifact; + +public class Calendar extends GUIArtifact { + Term[] days = { + ASSyntax.createAtom("sunday"), + ASSyntax.createAtom("monday"), + ASSyntax.createAtom("tuesday"), + ASSyntax.createAtom("wednesday"), + ASSyntax.createAtom("thursday"), + 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); + s.setPaintLabels(true); + s.setValue(0); + Dictionary<Integer, JLabel> lbs = new Hashtable<Integer, JLabel>(); + lbs.put(0, new JLabel("S")); + lbs.put(1, new JLabel("M")); + lbs.put(2, new JLabel("T")); + lbs.put(3, new JLabel("W")); + lbs.put(4, new JLabel("T")); + lbs.put(5, new JLabel("F")); + lbs.put(6, new JLabel("S")); + s.setLabelTable(lbs); + linkChangeEventToOp(s, "updateDay"); + + f.add(s); + f.pack(); + f.setVisible(true); + } + + @INTERNAL_OPERATION void updateDay(ChangeEvent ev) { + try { + ObsProperty prop = getObsProperty("today"); + prop.updateValue(days[ (int)s.getValue() ]); + } catch (Exception e2) { + e2.printStackTrace(); + } + } +} + Added: trunk/doc/mini-tutorial/src/hello-bdi/code/alice.asl =================================================================== --- trunk/doc/mini-tutorial/src/hello-bdi/code/alice.asl (rev 0) +++ trunk/doc/mini-tutorial/src/hello-bdi/code/alice.asl 2015-05-24 22:32:07 UTC (rev 1837) @@ -0,0 +1,20 @@ +!start. + ++!start + <- .send(bob,tell,happy(bob)); + .send(bob,tell,happy(alice1)); + .send(bob,tell,happy(alice2)); + .send(bob,tell,happy(alice3)); + .send(bob,tell,happy(alice4)); + .wait(1000); + .send(bob,tell,happy(morgana)); + .wait(1000); + /*.send(bob,tell,today(wednesday)); + .wait(3000); + .send(bob,tell,today(friday)); + .wait(3000); + .send(bob,tell,today(saturday)); + */ + //.send(bob,untell,happy(bob)); + .wait(1000); + .send(bob,untell,happy(alice)). Property changes on: trunk/doc/mini-tutorial/src/hello-bdi/code/alice.asl ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: trunk/doc/mini-tutorial/src/hello-bdi/code/bdi_hw.mas2j =================================================================== --- trunk/doc/mini-tutorial/src/hello-bdi/code/bdi_hw.mas2j (rev 0) +++ trunk/doc/mini-tutorial/src/hello-bdi/code/bdi_hw.mas2j 2015-05-24 22:32:07 UTC (rev 1837) @@ -0,0 +1,11 @@ +/* Jason Project */ + +MAS bdi_hw { + infrastructure: JaCaMo + + agents: + bob; + alice; + +} + Property changes on: trunk/doc/mini-tutorial/src/hello-bdi/code/bdi_hw.mas2j ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: trunk/doc/mini-tutorial/src/hello-bdi/code/bob.asl =================================================================== --- trunk/doc/mini-tutorial/src/hello-bdi/code/bob.asl (rev 0) +++ trunk/doc/mini-tutorial/src/hello-bdi/code/bob.asl 2015-05-24 22:32:07 UTC (rev 1837) @@ -0,0 +1,33 @@ +sincere(alice). + +!create_calendar. ++!create_calendar <- makeArtifact("c","Calendar",[],AId); focus(AId). + ++happy(H)[source(A)] : sincere(A)[source(self)] & .my_name(H) <- !say(hello(A)). ++happy(H) : not .my_name(H) <- !say(i_envy(H)). + +-happy(H)[source(A)] + <- .drop_intention(say(hello(A))); + .drop_intention(say(i_envy(H))). + ++!say(X) : today(friday) <- .print(X,"!!!!!"); .wait(500); !say(X). ++!say(X) : not today(monday) <- .print(X); .wait(math.random(400)+100); !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. ++today(saturday) <- .print("**** weekend!"); .drop_all_intentions. + ++!enter_lazy_mode + : .findall(A, .intend(say(A)), [_,_|L]) // the agent has two say intentions + <- for ( .member(I,L) ) { + .suspend(say(I)); + }. ++!enter_lazy_mode. + + ++!resume_all + : .count( .intend(A) & .suspended(A,R) & .substring("suspended",R), I) & I > 0 + <- .resume(say(_)); + !resume_all. ++!resume_all. + Property changes on: trunk/doc/mini-tutorial/src/hello-bdi/code/bob.asl ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: trunk/doc/mini-tutorial/src/hello-bdi/index.html =================================================================== (Binary files differ) Index: trunk/doc/mini-tutorial/src/hello-bdi/index.html =================================================================== --- trunk/doc/mini-tutorial/src/hello-bdi/index.html 2015-05-19 16:58:56 UTC (rev 1836) +++ trunk/doc/mini-tutorial/src/hello-bdi/index.html 2015-05-24 22:32:07 UTC (rev 1837) Property changes on: trunk/doc/mini-tutorial/src/hello-bdi/index.html ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/xml \ No newline at end of property Added: trunk/doc/mini-tutorial/src/hello-bdi/index.org =================================================================== --- trunk/doc/mini-tutorial/src/hello-bdi/index.org (rev 0) +++ trunk/doc/mini-tutorial/src/hello-bdi/index.org 2015-05-24 22:32:07 UTC (rev 1837) @@ -0,0 +1,300 @@ +#+TITLE: (BDI) Hello World +#+AUTHOR: Jomi F. Hubner (with Rafael H. Bordini assistance) +#+EMAIL: jom...@gm... +#+DATE: 2015 + +#+DESCRIPTION: +#+KEYWORDS: +#+LANGUAGE: pt +#+OPTIONS: email:t H:2 toc:2 num:nil author:t \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t +#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:t pri:nil tags:nil +#+STYLE: <link rel="stylesheet" type="text/css" href="./jcm.css" /> + +* Introduction + +This programming (mini) tutorial will illustrate how the BDI model is used in the [[http://jason.sf.net][Jason]] agent-oriented programming language. We start by a very simple agent code and progress exploring the BDI features of Jason. + +We assume that the reader knows the basic concepts of the BDI model (an introduction and further references are found at the [[http://en.wikipedia.org/wiki/Belief–desire–intention_software_model][Wikipedia]]). It is important to know these concepts to be a good Jason programmer, in the same way that knowing the concepts of and objects and classes is important for a Java programmer. Very briefly, in the BDI model the agent has /beliefs/ (based on what it perceives and communicates with other agents) that can produce /desires/ (states of the world that the agent wants to achieve). The agent /deliberates/ on its desires and decides to /commit/ to some (desires to which the agent is committed become /intentions/). The satisfy its intentions, the agent executes plans that lead to action. The behaviour of the agent (i.e., its actions) is thus explained/caused by what it intends (i.e., the desires it decided to pursue). An important feature of the model is that the agent should /react/ to changes in its environment as soon as possible while keeping its /pro-active/ (i.e., desires-oriented) behaviour. (Do not worry about all these high-level anthropomorphic concepts (in italics), we will try to keep the simplicity of usual hello world programs.) + +* Bob (the mentalist) + +** the agent program + +The Jason program for our agent is the following (since BDI is inspired in folk psychology, we can name this agent Bob): + +#+begin_src prolog +happy(bob). + +!say(hello). + ++!say(X) : happy(bob) <- .print(X). +#+end_src + +As we can see, the syntax is far from the usual C, Java, or Python programs we are used to. For those (rare) guys who have had some contact with Prolog, maybe it looks a bit familiar. The syntax is indeed inspired by Prolog, but the objective is different (the output is not knowledge and the underlying engine is not based on resolution). Let's read this program: + +1. The agent has one (initial) belief: =happy(bob)=, included by the programmer (rather than by perceiving the state of the environment). This belief can be read as ``the domain element named =bob= has the property (or predicate) =happy=". +2. The agent has one (initial) desire: =!say(hello)=, also included by the programmer. What follows the symbol =!= describes the desire and is also represented as a Prolog literal. +3. The agent has one plan to achieve the desire =say(hello)=. We can read this plan as ``whenever the agent has the desire to =say(X)= and believes that =happy(bob)=, by executing the action =.print(X)= the desire is achieved, for any =X= (which is a variable since it starts with an uppercase letter, as in Prolog). + +The /deliberation/ process of the BDI model is highly related to plans. The plan states /whether/ a desire can become an intention by means of its /event/ and /context/. In the Bob's plan, the event is =+!say(X)= (what is written before =:=) and it means the event of having a new desire to say something. The context is =happy(bob)= (the part of the code that goes between =:= and =<-=) which is a logical formula evaluated in regards to the current believes of the agent. + +The plan also states /how/ to achieve the desire (i.e. the /means-end/ reasoning part of the BDI model). If the sequence of actions (after =<-=) is successfully executed, the desire is (hopefully) achieved. An intention in Jason is an instantiated plan that the agent is executing in order to achieve a desire (also called goal). + +This program is interpreted by Jason as follows: + +1. The initial belief is added in the agent belief base (BB). +2. From the initial desire, the event =+!say(hello)= is added in the queue of events to be handled by the agent. +3. The plan is included in the plan library (PL) of the agent. +4. A reasoning cycle loop is executed: + - The event =+!say(hello)= is selected from the queue. + - The above plan is selected (it matches the selected event when the variable =X= is bound to =hello=). + - The context of the plan is evaluated as true since it follows from be BB (i.e. the agent believes =happy(bob)=). + - A new intention is created based on this plan and the =X= value. The agent has thus committed itself to the desire to =say(hello)=. + - One action of the intention is executed (the =.print(hello)= command in this case). + - Since the intention has executed all actions, it finishes. +5. The agent keeps waiting for new events to react to. + + +** execution + +- Create a new Jason project (you can use either [[http://jason.sourceforge.net/mini-tutorial/getting-started/][jEdit]] or [[http://jason.sourceforge.net/mini-tutorial/eclipse-plugin/][Eclipse]] plugins). + +- Create agent Bob with the source code above. The .mas2j project should look like: + +: MAS bdi_hw { +: +: agents: bob; +: +: } + +- Run the project. + +* Bob (the believer) + +The second version of agent Bob has neither initial beliefs nor desires: + +#+begin_src prolog ++happy(bob) <- !say(hello). ++!say(X) : not today(monday) <- .print(X); .wait(500); !say(X). +#+end_src + +The first plan has a different kind of event: the agent has started to believe something (the belief that follows =+=). So when the agent starts believing that Bob is happy, the desire to say hello (=!say(hello)=) is created. In this case, the desire is the result of changes in the agent's beliefs. The agent starts believing something when, for instance, it perceives the state of the environment or receives a message from another agent. + +The second plan has also changed: (i) the agent will decide to pursue the desire to say something on days other than Monday; (ii) after printing the message, the desire is keept, producing a loop that will end on the next Monday. In other words, the intention to achieve =!say= does not finish because that intention itself creates a new desire =!say= (here also conveniently called sub-goal). Only when this sub-goal is achieved, the intention finishes (which never happens in the above plan). + +If you run this program, nothing happens! Different from other languages where the programmer defines a sequence of operations, in Jason the programmer /declares/ plans and the order of execution depends on the order of the events that take place on a particular environment. + +To interact with Bob, we will create another agent at runtime and inform them about some facts. + +1. Run the project. +2. In the MAS Console, click on the button "New REPL agent" and fill "alice" as the name of the new agent. +3. In the Alice interface, enter =.send(bob,tell,happy(bob))=. +4. You will notice that Bob starts saying hello. + +The /tell/ message that Alice sent to Bob is automatically interpreted by Jason. The default interpretation, since it is a "tell" message, is to include the content of the message (=happy(bob)=) in the Bob's belief base. When that belief is added in the belief base, the event =+happy(bob)= is included in the queue of events. Bob then reacts to this event creating an intention. You can access the [[http://localhost:3272][Jason Mind Inspector]] to see the Bob's mental state (or use the Debug button in the MAS Console): + +#+ATTR_HTML: width=500 style="center;margin:0px 20px 20px 20px;" +[[./screens/mind-1.png]] + +As we can see, the belief is not exactly =happy(bob)= but =happy(bob)[source(alice)]=. The part enclosed by =[= and =]= are annotations. All beliefs in Jason have annotations for their sources. This information can be used, for instance, if an agent needs to consider only those beliefs that come from trustable sources: + +#+begin_src prolog +sincere(alice). + ++happy(bob)[source(A)] : sincere(A) <- !say(hello). + ++!say(X) : not today(monday) <- .print(X); .wait(500); !say(X). +#+end_src + +This program has a problem, however. Another malicious agent can tell Bob that it is sincere just before telling him =happy(bob)=! The source of the =sincere= belief should be Bob itself (and not another agent): + +#+begin_src prolog +sincere(alice). + ++happy(bob)[source(A)] : sincere(A)[source(self)] <- !say(hello). + ++!say(X) : not today(monday) <- .print(X); .wait(500); !say(X). +#+end_src + +** perception + +Besides messages from other agents, another source for beliefs is perception. We will place a calendar in the environment so that Bob can be aware of the current day. It is not the focus of this tutorial to develop the environment, so we will simply copy & paste some code: + +- change the .mas2j to: + +#+begin_src masj2 +MAS bdi_hw { + infrastructure: JaCaMo + + agents: bob; +} +#+end_src + +- Download [[./code/Calendar.java][this]] file and place it in the directory of the project. + +- In the beginning of Bob's program, add the following lines that create the Calendar in the environment: +#+begin_src prolog +!create_calendar. ++!create_calendar <- makeArtifact("c","Calendar",[],AId); focus(AId). +#+end_src + +- Run the project and interactively change the current day observing Bob's belief base and intentions. For example, if you change the day to Monday, the intention will finish. In this case, the intention finishes with failure, since the agent has a desire without a suitable plan. + +* Bob (the vigilant) + +The following program for Bob includes alternative plans for the events =+happy(H)= and =+!say(X)=. + +#+begin_src prolog +sincere(alice). + +!create_calendar. ++!create_calendar <- makeArtifact("c","Calendar",[],AId); focus(AId). + ++happy(H)[source(A)] : sincere(A)[source(self)] & .my_name(H) <- !say(hello(A)). ++happy(H) : not .my_name(H) <- !say(i_envy(H)). + ++!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). +#+end_src + +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 to react to the event. + +The first plan for =+happy(H)= is used when =H= is =bob= and the +source of =happy(H)= is sincere ([[http://jason.sourceforge.net/api/jason/stdlib/my_name.html][=.my\_name=]] 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 are no plans for Mondays!) + +Instead of using REPL, we will add a new agent, called Alice, to run +this system: +#+begin_src prolog +!start. + ++!start + <- .send(bob,tell,happy(bob)); + .send(bob,tell,happy(alice)); + .wait(2000); + .send(bob,tell,happy(morgana)). +#+end_src + +It is important to notice how many intentions Bob has: + +#+ATTR_HTML: width=500 style="center;margin:0px 20px 20px 20px;" +[[./screens/mind-2.png]] + +Bob is concurrently executing three intentions: one for each +event. More importantly, even with 3 intentions (or 100 intentions) +Bob promptly reacts to new events. This /reactivity/ is indeed one of +the nicer features of the BDI model. You can test it by creating a new +REPL agent that sends tell messages to Bob and see how fast it +reacts. + +To really stress Bob, we can change Alice's program as follows: +#+begin_src prolog +!start. + ++!start + <- .send(bob,tell,happy(bob)); + .send(bob,tell,happy(alice)); + .wait(2000); + .send(bob,tell,happy(morgana)); + for (.range(I,1,100)) { + .send(bob,tell,happy(I)); + }. +#+end_src + +At this point of the tutorial, you could try to imagine how to program +this application using conventional languages like Java and C. Even +actor-based langages, which are also oriented to events and great +tools for concurrency, will not be so reactive as Jason. + +* Bob (the revisionist) + +Another important feature of the BDI model is that agents are able to +revise their own intentions. The following plan reacts to the event of +stop believing that someone is happy. The reaction is to drop the +corresponding intention. + +#+begin_src prolog +// new plan in Bob's program: + +-happy(H)[source(A)] + <- .drop_intention(say(hello(A))); + .drop_intention(say(i_envy(H))). +#+end_src + +We can test this with the following program for Alice: + +#+begin_src prolog +!start. + ++!start + <- .send(bob,tell,happy(bob)); + .send(bob,tell,happy(alice)); .wait(2000); + .send(bob,tell,happy(morgana)); .wait(2000); + .send(bob,untell,happy(bob)); .wait(1000); + .send(bob,untell,happy(alice)). +#+end_src + +The =untell= message removes the corresponding belief in the receiver +(only for the belief with that same source, of course). + +* Bob (the lazy -- finally) + +This last code for Bob implements the following: + +1. On Wednesdays, Bob keeps only two =say= intentions, the others will + be suspended. +2. On Fridays, suspended intentions are resumed. +3. On Saturdays, all intentions are dropped. + + +#+begin_src prolog +sincere(alice). + +!create_calendar. ++!create_calendar <- makeArtifact("c","Calendar",[],AId); focus(AId). + ++happy(H)[source(A)] : sincere(A)[source(self)] & .my_name(H) <- !say(hello(A)). ++happy(H) : not .my_name(H) <- !say(i_envy(H)). + +-happy(H)[source(A)] + <- .drop_intention(say(hello(A))); + .drop_intention(say(i_envy(H))). + ++!say(X) : today(friday) <- .print(X,"!!!!!"); .wait(500); !say(X). ++!say(X) : not today(monday) <- .print(X); .wait(math.random(400)+100); !say(X). + +/**** the following is NEW ****/ + ++today(wednesday) <- .print("**** Let's slow down.... ****"); !enter_lazy_mode. ++today(friday) <- .print("**** Let's finish the work!"); !resume_all. ++today(saturday) <- .print("**** weekend!"); .drop_all_intentions. + ++!enter_lazy_mode + : .findall(A, .intend(say(A)), [_,_|L]) // the agent has two say intentions + <- for ( .member(I,L) ) { + .suspend(say(I)); + }. ++!enter_lazy_mode. + ++!resume_all + : .count( .intend(A) & .suspended(A,R) & .substring("suspended",R), I) & I > 0 + <- .resume(say(_)); + !resume_all. ++!resume_all. +#+end_src + +(You can refer to the [[http://jason.sourceforge.net/api/jason/stdlib/package-summary.html#package.description][Jason API]] for explanations about all the commands used in this example.) + +This tutorial showed how some of the (great) BDI concepts become +concrete and practical in Jason, particularly long-term intentions and +reactivity. + +------ + + + Added: trunk/doc/mini-tutorial/src/hello-bdi/jcm.css =================================================================== --- trunk/doc/mini-tutorial/src/hello-bdi/jcm.css (rev 0) +++ trunk/doc/mini-tutorial/src/hello-bdi/jcm.css 2015-05-24 22:32:07 UTC (rev 1837) @@ -0,0 +1,93 @@ +/* Century Schoolbook font is very similar to Computer Modern Math: cmmi */ +.MATH { font-family: "Century Schoolbook", serif; } +.MATH I { font-family: "Century Schoolbook", serif; font-shape: italic } +.BOLDMATH { font-family: "Century Schoolbook", serif; font-weight: bold } + +/* implement both fixed-size and relative sizes */ +SMALL.XTINY { font-size : xx-small } +SMALL.TINY { font-size : x-small } +SMALL.SCRIPTSIZE { font-size : smaller } +SMALL.FOOTNOTESIZE { font-size : small } +SMALL.SMALL { } +BIG.LARGE { } +BIG.XLARGE { font-size : large } +BIG.XXLARGE { font-size : x-large } +BIG.HUGE { font-size : larger } +BIG.XHUGE { font-size : xx-large } + +a { + text-decoration: none; +} + +/* Page background color */ +body { background-color: white; font-family: "Optima", "Georgia", "Times", arial, helvetica, sanserif; font-weight: 200; } +/* mathematics styles */ +DIV.displaymath { } /* math displays */ +TD.eqno { } /* equation-number cells */ + + +.title { + color:#48005E; + font-size: 200%; font-weight:200; + font-family: "Helvetica Neue Light", Optima, Garamond, Times; + text-align: center; + /*display: block; + border-top: 1px solid black; + border-bottom: 1px solid black;*/ + + /*margin-left: -1em;*/ + padding-top: 20px; + padding-bottom: 20px; + padding-right: 10px; +} + +H1 { + color:#48005E; + font-size: 150%; font-weight:200; + display: block; + text-align: left; + + padding-top: 10px; + padding-bottom: 0px; + /*padding-left: 10px; */ + padding-right: 10px; + /*margin-left: -1em;*/ + /*border-bottom: 1px solid black;*/ +} + +H2 { + color:#48005E; + font-size: 140%; font-weight:200; + display: block; + text-align: left; + + padding-top: 5px; + padding-bottom: 0px; + /*padding-left: 10px; */ + padding-right: 10px; + /*margin-left: -1em;*/ +} + +H3 { + color:#48005E; + font-size: 120%; font-weight:200; + display: block; + text-align: left; + + padding-top: 5px; + padding-bottom: 0px; + /*padding-left: 10px; */ + padding-right: 10px; + /*margin-left: -1em;*/ +} + +HR { width: 100%; height: 1px;} + +PRE +{ + padding: 1em; + white-space: pre; + background-color:#f2f2f2; + /*border: 1px solid black;*/ + font-family: Courier, fixed, serif; +} Property changes on: trunk/doc/mini-tutorial/src/hello-bdi/jcm.css ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: trunk/doc/mini-tutorial/src/hello-bdi/screens/mind-1.png =================================================================== (Binary files differ) Index: trunk/doc/mini-tutorial/src/hello-bdi/screens/mind-1.png =================================================================== --- trunk/doc/mini-tutorial/src/hello-bdi/screens/mind-1.png 2015-05-19 16:58:56 UTC (rev 1836) +++ trunk/doc/mini-tutorial/src/hello-bdi/screens/mind-1.png 2015-05-24 22:32:07 UTC (rev 1837) Property changes on: trunk/doc/mini-tutorial/src/hello-bdi/screens/mind-1.png ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +image/png \ No newline at end of property Added: trunk/doc/mini-tutorial/src/hello-bdi/screens/mind-2.png =================================================================== (Binary files differ) Index: trunk/doc/mini-tutorial/src/hello-bdi/screens/mind-2.png =================================================================== --- trunk/doc/mini-tutorial/src/hello-bdi/screens/mind-2.png 2015-05-19 16:58:56 UTC (rev 1836) +++ trunk/doc/mini-tutorial/src/hello-bdi/screens/mind-2.png 2015-05-24 22:32:07 UTC (rev 1837) Property changes on: trunk/doc/mini-tutorial/src/hello-bdi/screens/mind-2.png ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +image/png \ No newline at end of property Modified: trunk/examples/cleaning-robots/logging.properties =================================================================== --- trunk/examples/cleaning-robots/logging.properties 2015-05-19 16:58:56 UTC (rev 1836) +++ trunk/examples/cleaning-robots/logging.properties 2015-05-24 22:32:07 UTC (rev 1837) @@ -28,6 +28,7 @@ jason.runtime.MASConsoleLogHandler.level = ALL jason.runtime.MASConsoleLogHandler.formatter = jason.runtime.MASConsoleLogFormatter jason.runtime.MASConsoleLogHandler.tabbed = false +jason.runtime.MASConsoleLogHandler.colors = true # default file output is in project's directory. java.util.logging.FileHandler.pattern = mas-%u.log Modified: trunk/src/jason/runtime/MASConsoleColorGUI.java =================================================================== --- trunk/src/jason/runtime/MASConsoleColorGUI.java 2015-05-19 16:58:56 UTC (rev 1836) +++ trunk/src/jason/runtime/MASConsoleColorGUI.java 2015-05-24 22:32:07 UTC (rev 1837) @@ -2,8 +2,11 @@ import java.awt.BorderLayout; import java.awt.Color; +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; import java.util.HashMap; -import java.util.Hashtable; import java.util.Map; import javax.swing.JScrollPane; @@ -22,7 +25,7 @@ */ public class MASConsoleColorGUI extends MASConsoleGUI { private Map<String, MASColorTextPane> agsTextArea = new HashMap<String, MASColorTextPane>(); - private Hashtable<String, Color> agsColours = new Hashtable<String, Color>(); + private Map<String, Color> agsColours = new HashMap<String, Color>(); private MASColorTextPane output; private MASConsoleColorGUI(String title) { @@ -65,7 +68,6 @@ agsColours.put(agName, c); } } - if (!frame.isVisible()) { frame.setVisible(true); } @@ -99,21 +101,25 @@ } // print in output - int l = output.getDocument().getLength(); - if (l > 60000) { - cleanConsole(); - l = 0; - } synchronized (this) { + int l = output.getDocument().getLength(); + if (l > 60000) { + cleanConsole(); + l = 0; + } output.append(c, s); try { output.setCaretPosition(l); } catch (IllegalArgumentException e) {} } } catch (Exception e) { - //close(); - System.out.println(e); - e.printStackTrace(); + try { + PrintWriter out = new PrintWriter(new FileWriter("e_r_r_o_r.txt")); + out.write("Error that can not be printed in the MAS Console!\n"+e.toString()+"\n"); + e.printStackTrace(out); + out.close(); + } catch (IOException e1) { + } } } Modified: trunk/src/jason/runtime/MASConsoleGUI.java =================================================================== --- trunk/src/jason/runtime/MASConsoleGUI.java 2015-05-19 16:58:56 UTC (rev 1836) +++ trunk/src/jason/runtime/MASConsoleGUI.java 2015-05-24 22:32:07 UTC (rev 1837) @@ -31,7 +31,10 @@ import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.io.BufferedWriter; import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; import java.util.HashMap; import java.util.Map; import java.util.logging.LogManager; @@ -215,8 +218,13 @@ } catch (java.lang.IllegalArgumentException e) {} } } catch (Exception e) { - //close(); - System.out.println(e); + try { + PrintWriter out = new PrintWriter(new FileWriter("e_r_r_o_r.txt")); + out.write("Error that can not be printed in the MAS Console!\n"+e.toString()+"\n"); + e.printStackTrace(out); + out.close(); + } catch (IOException e1) { + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2015-05-19 16:58:59
|
Revision: 1836 http://sourceforge.net/p/jason/svn/1836 Author: jomifred Date: 2015-05-19 16:58:56 +0000 (Tue, 19 May 2015) Log Message: ----------- fix problem in block-world example Modified Paths: -------------- trunk/examples/blocks-world/BlocksEnv/WorldModel.java trunk/examples/blocks-world/BlocksWorld.mas2j Modified: trunk/examples/blocks-world/BlocksEnv/WorldModel.java =================================================================== --- trunk/examples/blocks-world/BlocksEnv/WorldModel.java 2015-05-13 20:18:49 UTC (rev 1835) +++ trunk/examples/blocks-world/BlocksEnv/WorldModel.java 2015-05-19 16:58:56 UTC (rev 1836) @@ -105,7 +105,7 @@ model.names = new String[GWidth][GHeight]; Stack<String> s1 = new Stack<String>(); - s1.addAll(Arrays.asList(new String[] {"table", "c", "b", "a"})); + //s1.addAll(Arrays.asList(new String[] {"table", "c", "b", "a"})); s1.push("table"); s1.push("c"); s1.push("b"); s1.push("a"); model.stackList.add(s1); Stack<String> s2 = new Stack<String>(); Modified: trunk/examples/blocks-world/BlocksWorld.mas2j =================================================================== --- trunk/examples/blocks-world/BlocksWorld.mas2j 2015-05-13 20:18:49 UTC (rev 1835) +++ trunk/examples/blocks-world/BlocksWorld.mas2j 2015-05-19 16:58:56 UTC (rev 1836) @@ -3,8 +3,8 @@ infrastructure: Centralised - environment: BlocksEnv.BlocksWorld(1,0,yes) // change 0 to 500 or more to slowdown - // yes to use GUI + environment: BlocksEnv.BlocksWorld(1,500,yes) // change 500 to 0 to speed up + // yes to use GUI // There are 5 different solutions to a Blocks World problem in this example. // Choose one of them below: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2015-05-13 20:18:51
|
Revision: 1835 http://sourceforge.net/p/jason/svn/1835 Author: jomifred Date: 2015-05-13 20:18:49 +0000 (Wed, 13 May 2015) Log Message: ----------- minor bug in jEdit plugin Modified Paths: -------------- trunk/src/jason/jeditplugin/JasonID.java Modified: trunk/src/jason/jeditplugin/JasonID.java =================================================================== --- trunk/src/jason/jeditplugin/JasonID.java 2015-04-13 20:15:05 UTC (rev 1834) +++ trunk/src/jason/jeditplugin/JasonID.java 2015-05-13 20:18:49 UTC (rev 1835) @@ -139,6 +139,8 @@ JasonProjectSideKickParser.addPluginInstance(this); new CheckVersion().start(); + + Config.get().setProperty(Config.START_WEB_MI, "false"); } public synchronized void start() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2015-04-13 20:15:07
|
Revision: 1834 http://sourceforge.net/p/jason/svn/1834 Author: jomifred Date: 2015-04-13 20:15:05 +0000 (Mon, 13 Apr 2015) Log Message: ----------- add parameter to customise kqml events Modified Paths: -------------- trunk/release-notes.txt trunk/src/jason/asSemantics/Agent.java trunk/src/jason/asSemantics/Message.java trunk/src/jason/asSemantics/TransitionSystem.java trunk/src/jason/asSyntax/PlanLibrary.java trunk/src/jason/jeditplugin/Config.java Modified: trunk/release-notes.txt =================================================================== --- trunk/release-notes.txt 2015-04-06 21:50:54 UTC (rev 1833) +++ trunk/release-notes.txt 2015-04-13 20:15:05 UTC (rev 1834) @@ -11,6 +11,11 @@ + { +b : p <- .print(ok) }; ... +- two new parameters in .jason/user.properties file: kqmlPlansFile (the file + with the plans that implement the KQML semantics) and kqmlReceivedFunctor + (the functor used to produce new message events). + + New internal actions: - .asserta: insert a belief (or rule) in the begin of the belief base (can be used in prolog like rules) - .assertz: insert a belief (or rule) in the end of the belief base (can be used in prolog like rules) Modified: trunk/src/jason/asSemantics/Agent.java =================================================================== --- trunk/src/jason/asSemantics/Agent.java 2015-04-06 21:50:54 UTC (rev 1833) +++ trunk/src/jason/asSemantics/Agent.java 2015-04-13 20:15:05 UTC (rev 1834) @@ -208,14 +208,29 @@ fixAgInIAandFunctions(this); // used to fix agent reference in functions used inside includes } - // kqml Plans at the end of the ag PS - if (JasonException.class.getResource("/asl/kqmlPlans.asl") != null) { - setASLSrc("kqmlPlans.asl"); - parseAS(JasonException.class.getResource("/asl/kqmlPlans.asl")); - setASLSrc(asSrc); + // load kqml plans at the end of the ag PL + Config c = Config.get(); + if (c.getKqmlPlansFile().equals(Message.kqmlDefaultPlans)) { + // load default implementation + // if KQML functor is not changed + if (c.getKqmlFunctor().equals(Message.kqmlReceivedFunctor)) { + String file = Message.kqmlDefaultPlans.substring(Message.kqmlDefaultPlans.indexOf("/")); + if (JasonException.class.getResource(file) != null) { + setASLSrc("kqmlPlans.asl"); + parseAS(JasonException.class.getResource(file)); + } else { + logger.warning("The kqmlPlans.asl was not found!"); + } + } } else { - logger.warning("The kqmlPlans.asl was not found!"); + // load from specified file + try { + parseAS(new File(c.getKqmlPlansFile())); + } catch (Exception e) { + logger.warning("Error reading kqml semantic plans. "+e+". from file "+c.getKqmlPlansFile()); + } } + setASLSrc(asSrc); } catch (Exception e) { logger.log(Level.SEVERE, "Error creating customised Agent class!", e); throw new JasonException("Error creating customised Agent class! - " + e); Modified: trunk/src/jason/asSemantics/Message.java =================================================================== --- trunk/src/jason/asSemantics/Message.java 2015-04-06 21:50:54 UTC (rev 1833) +++ trunk/src/jason/asSemantics/Message.java 2015-04-13 20:15:05 UTC (rev 1834) @@ -48,6 +48,7 @@ public final static String msgIdSyncAskPrefix = "samid"; public final static String kqmlReceivedFunctor = "kqml_received"; + public final static String kqmlDefaultPlans = "$jasonJar/asl/kqmlPlans.asl"; public Message() { } Modified: trunk/src/jason/asSemantics/TransitionSystem.java =================================================================== --- trunk/src/jason/asSemantics/TransitionSystem.java 2015-04-06 21:50:54 UTC (rev 1833) +++ trunk/src/jason/asSemantics/TransitionSystem.java 2015-04-13 20:15:05 UTC (rev 1834) @@ -53,6 +53,7 @@ import jason.asSyntax.VarTerm; import jason.asSyntax.parser.ParseException; import jason.bb.BeliefBase; +import jason.jeditplugin.Config; import jason.runtime.Settings; import jason.stdlib.add_nested_source; import jason.stdlib.desire; @@ -229,6 +230,8 @@ // the semantic rules are referred to in comments in the functions below + private String kqmlReceivedFunctor = Config.get().getKqmlFunctor(); + private void applyProcMsg() throws JasonException { confP.step = State.SelEv; if (conf.C.hasMsg()) { @@ -322,7 +325,7 @@ } if (!added) { - Literal received = new LiteralImpl(Message.kqmlReceivedFunctor).addTerms( + Literal received = new LiteralImpl(kqmlReceivedFunctor).addTerms( new Atom(sender), new Atom(m.getIlForce()), content, Modified: trunk/src/jason/asSyntax/PlanLibrary.java =================================================================== --- trunk/src/jason/asSyntax/PlanLibrary.java 2015-04-06 21:50:54 UTC (rev 1833) +++ trunk/src/jason/asSyntax/PlanLibrary.java 2015-04-13 20:15:05 UTC (rev 1834) @@ -26,11 +26,11 @@ import jason.JasonException; -import jason.asSemantics.Message; import jason.asSyntax.Trigger.TEOperator; import jason.asSyntax.Trigger.TEType; import jason.asSyntax.parser.ParseException; import jason.bb.BeliefBase; +import jason.jeditplugin.Config; import java.util.ArrayList; import java.util.HashMap; @@ -144,6 +144,8 @@ add(p,false); } + private String kqmlReceivedFunctor = Config.get().getKqmlFunctor(); + /** * Adds a plan into the plan library, either before or after all other * plans depending on the boolean parameter. @@ -173,7 +175,7 @@ if (!p.getLabel().hasSource()) p.getLabel().addAnnot(BeliefBase.TSelf); - if (p.getTrigger().getLiteral().getFunctor().equals(Message.kqmlReceivedFunctor)) { + if (p.getTrigger().getLiteral().getFunctor().equals(kqmlReceivedFunctor)) { if (! (p.getSrcInfo() != null && "kqmlPlans.asl".equals(p.getSrcInfo().getSrcFile()))) { hasUserKqmlReceived = true; } Modified: trunk/src/jason/jeditplugin/Config.java =================================================================== --- trunk/src/jason/jeditplugin/Config.java 2015-04-06 21:50:54 UTC (rev 1833) +++ trunk/src/jason/jeditplugin/Config.java 2015-04-13 20:15:05 UTC (rev 1834) @@ -23,6 +23,7 @@ package jason.jeditplugin; +import jason.asSemantics.Message; import jason.asSemantics.TransitionSystem; import jason.infra.centralised.CentralisedFactory; import jason.infra.jade.JadeFactory; @@ -88,6 +89,9 @@ public static final String NB_TH_SCH = "numberOfThreadsForScheduler"; + public static final String KQML_RECEIVED_FUNCTOR = "kqmlReceivedFunctor"; + public static final String KQML_PLANS_FILE = "kqmlPlansFile"; + private static Config singleton = null; protected static String configFactory = null; @@ -134,7 +138,7 @@ public String getFileConfComment() { return "Jason user configuration"; } - + /** Returns true if the file is loaded correctly */ public boolean load() { try { @@ -214,7 +218,7 @@ public String getAntLib() { return getProperty(ANT_LIB); } - + public void setJavaHome(String jh) { if (jh != null) { jh = new File(jh).getAbsolutePath(); @@ -238,6 +242,13 @@ public String getShellCommand() { return getProperty(SHELL_CMD); } + + public String getKqmlFunctor() { + return getProperty(KQML_RECEIVED_FUNCTOR, Message.kqmlReceivedFunctor); + } + public String getKqmlPlansFile() { + return getProperty(KQML_PLANS_FILE, Message.kqmlDefaultPlans); + } /** Set most important parameters with default values */ public void fix() { @@ -347,6 +358,14 @@ if (getProperty(SHORT_UNNAMED_VARS) == null) { put(SHORT_UNNAMED_VARS,"true"); } + + if (getProperty(KQML_RECEIVED_FUNCTOR) == null) { + put(KQML_RECEIVED_FUNCTOR, Message.kqmlReceivedFunctor); + } + + if (getProperty(KQML_PLANS_FILE) == null) { + put(KQML_PLANS_FILE, Message.kqmlDefaultPlans); + } // Default infrastructures put("infrastructure.Centralised", CentralisedFactory.class.getName()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2015-04-06 21:51:01
|
Revision: 1833 http://sourceforge.net/p/jason/svn/1833 Author: jomifred Date: 2015-04-06 21:50:54 +0000 (Mon, 06 Apr 2015) Log Message: ----------- improve Config Modified Paths: -------------- trunk/lib/jacamo.jar trunk/src/jason/infra/centralised/CentralisedMASLauncherAnt.java trunk/src/jason/jeditplugin/Config.java trunk/src/jason/stdlib/random.java Modified: trunk/lib/jacamo.jar =================================================================== (Binary files differ) Modified: trunk/src/jason/infra/centralised/CentralisedMASLauncherAnt.java =================================================================== --- trunk/src/jason/infra/centralised/CentralisedMASLauncherAnt.java 2015-04-02 18:55:33 UTC (rev 1832) +++ trunk/src/jason/infra/centralised/CentralisedMASLauncherAnt.java 2015-04-06 21:50:54 UTC (rev 1833) @@ -178,7 +178,7 @@ } protected String replaceMarks(String script, boolean debug) { - script = replace(script, "<VERSION>", Config.get().getJasonRunningVersion()); + script = replace(script, "<VERSION>", Config.get().getProperty("version")); script = replace(script, "<DATE>", new SimpleDateFormat("MMMM dd, yyyy - HH:mm:ss").format(new Date())); script = replace(script, "<PROJECT-ID>", project.getSocName()); Modified: trunk/src/jason/jeditplugin/Config.java =================================================================== --- trunk/src/jason/jeditplugin/Config.java 2015-04-02 18:55:33 UTC (rev 1832) +++ trunk/src/jason/jeditplugin/Config.java 2015-04-06 21:50:54 UTC (rev 1833) @@ -90,12 +90,25 @@ private static Config singleton = null; + protected static String configFactory = null; + + public static void setClassFactory(String f) { + configFactory = f; + } + public static Config get() { return get(true); } public static Config get(boolean tryToFixConfig) { if (singleton == null) { - singleton = new Config(); + if (configFactory == null) + configFactory = Config.class.getName(); + try { + singleton = (Config)Class.forName(configFactory).newInstance(); + } catch (Exception e) { + System.err.println("Error creating config from "+configFactory+"("+e+"), using default."); + singleton = new Config(); + } if (!singleton.load()) { if (tryToFixConfig) { singleton.fix(); Modified: trunk/src/jason/stdlib/random.java =================================================================== --- trunk/src/jason/stdlib/random.java 2015-04-02 18:55:33 UTC (rev 1832) +++ trunk/src/jason/stdlib/random.java 2015-04-06 21:50:54 UTC (rev 1833) @@ -20,7 +20,7 @@ <p>Parameter:<ul> <li>- value (number): the variable to receive the random value<br/> - <li><i>+ quantify of random numbers</i> (number, optional): default value is 1, value = 0 means that an infinify number of random numbers will be produced (this is useful for some backtrack circumstances).</li> + <li><i>+ quantity of random numbers</i> (number, optional): default value is 1, value = 0 means that an infinify number of random numbers will be produced (this is useful for some backtrack circumstances).</li> </ul> @@ -28,7 +28,7 @@ <li><code>.random(X)</code>: unifies X with one random number between 0 and 1.</li> <li><code>.random(X, 5)</code>: unifies X with a random number between 0 and 1, and backtracks 5 times. For example: .findall(X, .random(X,5), L) will produce a list of 5 random numbers.</li> - <li><code>.random(X, 0)</code>: unifies X with a random number between 0 and 1, and but backtracks infinitely.</li> + <li><code>.random(X, 0)</code>: unifies X with a random number between 0 and 1, and backtracks infinitely.</li> </ul> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2015-04-02 18:55:36
|
Revision: 1832 http://sourceforge.net/p/jason/svn/1832 Author: jomifred Date: 2015-04-02 18:55:33 +0000 (Thu, 02 Apr 2015) Log Message: ----------- improve build.xml template in the task that produces an application jar Modified Paths: -------------- trunk/src/templates/build-template.xml Modified: trunk/src/templates/build-template.xml =================================================================== --- trunk/src/templates/build-template.xml 2015-04-02 18:31:58 UTC (rev 1831) +++ trunk/src/templates/build-template.xml 2015-04-02 18:55:33 UTC (rev 1832) @@ -57,6 +57,8 @@ <fileset dir="${build.dir}"> <include name="**/*.class" /> </fileset> + <zipgroupfileset dir="${basedir}/lib" includes="**/*.jar" /> + <zipgroupfileset dir="${jasonJar}/../../lib" includes="cartago.jar, c4jason.jar, moise.jar" /> <manifest> <attribute name="Main-Class" value="jason.infra.centralised.RunCentralisedMAS"/> </manifest> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2015-04-02 18:32:00
|
Revision: 1831 http://sourceforge.net/p/jason/svn/1831 Author: jomifred Date: 2015-04-02 18:31:58 +0000 (Thu, 02 Apr 2015) Log Message: ----------- update jacamo.jar Modified Paths: -------------- trunk/lib/jacamo.jar trunk/src/jason/stdlib/relevant_rules.java Modified: trunk/lib/jacamo.jar =================================================================== (Binary files differ) Modified: trunk/src/jason/stdlib/relevant_rules.java =================================================================== --- trunk/src/jason/stdlib/relevant_rules.java 2015-03-31 21:23:51 UTC (rev 1830) +++ trunk/src/jason/stdlib/relevant_rules.java 2015-04-02 18:31:58 UTC (rev 1831) @@ -12,7 +12,6 @@ import jason.asSyntax.Term; import java.util.Iterator; -import java.util.logging.Logger; /** <p>Internal action: <b><code>.relevant_rules</code></b>. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2015-03-31 21:23:59
|
Revision: 1830 http://sourceforge.net/p/jason/svn/1830 Author: jomifred Date: 2015-03-31 21:23:51 +0000 (Tue, 31 Mar 2015) Log Message: ----------- new internal action relevant_rules Modified Paths: -------------- trunk/demos/tell-rule/receiver.asl trunk/demos/tell-rule/sender.asl Added Paths: ----------- trunk/src/jason/stdlib/relevant_rules.java Removed Paths: ------------- trunk/demos/tell-rule/rules/ Modified: trunk/demos/tell-rule/receiver.asl =================================================================== --- trunk/demos/tell-rule/receiver.asl 2015-03-31 21:08:14 UTC (rev 1829) +++ trunk/demos/tell-rule/receiver.asl 2015-03-31 21:23:51 UTC (rev 1830) @@ -17,6 +17,6 @@ +R[source(A)]; } // get all rules and print them - rules.get_rules(_,LR); + .relevant_rules(_,LR); .print("Rules: ",LR). Modified: trunk/demos/tell-rule/sender.asl =================================================================== --- trunk/demos/tell-rule/sender.asl 2015-03-31 21:08:14 UTC (rev 1829) +++ trunk/demos/tell-rule/sender.asl 2015-03-31 21:23:51 UTC (rev 1830) @@ -16,7 +16,7 @@ <- .send(receiver,tellRule, [{a :- b & c}]); // send a list with a single rule .wait(100); .send(receiver,achieve,test); - rules.get_rules(x(_),L); // get all rules with head x(_) + .relevant_rules(x(_),L); // get all rules with head x(_) .print("Sending rules ", L); .send(receiver,tellRule, L). Added: trunk/src/jason/stdlib/relevant_rules.java =================================================================== --- trunk/src/jason/stdlib/relevant_rules.java (rev 0) +++ trunk/src/jason/stdlib/relevant_rules.java 2015-03-31 21:23:51 UTC (rev 1830) @@ -0,0 +1,68 @@ +// Internal action code for project tell-rule.mas2j + +package jason.stdlib; + +import jason.asSemantics.DefaultInternalAction; +import jason.asSemantics.TransitionSystem; +import jason.asSemantics.Unifier; +import jason.asSyntax.ListTerm; +import jason.asSyntax.ListTermImpl; +import jason.asSyntax.Literal; +import jason.asSyntax.Rule; +import jason.asSyntax.Term; + +import java.util.Iterator; +import java.util.logging.Logger; + +/** +<p>Internal action: <b><code>.relevant_rules</code></b>. + +<p>Description: gets all rules that can be used to prove some literal. + +<p>Parameters:<ul> + +<li>+ literal.</li> + +<li>- rules (list of rule terms)</li> + +</ul> + +<p>Example:<ul> + +<li> <code>.relevant_rules( p(_),LP)</code>: unifies LP with a list of +all rules with head p/1.</li> + + +</ul> + +*/ +public class relevant_rules extends DefaultInternalAction { + + @Override public int getMinArgs() { return 2; } + @Override public int getMaxArgs() { return 2; } + + @Override + public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception { + try { + Literal pattern = (Literal)args[0]; + Iterator<Literal> i = ts.getAg().getBB().getCandidateBeliefs(pattern, un); + ListTerm result = new ListTermImpl(); + while (i.hasNext()) { + Literal l = i.next(); + if (l.isRule()) { + if (un.clone().unifies(pattern, l)) { + l = l.copy(); + l.delSources(); + ((Rule)l).setAsTerm(true); + result.add(l); + } + } + } + return un.unifies(args[1],result); + } catch (Exception e) { + ts.getLogger().warning("Error in internal action 'get_rules'! "+e); + } + return false; + } +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2015-03-31 21:08:25
|
Revision: 1829 http://sourceforge.net/p/jason/svn/1829 Author: jomifred Date: 2015-03-31 21:08:14 +0000 (Tue, 31 Mar 2015) Log Message: ----------- rules can be enclosed by { and } and used used as terms (for .assert and + operador) Modified Paths: -------------- trunk/applications/as-unit-test/src/jason/tests/TestPlanbodyAsTerm.java trunk/demos/tell-rule/receiver.asl trunk/demos/tell-rule/rules/get_rules.java trunk/demos/tell-rule/sender.asl trunk/release-notes.txt trunk/src/jason/asSyntax/Rule.java trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc trunk/src/jason/asSyntax/parser/as2j.java trunk/src/jason/bb/DefaultBeliefBase.java trunk/src/jason/stdlib/asserta.java trunk/src/jason/stdlib/assertz.java trunk/src/test/RuleTest.java Added Paths: ----------- trunk/applications/as-unit-test/src/jason/tests/TestRuleTerm.java Removed Paths: ------------- trunk/demos/tell-rule/rules/add_rule.java Modified: trunk/applications/as-unit-test/src/jason/tests/TestPlanbodyAsTerm.java =================================================================== --- trunk/applications/as-unit-test/src/jason/tests/TestPlanbodyAsTerm.java 2015-03-31 19:06:26 UTC (rev 1828) +++ trunk/applications/as-unit-test/src/jason/tests/TestPlanbodyAsTerm.java 2015-03-31 21:08:14 UTC (rev 1829) @@ -34,7 +34,7 @@ "+!g2(A) <- jason.asunit.print(A)."+ "+!trl <- !myadd( { jason.asunit.print(a); jason.asunit.print(b) } ); !grl. "+ - "+!myadd(Action) <- .add_plan( {+!grl : c <- Action} ); .add_plan( {+!grl <- jason.asunit.print(ops) } )." + "+!myadd(Action) <- +>{+!grl : c <- Action}; +>{+!grl <- jason.asunit.print(ops) }." ); } Added: trunk/applications/as-unit-test/src/jason/tests/TestRuleTerm.java =================================================================== --- trunk/applications/as-unit-test/src/jason/tests/TestRuleTerm.java (rev 0) +++ trunk/applications/as-unit-test/src/jason/tests/TestRuleTerm.java 2015-03-31 21:08:14 UTC (rev 1829) @@ -0,0 +1,52 @@ +package jason.tests; + +import jason.asunit.TestAgent; + +import org.junit.Before; +import org.junit.Test; + +public class TestRuleTerm { + + TestAgent ag; + + // initialisation of the agent test + @Before + public void setupAg() { + ag = new TestAgent(); + + // defines the agent's AgentSpeak code + ag.parseAScode( + "q. r. " + + "+!test1 <- .asserta( { p :- q & r } ); .asserta( { v(X,Y) :- Y=X+10 } ). " + + "+!test2 : p <- jason.asunit.print(2). " + + "+!test3(X) : v(X,Y) <- jason.asunit.print(Y). \n" + + "+!test4 <- +{ v :- p & v(2,12) }; !test4a. " + + "+!test4a : v <- jason.asunit.print(ok). " + + "+!test4a <- jason.asunit.print(bu). \n" + + + "+!test5 <- +{ +!k <- jason.asunit.print(ok) }; !k. " + ); + } + + @Test(timeout=2000) + public void testRule() { + ag.addGoal("test1"); + ag.assertBel("p", 5); + + ag.addGoal("test2"); + ag.assertPrint("2", 5); + + ag.addGoal("test3(2)"); + ag.assertPrint("12", 5); + + ag.addGoal("test4"); + ag.assertPrint("ok", 5); + } + + @Test(timeout=2000) + public void testPlan() { + ag.addGoal("test5"); + ag.assertPrint("ok", 10); + } + +} Modified: trunk/demos/tell-rule/receiver.asl =================================================================== --- trunk/demos/tell-rule/receiver.asl 2015-03-31 19:06:26 UTC (rev 1828) +++ trunk/demos/tell-rule/receiver.asl 2015-03-31 21:08:14 UTC (rev 1829) @@ -11,9 +11,11 @@ +!test <- .print(not_ok). // customisation of KQML performative tellRule -+!kqml_received(A,tellRule,Rule,_) - <- .print("Received rule(s) ",Rule, " from ",A); - rules.add_rule(Rule); ++!kqml_received(A,tellRule,Rules,_) + <- .print("Received rule(s) ",Rules, " from ",A); + for ( .member(R, Rules) ) { + +R[source(A)]; + } // get all rules and print them rules.get_rules(_,LR); .print("Rules: ",LR). Deleted: trunk/demos/tell-rule/rules/add_rule.java =================================================================== --- trunk/demos/tell-rule/rules/add_rule.java 2015-03-31 19:06:26 UTC (rev 1828) +++ trunk/demos/tell-rule/rules/add_rule.java 2015-03-31 21:08:14 UTC (rev 1829) @@ -1,44 +0,0 @@ -// Internal action code for project tell-rule.mas2j - -package rules; - -import jason.asSemantics.*; -import jason.asSyntax.*; -import java.util.logging.*; - -public class add_rule extends DefaultInternalAction { - - private Logger logger = Logger.getLogger("tell-rule.mas2j."+add_rule.class.getName()); - - @Override - public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception { - try { - if (args[0].isList()) { - ListTerm l = (ListTerm)args[0]; - for (int i=l.size()-1; i >= 0; i--) { - Term t = l.get(i); - addRule( ((StringTerm)t).getString(), ts ); - } - } else { - addRule( ((StringTerm)args[0]).getString(), ts ); - } - return true; - } catch (Exception e) { - logger.warning("Error in internal action 'add_rule'! "+e); - } - return false; - } - - private void addRule(String sRule, TransitionSystem ts) { - int p = sRule.indexOf(":-"); - if (p > 0) { - //logger.info("Adding rule: "+sRule); - Literal head = Literal.parseLiteral(sRule.substring(0,p)); - LogicalFormula body = LogExpr.parseExpr(sRule.substring(p+2)); - ts.getAg().getBB().add(new Rule(head,body)); - } else { - logger.info(sRule+" is not a rule!"); - } - } -} - Modified: trunk/demos/tell-rule/rules/get_rules.java =================================================================== --- trunk/demos/tell-rule/rules/get_rules.java 2015-03-31 19:06:26 UTC (rev 1828) +++ trunk/demos/tell-rule/rules/get_rules.java 2015-03-31 21:08:14 UTC (rev 1829) @@ -8,7 +8,7 @@ import jason.asSyntax.ListTerm; import jason.asSyntax.ListTermImpl; import jason.asSyntax.Literal; -import jason.asSyntax.StringTermImpl; +import jason.asSyntax.Rule; import jason.asSyntax.Term; import java.util.Iterator; @@ -30,7 +30,8 @@ if (un.clone().unifies(pattern, l)) { l = l.copy(); l.delSources(); - result.add(new StringTermImpl(l.toString())); + ((Rule)l).setAsTerm(true); + result.add(l); } } } Modified: trunk/demos/tell-rule/sender.asl =================================================================== --- trunk/demos/tell-rule/sender.asl 2015-03-31 19:06:26 UTC (rev 1828) +++ trunk/demos/tell-rule/sender.asl 2015-03-31 21:08:14 UTC (rev 1829) @@ -13,9 +13,10 @@ /* Plans */ +!start : true - <- .send(receiver,tellRule,"a :- b & c"); // send a rule as a string + <- .send(receiver,tellRule, [{a :- b & c}]); // send a list with a single rule + .wait(100); .send(receiver,achieve,test); rules.get_rules(x(_),L); // get all rules with head x(_) .print("Sending rules ", L); - .send(receiver,tellRule,L). + .send(receiver,tellRule, L). Modified: trunk/release-notes.txt =================================================================== --- trunk/release-notes.txt 2015-03-31 19:06:26 UTC (rev 1828) +++ trunk/release-notes.txt 2015-03-31 21:08:14 UTC (rev 1829) @@ -1,4 +1,22 @@ --------------------------- +version 1.4.3 + +revision xxxx on SVN +--------------------------- + +New features: +- the operator "+" works with plans and rules enclosed by { and }. For instance: + ... + + { p :- q & r }; + + { +b : p <- .print(ok) }; + ... + +New internal actions: +- .asserta: insert a belief (or rule) in the begin of the belief base (can be used in prolog like rules) +- .assertz: insert a belief (or rule) in the end of the belief base (can be used in prolog like rules) + + +--------------------------- version 1.4.2 revision 1821 on SVN Modified: trunk/src/jason/asSyntax/Rule.java =================================================================== --- trunk/src/jason/asSyntax/Rule.java 2015-03-31 19:06:26 UTC (rev 1828) +++ trunk/src/jason/asSyntax/Rule.java 2015-03-31 21:08:14 UTC (rev 1829) @@ -60,6 +60,7 @@ public Rule(Rule r, Unifier u) { super(r,u); + this.isTerm = r.isTerm; body = (LogicalFormula)r.body.capply(u); predicateIndicatorCache = null; } @@ -70,6 +71,16 @@ return true; } + @Override + public boolean isAtom() { + return false; + } + + @Override + public boolean isGround() { + return false; + } + public void setAsTerm(boolean b) { isTerm = b; } @@ -112,6 +123,7 @@ Rule r = new Rule((Literal)super.clone(), (LogicalFormula)body.clone()); r.predicateIndicatorCache = null; r.resetHashCodeCache(); + r.isTerm = this.isTerm; return r; } @@ -124,7 +136,10 @@ } public String toString() { - return super.toString() + " :- " + body; + if (isTerm()) + return "{ " + super.toString() + " :- " + body + " }"; + else + return super.toString() + " :- " + body; } @Override Modified: trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc =================================================================== --- trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2015-03-31 19:06:26 UTC (rev 1828) +++ trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2015-03-31 21:08:14 UTC (rev 1829) @@ -392,16 +392,22 @@ "(" B = log_expr() ")" - T1 = plan_term() + T1 = rule_plan_term() [ [ <TK_ELSE> { useElse = true; } ] - T2 = plan_term() + T2 = rule_plan_term() ] { try { + if (T1.isRule()) { + throw new ParseException(getSourceRef(T1)+" if requires a plan body."); + } if (T2 == null) { stmtLiteral = new InternalActionLiteral(ASSyntax.createStructure(".if_then_else", (Term)B, T1), curAg); stmtLiteral.setSrcInfo( ((Term)B).getSrcInfo() ); } else { + if (T2.isRule()) { + throw new ParseException(getSourceRef(T2)+" if (else) requires a plan body."); + } stmtLiteral = new InternalActionLiteral(ASSyntax.createStructure(".if_then_else", (Term)B, T1, T2), curAg); stmtLiteral.setSrcInfo( ((Term)B).getSrcInfo() ); if (! useElse) { @@ -421,8 +427,11 @@ "(" B = log_expr() ")" - T1 = plan_term() + T1 = rule_plan_term() { try { + if (T1.isRule()) { + throw new ParseException(getSourceRef(T1)+"for requires a plan body."); + } stmtLiteral = new InternalActionLiteral(ASSyntax.createStructure(".foreach", (Term)B, T1), curAg); stmtLiteral.setSrcInfo( ((Term)B).getSrcInfo() ); return new PlanBodyImpl(BodyType.internalAction, stmtLiteral); @@ -438,8 +447,11 @@ "(" B = log_expr() ")" - T1 = plan_term() + T1 = rule_plan_term() { try { + if (T1.isRule()) { + throw new ParseException(getSourceRef(T1)+"while requires a plan body."); + } stmtLiteral = new InternalActionLiteral(ASSyntax.createStructure(".loop", (Term)B, T1), curAg); stmtLiteral.setSrcInfo( ((Term)B).getSrcInfo() ); return new PlanBodyImpl(BodyType.internalAction, stmtLiteral); @@ -469,10 +481,33 @@ ) ] + ( + B = rule_plan_term() + | B = log_expr() + ) { if (formType == BodyType.action && B instanceof RelExpr) { return new PlanBodyImpl(BodyType.constraint, (RelExpr)B); // constraint - } else if (B instanceof Literal) { + } + if (B instanceof Plan) { + try { + InternalActionLiteral ia = null; + String ias = ""; + if (formType == BodyType.delBel) { + ia = new InternalActionLiteral(ASSyntax.createStructure(".remove_plan", (Term)B), curAg); + } else if (formType == BodyType.addBel) { + ia = new InternalActionLiteral(ASSyntax.createStructure(".add_plan", (Term)B, BeliefBase.ASelf, new Atom("begin")), curAg); + } else if (formType == BodyType.addBelEnd) { + ia = new InternalActionLiteral(ASSyntax.createStructure(".add_plan", (Term)B, BeliefBase.ASelf, new Atom("end")), curAg); + } else { + throw new ParseException(getSourceRef(B)+" Wrong combination of operator "+formType+" and plan."); + } + return new PlanBodyImpl(BodyType.internalAction, ia); + } catch (Exception e) { + e.printStackTrace(); + } + } + if (B instanceof Literal) { if ( ((Literal)B).isInternalAction() ) formType = BodyType.internalAction; return new PlanBodyImpl(formType, (Literal)B); @@ -489,8 +524,12 @@ } } -Term plan_term(): { Trigger T = null; Object C = null; PlanBody B = null, B1 = null; Plan P = null; boolean pb = true; Pred L = null; } - // pb = "only plan body" +Term rule_plan_term(): { Trigger T = null; Object C = null; PlanBody B = null, B1 = null; Plan P = null; + boolean pb = true; // pb = "only plan body" + Pred L = null; + Literal h = null; Object t = null; + } + { "{" [ LOOKAHEAD(4) @@ -501,10 +540,20 @@ | ";" { if (!pb) throw new ParseException(getSourceRef(T)+" Wrong place for ';'"); } ) ] - ] + ] + [ LOOKAHEAD(50) + h=literal() + ":-" + t = log_expr() + ] [ B = plan_body() ] "}" - { + { if (h != null) { + Rule r = new Rule(h,(LogicalFormula)t); + r.setAsTerm(true); + return r; + } + // the plan body case if (T != null) { // handle the case of "+a1", parsed as TE, need to be changed to plan's body // handle the case of "+a1; +a2", parsed as "TE; Body" @@ -590,8 +639,8 @@ "(" l = terms() ")" { p.setTerms(l); } ] - ( b=plan_term() { p.addTerm(b); } - )* + //( b=rule_plan_term() { p.addTerm(b); } + //)* [ lt = list() { p.setAnnots(lt); } ] @@ -614,7 +663,7 @@ Term term() : { Object o; } { ( o=list() - | o=plan_term() + | o=rule_plan_term() | o=log_expr() // log_expr includes literals/atoms/structures ) { return changeToAtom(o); } @@ -643,7 +692,7 @@ ( o=list() | o=arithm_expr() | o=string() - | o=plan_term() + | o=rule_plan_term() ) { return changeToAtom(o); } } @@ -707,7 +756,7 @@ ( op2 = arithm_expr() | op2 = string() | op2 = list() - | op2 = plan_term() + | op2 = rule_plan_term() ) { if ( ((Term)op1).isInternalAction() && operator != RelationalOp.literalBuilder) Modified: trunk/src/jason/asSyntax/parser/as2j.java =================================================================== --- trunk/src/jason/asSyntax/parser/as2j.java 2015-03-31 19:06:26 UTC (rev 1828) +++ trunk/src/jason/asSyntax/parser/as2j.java 2015-03-31 21:08:14 UTC (rev 1829) @@ -461,6 +461,7 @@ case STRING: case ATOM: case UNNAMEDVAR: + case 30: case 34: case 37: case 38: @@ -499,6 +500,7 @@ case STRING: case ATOM: case UNNAMEDVAR: + case 30: case 34: case 37: case 38: @@ -528,7 +530,7 @@ jj_consume_token(42); B = log_expr(); jj_consume_token(43); - T1 = plan_term(); + T1 = rule_plan_term(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case TK_ELSE: case 30: @@ -541,17 +543,23 @@ jj_la1[19] = jj_gen; ; } - T2 = plan_term(); + T2 = rule_plan_term(); break; default: jj_la1[20] = jj_gen; ; } try { + if (T1.isRule()) { + {if (true) throw new ParseException(getSourceRef(T1)+" if requires a plan body.");} + } if (T2 == null) { stmtLiteral = new InternalActionLiteral(ASSyntax.createStructure(".if_then_else", (Term)B, T1), curAg); stmtLiteral.setSrcInfo( ((Term)B).getSrcInfo() ); } else { + if (T2.isRule()) { + {if (true) throw new ParseException(getSourceRef(T2)+" if (else) requires a plan body.");} + } stmtLiteral = new InternalActionLiteral(ASSyntax.createStructure(".if_then_else", (Term)B, T1, T2), curAg); stmtLiteral.setSrcInfo( ((Term)B).getSrcInfo() ); if (! useElse) { @@ -571,8 +579,11 @@ jj_consume_token(42); B = log_expr(); jj_consume_token(43); - T1 = plan_term(); + T1 = rule_plan_term(); try { + if (T1.isRule()) { + {if (true) throw new ParseException(getSourceRef(T1)+"for requires a plan body.");} + } stmtLiteral = new InternalActionLiteral(ASSyntax.createStructure(".foreach", (Term)B, T1), curAg); stmtLiteral.setSrcInfo( ((Term)B).getSrcInfo() ); {if (true) return new PlanBodyImpl(BodyType.internalAction, stmtLiteral);} @@ -588,8 +599,11 @@ jj_consume_token(42); B = log_expr(); jj_consume_token(43); - T1 = plan_term(); + T1 = rule_plan_term(); try { + if (T1.isRule()) { + {if (true) throw new ParseException(getSourceRef(T1)+"while requires a plan body.");} + } stmtLiteral = new InternalActionLiteral(ASSyntax.createStructure(".loop", (Term)B, T1), curAg); stmtLiteral.setSrcInfo( ((Term)B).getSrcInfo() ); {if (true) return new PlanBodyImpl(BodyType.internalAction, stmtLiteral);} @@ -674,10 +688,53 @@ jj_la1[25] = jj_gen; ; } - B = log_expr(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case 30: + B = rule_plan_term(); + break; + case VAR: + case TK_TRUE: + case TK_FALSE: + case TK_NOT: + case TK_NEG: + case TK_BEGIN: + case TK_END: + case NUMBER: + case STRING: + case ATOM: + case UNNAMEDVAR: + case 37: + case 38: + case 42: + B = log_expr(); + break; + default: + jj_la1[26] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } if (formType == BodyType.action && B instanceof RelExpr) { {if (true) return new PlanBodyImpl(BodyType.constraint, (RelExpr)B);} // constraint - } else if (B instanceof Literal) { + } + if (B instanceof Plan) { + try { + InternalActionLiteral ia = null; + String ias = ""; + if (formType == BodyType.delBel) { + ia = new InternalActionLiteral(ASSyntax.createStructure(".remove_plan", (Term)B), curAg); + } else if (formType == BodyType.addBel) { + ia = new InternalActionLiteral(ASSyntax.createStructure(".add_plan", (Term)B, BeliefBase.ASelf, new Atom("begin")), curAg); + } else if (formType == BodyType.addBelEnd) { + ia = new InternalActionLiteral(ASSyntax.createStructure(".add_plan", (Term)B, BeliefBase.ASelf, new Atom("end")), curAg); + } else { + {if (true) throw new ParseException(getSourceRef(B)+" Wrong combination of operator "+formType+" and plan.");} + } + {if (true) return new PlanBodyImpl(BodyType.internalAction, ia);} + } catch (Exception e) { + e.printStackTrace(); + } + } + if (B instanceof Literal) { if ( ((Literal)B).isInternalAction() ) formType = BodyType.internalAction; {if (true) return new PlanBodyImpl(formType, (Literal)B);} @@ -694,8 +751,11 @@ throw new Error("Missing return statement in function"); } - final public Term plan_term() throws ParseException { - Trigger T = null; Object C = null; PlanBody B = null, B1 = null; Plan P = null; boolean pb = true; Pred L = null; + final public Term rule_plan_term() throws ParseException { + Trigger T = null; Object C = null; PlanBody B = null, B1 = null; Plan P = null; + boolean pb = true; // pb = "only plan body" + Pred L = null; + Literal h = null; Object t = null; jj_consume_token(30); if (jj_2_2(4)) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -705,7 +765,7 @@ pb = false; break; default: - jj_la1[26] = jj_gen; + jj_la1[27] = jj_gen; ; } T = trigger(); @@ -717,7 +777,7 @@ pb = false; break; default: - jj_la1[27] = jj_gen; + jj_la1[28] = jj_gen; ; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -733,18 +793,25 @@ if (!pb) {if (true) throw new ParseException(getSourceRef(T)+" Wrong place for ';'");} break; default: - jj_la1[28] = jj_gen; + jj_la1[29] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; default: - jj_la1[29] = jj_gen; + jj_la1[30] = jj_gen; ; } } else { ; } + if (jj_2_3(50)) { + h = literal(); + jj_consume_token(32); + t = log_expr(); + } else { + ; + } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case VAR: case TK_TRUE: @@ -760,6 +827,7 @@ case STRING: case ATOM: case UNNAMEDVAR: + case 30: case 34: case 37: case 38: @@ -769,10 +837,16 @@ B = plan_body(); break; default: - jj_la1[30] = jj_gen; + jj_la1[31] = jj_gen; ; } jj_consume_token(31); + if (h != null) { + Rule r = new Rule(h,(LogicalFormula)t); + r.setAsTerm(true); + {if (true) return r;} + } + // the plan body case if (T != null) { // handle the case of "+a1", parsed as TE, need to be changed to plan's body // handle the case of "+a1; +a2", parsed as "TE; Body" @@ -823,7 +897,7 @@ type = Literal.LNeg; break; default: - jj_la1[31] = jj_gen; + jj_la1[32] = jj_gen; ; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -853,7 +927,7 @@ {if (true) return vt;} break; default: - jj_la1[32] = jj_gen; + jj_la1[33] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -867,7 +941,7 @@ {if (true) return Literal.LFalse;} break; default: - jj_la1[33] = jj_gen; + jj_la1[34] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -888,7 +962,7 @@ K = jj_consume_token(TK_END); break; default: - jj_la1[34] = jj_gen; + jj_la1[35] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -902,22 +976,9 @@ p.setTerms(l); break; default: - jj_la1[35] = jj_gen; + jj_la1[36] = jj_gen; ; } - label_9: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 30: - ; - break; - default: - jj_la1[36] = jj_gen; - break label_9; - } - b = plan_term(); - p.addTerm(b); - } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 48: lt = list(); @@ -936,7 +997,7 @@ ArrayList listTerms = new ArrayList(); Term v; PlanBody o; v = term(); listTerms.add(v); - label_10: + label_9: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 47: @@ -944,7 +1005,7 @@ break; default: jj_la1[38] = jj_gen; - break label_10; + break label_9; } jj_consume_token(47); v = term(); @@ -962,7 +1023,7 @@ o = list(); break; case 30: - o = plan_term(); + o = rule_plan_term(); break; case VAR: case TK_TRUE: @@ -1010,7 +1071,7 @@ case 48: f = term_in_list(); last = lt.append(f); lt.setSrcInfo(f.getSrcInfo()); - label_11: + label_10: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 47: @@ -1018,7 +1079,7 @@ break; default: jj_la1[40] = jj_gen; - break label_11; + break label_10; } jj_consume_token(47); f = term_in_list(); @@ -1085,7 +1146,7 @@ o = string(); break; case 30: - o = plan_term(); + o = rule_plan_term(); break; default: jj_la1[44] = jj_gen; @@ -1266,7 +1327,7 @@ op2 = list(); break; case 30: - op2 = plan_term(); + op2 = rule_plan_term(); break; default: jj_la1[50] = jj_gen; @@ -1292,7 +1353,7 @@ Object t1, t2; ArithmeticOp op; t1 = arithm_expr_trm(); op = ArithmeticOp.none; - label_12: + label_11: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 37: @@ -1301,7 +1362,7 @@ break; default: jj_la1[52] = jj_gen; - break label_12; + break label_11; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 37: @@ -1334,7 +1395,7 @@ Object t1, t2; ArithmeticOp op; t1 = arithm_expr_factor(); op = ArithmeticOp.none; - label_13: + label_12: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case TK_INTDIV: @@ -1345,7 +1406,7 @@ break; default: jj_la1[54] = jj_gen; - break label_13; + break label_12; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 58: @@ -1525,102 +1586,222 @@ finally { jj_save(1, xla); } } - final private boolean jj_3R_67() { - if (jj_3R_79()) return true; + final private boolean jj_2_3(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_3(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(2, xla); } + } + + final private boolean jj_3R_117() { + if (jj_3R_106()) return true; return false; } - final private boolean jj_3R_66() { - if (jj_3R_78()) return true; + final private boolean jj_3R_83() { + if (jj_scan_token(57)) return true; return false; } - final private boolean jj_3R_85() { - if (jj_3R_91()) return true; + final private boolean jj_3R_82() { + if (jj_scan_token(56)) return true; return false; } - final private boolean jj_3R_65() { - if (jj_3R_77()) return true; + final private boolean jj_3R_116() { + if (jj_scan_token(41)) return true; return false; } - final private boolean jj_3R_53() { - if (jj_3R_14()) return true; + final private boolean jj_3R_81() { + if (jj_scan_token(55)) return true; return false; } - final private boolean jj_3R_64() { - if (jj_3R_76()) return true; + final private boolean jj_3R_80() { + if (jj_scan_token(54)) return true; return false; } - final private boolean jj_3R_52() { - if (jj_scan_token(TK_NEG)) return true; + final private boolean jj_3R_79() { + if (jj_scan_token(53)) return true; return false; } - final private boolean jj_3R_59() { + final private boolean jj_3R_78() { + if (jj_scan_token(46)) return true; + return false; + } + + final private boolean jj_3R_77() { + if (jj_scan_token(52)) return true; + return false; + } + + final private boolean jj_3R_76() { + if (jj_scan_token(45)) return true; + return false; + } + + final private boolean jj_3R_72() { Token xsp; xsp = jj_scanpos; - if (jj_3R_64()) { + if (jj_3R_76()) { jj_scanpos = xsp; - if (jj_3R_65()) { + if (jj_3R_77()) { jj_scanpos = xsp; - if (jj_3R_66()) { + if (jj_3R_78()) { jj_scanpos = xsp; - if (jj_3R_67()) return true; + if (jj_3R_79()) { + jj_scanpos = xsp; + if (jj_3R_80()) { + jj_scanpos = xsp; + if (jj_3R_81()) { + jj_scanpos = xsp; + if (jj_3R_82()) { + jj_scanpos = xsp; + if (jj_3R_83()) return true; } } } + } + } + } + } + xsp = jj_scanpos; + if (jj_3R_84()) { + jj_scanpos = xsp; + if (jj_3R_85()) { + jj_scanpos = xsp; + if (jj_3R_86()) { + jj_scanpos = xsp; + if (jj_3R_87()) return true; + } + } + } return false; } - final private boolean jj_3R_44() { + final private boolean jj_3R_71() { + if (jj_3R_74()) return true; + return false; + } + + final private boolean jj_3R_115() { + if (jj_3R_122()) return true; + return false; + } + + final private boolean jj_3R_70() { + if (jj_3R_73()) return true; + return false; + } + + final private boolean jj_3R_114() { + if (jj_3R_121()) return true; + return false; + } + + final private boolean jj_3R_113() { + if (jj_3R_120()) return true; + return false; + } + + final private boolean jj_3R_112() { + if (jj_3R_119()) return true; + return false; + } + + final private boolean jj_3R_64() { Token xsp; xsp = jj_scanpos; - if (jj_3R_52()) jj_scanpos = xsp; - xsp = jj_scanpos; - if (jj_3R_53()) { + if (jj_3R_70()) { jj_scanpos = xsp; - if (jj_3R_54()) return true; + if (jj_3R_71()) return true; } + xsp = jj_scanpos; + if (jj_3R_72()) jj_scanpos = xsp; return false; } - final private boolean jj_3R_31() { + final private boolean jj_3R_106() { Token xsp; xsp = jj_scanpos; - if (jj_3R_44()) { + if (jj_3R_112()) { jj_scanpos = xsp; - if (jj_3R_45()) { + if (jj_3R_113()) { jj_scanpos = xsp; - if (jj_3R_46()) return true; + if (jj_3R_114()) { + jj_scanpos = xsp; + if (jj_3R_115()) return true; } } + } + xsp = jj_scanpos; + if (jj_3R_116()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_117()) jj_scanpos = xsp; return false; } - final private boolean jj_3R_43() { + final private boolean jj_3R_99() { + if (jj_3R_106()) return true; + return false; + } + + final private boolean jj_3R_45() { if (jj_scan_token(40)) return true; return false; } - final private boolean jj_3R_42() { + final private boolean jj_3_3() { + if (jj_3R_19()) return true; + if (jj_scan_token(32)) return true; + if (jj_3R_20()) return true; + return false; + } + + final private boolean jj_3R_44() { if (jj_scan_token(34)) return true; return false; } + final private boolean jj_3R_32() { + if (jj_scan_token(41)) return true; + return false; + } + + final private boolean jj_3R_31() { + if (jj_scan_token(36)) return true; + return false; + } + final private boolean jj_3R_30() { Token xsp; xsp = jj_scanpos; - if (jj_3R_42()) { + if (jj_3R_44()) { jj_scanpos = xsp; - if (jj_3R_43()) return true; + if (jj_3R_45()) return true; } return false; } + final private boolean jj_3R_17() { + if (jj_scan_token(35)) return true; + if (jj_3R_20()) return true; + return false; + } + + final private boolean jj_3R_18() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_31()) { + jj_scanpos = xsp; + if (jj_3R_32()) return true; + } + return false; + } + final private boolean jj_3R_29() { if (jj_scan_token(39)) return true; return false; @@ -1631,17 +1812,30 @@ return false; } + final private boolean jj_3R_15() { + if (jj_scan_token(TK_LABEL_AT)) return true; + if (jj_3R_13()) return true; + return false; + } + final private boolean jj_3R_27() { if (jj_scan_token(37)) return true; return false; } - final private boolean jj_3R_80() { - if (jj_3R_85()) return true; + final private boolean jj_3_2() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_15()) jj_scanpos = xsp; + if (jj_3R_16()) return true; + xsp = jj_scanpos; + if (jj_3R_17()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_18()) jj_scanpos = xsp; return false; } - final private boolean jj_3R_17() { + final private boolean jj_3R_16() { Token xsp; xsp = jj_scanpos; if (jj_3R_27()) { @@ -1653,180 +1847,333 @@ } xsp = jj_scanpos; if (jj_3R_30()) jj_scanpos = xsp; - if (jj_3R_31()) return true; + if (jj_3R_19()) return true; return false; } - final private boolean jj_3R_51() { - if (jj_scan_token(TK_LABEL_AT)) return true; + final private boolean jj_3R_65() { + if (jj_scan_token(30)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3_2()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3_3()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_99()) jj_scanpos = xsp; + if (jj_scan_token(31)) return true; return false; } - final private boolean jj_3R_41() { + final private boolean jj_3R_56() { + if (jj_3R_64()) return true; + return false; + } + + final private boolean jj_3R_55() { + if (jj_scan_token(TK_NOT)) return true; + if (jj_3R_49()) return true; + return false; + } + + final private boolean jj_3R_49() { Token xsp; xsp = jj_scanpos; - if (jj_3R_51()) jj_scanpos = xsp; - if (jj_3R_17()) return true; + if (jj_3R_55()) { + jj_scanpos = xsp; + if (jj_3R_56()) return true; + } return false; } - final private boolean jj_3R_83() { - if (jj_3R_81()) return true; + final private boolean jj_3R_50() { + if (jj_scan_token(51)) return true; + if (jj_3R_36()) return true; return false; } - final private boolean jj_3R_49() { - if (jj_3R_59()) return true; + final private boolean jj_3R_36() { + if (jj_3R_49()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_50()) jj_scanpos = xsp; return false; } - final private boolean jj_3R_82() { - if (jj_3R_80()) return true; + final private boolean jj_3R_37() { + if (jj_scan_token(49)) return true; + if (jj_3R_20()) return true; return false; } - final private boolean jj_3R_34() { - if (jj_scan_token(41)) return true; + final private boolean jj_3R_20() { + if (jj_3R_36()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_37()) jj_scanpos = xsp; return false; } - final private boolean jj_3R_33() { - if (jj_scan_token(36)) return true; + final private boolean jj_3R_53() { + if (jj_scan_token(TK_LABEL_AT)) return true; return false; } - final private boolean jj_3R_19() { + final private boolean jj_3R_43() { Token xsp; xsp = jj_scanpos; - if (jj_3R_33()) { + if (jj_3R_53()) jj_scanpos = xsp; + if (jj_3R_16()) return true; + return false; + } + + final private boolean jj_3R_69() { + if (jj_3R_65()) return true; + return false; + } + + final private boolean jj_3R_68() { + if (jj_3R_74()) return true; + return false; + } + + final private boolean jj_3R_67() { + if (jj_3R_73()) return true; + return false; + } + + final private boolean jj_3R_66() { + if (jj_3R_39()) return true; + return false; + } + + final private boolean jj_3R_60() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_66()) { jj_scanpos = xsp; - if (jj_3R_34()) return true; + if (jj_3R_67()) { + jj_scanpos = xsp; + if (jj_3R_68()) { + jj_scanpos = xsp; + if (jj_3R_69()) return true; } + } + } return false; } - final private boolean jj_3R_18() { - if (jj_scan_token(35)) return true; - if (jj_3R_32()) return true; + final private boolean jj_3R_95() { + if (jj_3R_39()) return true; return false; } - final private boolean jj_3R_75() { + final private boolean jj_3R_94() { + if (jj_scan_token(UNNAMEDVAR)) return true; + return false; + } + + final private boolean jj_3R_93() { + if (jj_scan_token(VAR)) return true; + return false; + } + + final private boolean jj_3R_74() { + if (jj_scan_token(STRING)) return true; + return false; + } + + final private boolean jj_3R_42() { + if (jj_scan_token(34)) return true; + return false; + } + + final private boolean jj_3R_63() { + if (jj_3R_39()) return true; + return false; + } + + final private boolean jj_3R_90() { + if (jj_scan_token(49)) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_82()) { + if (jj_3R_93()) { jj_scanpos = xsp; - if (jj_3R_83()) return true; + if (jj_3R_94()) { + jj_scanpos = xsp; + if (jj_3R_95()) return true; } + } return false; } - final private boolean jj_3R_16() { - if (jj_scan_token(TK_LABEL_AT)) return true; - if (jj_3R_14()) return true; + final private boolean jj_3R_89() { + if (jj_scan_token(47)) return true; + if (jj_3R_60()) return true; return false; } - final private boolean jj_3_2() { + final private boolean jj_3R_62() { + if (jj_scan_token(UNNAMEDVAR)) return true; + return false; + } + + final private boolean jj_3R_126() { + if (jj_3R_20()) return true; + return false; + } + + final private boolean jj_3R_61() { + if (jj_scan_token(VAR)) return true; + return false; + } + + final private boolean jj_3R_134() { + if (jj_scan_token(37)) return true; + return false; + } + + final private boolean jj_3R_125() { + if (jj_3R_65()) return true; + return false; + } + + final private boolean jj_3R_52() { + if (jj_3R_60()) return true; Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_89()) { jj_scanpos = xsp; break; } + } xsp = jj_scanpos; - if (jj_3R_16()) jj_scanpos = xsp; - if (jj_3R_17()) return true; + if (jj_3R_90()) jj_scanpos = xsp; + return false; + } + + final private boolean jj_3R_54() { + Token xsp; xsp = jj_scanpos; - if (jj_3R_18()) jj_scanpos = xsp; + if (jj_3R_61()) { + jj_scanpos = xsp; + if (jj_3R_62()) return true; + } xsp = jj_scanpos; - if (jj_3R_19()) jj_scanpos = xsp; + if (jj_3R_63()) jj_scanpos = xsp; return false; } - final private boolean jj_3R_36() { - if (jj_scan_token(30)) return true; + final private boolean jj_3R_137() { + if (jj_scan_token(46)) return true; + return false; + } + + final private boolean jj_3R_39() { + if (jj_scan_token(48)) return true; Token xsp; xsp = jj_scanpos; - if (jj_3_2()) jj_scanpos = xsp; - xsp = jj_scanpos; - if (jj_3R_49()) jj_scanpos = xsp; - if (jj_scan_token(31)) return true; + if (jj_3R_52()) jj_scanpos = xsp; + if (jj_scan_token(50)) return true; return false; } - final private boolean jj_3R_40() { - if (jj_scan_token(34)) return true; + final private boolean jj_3R_136() { + if (jj_scan_token(45)) return true; return false; } - final private boolean jj_3R_63() { - if (jj_3R_75()) return true; + final private boolean jj_3R_135() { + if (jj_scan_token(37)) return true; return false; } - final private boolean jj_3R_62() { - if (jj_scan_token(TK_NOT)) return true; + final private boolean jj_3R_132() { + if (jj_scan_token(38)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_134()) jj_scanpos = xsp; return false; } - final private boolean jj_3R_55() { + final private boolean jj_3R_133() { Token xsp; xsp = jj_scanpos; - if (jj_3R_62()) { + if (jj_3R_135()) { jj_scanpos = xsp; - if (jj_3R_63()) return true; + if (jj_3R_136()) { + jj_scanpos = xsp; + if (jj_3R_137()) return true; } + } return false; } - final private boolean jj_3R_39() { - if (jj_3R_31()) return true; + final private boolean jj_3R_59() { + if (jj_3R_20()) return true; return false; } - final private boolean jj_3R_47() { - if (jj_3R_55()) return true; + final private boolean jj_3R_58() { + if (jj_3R_65()) return true; return false; } - final private boolean jj_3R_90() { - if (jj_scan_token(38)) return true; + final private boolean jj_3R_57() { + if (jj_3R_39()) return true; return false; } - final private boolean jj_3R_32() { - if (jj_3R_47()) return true; + final private boolean jj_3R_131() { + if (jj_scan_token(37)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_133()) jj_scanpos = xsp; return false; } - final private boolean jj_3R_89() { - if (jj_scan_token(37)) return true; + final private boolean jj_3R_130() { + if (jj_scan_token(40)) return true; return false; } - final private boolean jj_3R_88() { - if (jj_scan_token(40)) return true; + final private boolean jj_3R_41() { + if (jj_3R_19()) return true; return false; } - final private boolean jj_3R_87() { + final private boolean jj_3R_51() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_57()) { + jj_scanpos = xsp; + if (jj_3R_58()) { + jj_scanpos = xsp; + if (jj_3R_59()) return true; + } + } + return false; + } + + final private boolean jj_3R_129() { if (jj_scan_token(44)) return true; return false; } - final private boolean jj_3R_86() { + final private boolean jj_3R_128() { if (jj_scan_token(34)) return true; return false; } - final private boolean jj_3R_84() { + final private boolean jj_3R_124() { Token xsp; xsp = jj_scanpos; - if (jj_3R_86()) { + if (jj_3R_128()) { jj_scanpos = xsp; - if (jj_3R_87()) { + if (jj_3R_129()) { jj_scanpos = xsp; - if (jj_3R_88()) { + if (jj_3R_130()) { jj_scanpos = xsp; - if (jj_3R_89()) { + if (jj_3R_131()) { jj_scanpos = xsp; - if (jj_3R_90()) return true; + if (jj_3R_132()) return true; } } } @@ -1834,269 +2181,355 @@ return false; } - final private boolean jj_3R_79() { + final private boolean jj_3R_118() { + if (jj_3R_19()) return true; + return false; + } + + final private boolean jj_3R_122() { Token xsp; xsp = jj_scanpos; - if (jj_3R_84()) jj_scanpos = xsp; - if (jj_3R_32()) return true; + if (jj_3R_124()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_125()) { + jj_scanpos = xsp; + if (jj_3R_126()) return true; + } return false; } - final private boolean jj_3R_71() { - if (jj_3R_36()) return true; + final private boolean jj_3R_75() { + if (jj_scan_token(47)) return true; + if (jj_3R_51()) return true; return false; } - final private boolean jj_3R_70() { - if (jj_3R_81()) return true; + final private boolean jj_3R_111() { + if (jj_3R_118()) return true; return false; } - final private boolean jj_3R_69() { - if (jj_3R_80()) return true; + final private boolean jj_3R_110() { + if (jj_scan_token(42)) return true; + if (jj_3R_20()) return true; + if (jj_scan_token(43)) return true; return false; } - final private boolean jj_3R_68() { - if (jj_3R_37()) return true; + final private boolean jj_3R_38() { + if (jj_3R_51()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_75()) { jj_scanpos = xsp; break; } + } return false; } - final private boolean jj_3R_60() { + final private boolean jj_3R_109() { + if (jj_scan_token(37)) return true; + if (jj_3R_100()) return true; + return false; + } + + final private boolean jj_3R_22() { + if (jj_3R_39()) return true; + return false; + } + + final private boolean jj_3R_108() { + if (jj_scan_token(38)) return true; + if (jj_3R_100()) return true; + return false; + } + + final private boolean jj_3R_107() { + if (jj_scan_token(NUMBER)) return true; + return false; + } + + final private boolean jj_3R_21() { + if (jj_scan_token(42)) return true; + if (jj_3R_38()) return true; + if (jj_scan_token(43)) return true; + return false; + } + + final private boolean jj_3R_100() { Token xsp; xsp = jj_scanpos; - if (jj_3R_68()) { + if (jj_3R_107()) { jj_scanpos = xsp; - if (jj_3R_69()) { + if (jj_3R_108()) { jj_scanpos = xsp; - if (jj_3R_70()) { + if (jj_3R_109()) { jj_scanpos = xsp; - if (jj_3R_71()) return true; + if (jj_3R_110()) { + jj_scanpos = xsp; + if (jj_3R_111()) return true; } } } + } return false; } - final private boolean jj_3R_81() { - if (jj_scan_token(STRING)) return true; + final private boolean jj_3R_121() { + if (jj_scan_token(TK_WHILE)) return true; + if (jj_scan_token(42)) return true; + if (jj_3R_20()) return true; + if (jj_scan_token(43)) return true; + if (jj_3R_65()) return true; return false; } final private boolean jj_3_1() { if (jj_scan_token(TK_BEGIN)) return true; + if (jj_3R_13()) return true; + if (jj_scan_token(31)) return true; if (jj_3R_14()) return true; - if (jj_scan_token(31)) return true; - if (jj_3R_15()) return true; return false; } - final private boolean jj_3R_74() { - if (jj_3R_37()) return true; + final private boolean jj_3R_40() { + if (jj_scan_token(30)) return true; return false; } - final private boolean jj_3R_38() { - if (jj_scan_token(30)) return true; + final private boolean jj_3R_13() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(23)) { + jj_scanpos = xsp; + if (jj_scan_token(14)) { + jj_scanpos = xsp; + if (jj_scan_token(15)) return true; + } + } + xsp = jj_scanpos; + if (jj_3R_21()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_22()) jj_scanpos = xsp; return false; } - final private boolean jj_3R_73() { - if (jj_scan_token(UNNAMEDVAR)) return true; + final private boolean jj_3R_101() { + if (jj_scan_token(60)) return true; + if (jj_3R_92()) return true; return false; } - final private boolean jj_3R_72() { - if (jj_scan_token(VAR)) return true; + final private boolean jj_3R_92() { + if (jj_3R_100()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_101()) jj_scanpos = xsp; return false; } - final private boolean jj_3R_78() { - if (jj_scan_token(TK_WHILE)) return true; + final private boolean jj_3R_35() { + if (jj_scan_token(TK_FALSE)) return true; return false; } - final private boolean jj_3R_50() { - if (jj_3R_60()) return true; + final private boolean jj_3R_34() { + if (jj_scan_token(TK_TRUE)) return true; return false; } - final private boolean jj_3R_61() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_72()) { - jj_scanpos = xsp; - if (jj_3R_73()) return true; - } - xsp = jj_scanpos; - if (jj_3R_74()) jj_scanpos = xsp; + final private boolean jj_3R_48() { + if (jj_3R_54()) return true; return false; } - final private boolean jj_3R_37() { - if (jj_scan_token(48)) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_50()) jj_scanpos = xsp; - if (jj_scan_token(50)) return true; + final private boolean jj_3R_120() { + if (jj_scan_token(TK_FOR)) return true; + if (jj_scan_token(42)) return true; + if (jj_3R_20()) return true; + if (jj_scan_token(43)) return true; + if (jj_3R_65()) return true; return false; } - final private boolean jj_3R_58() { - if (jj_3R_32()) return true; + final private boolean jj_3R_105() { + if (jj_scan_token(TK_INTMOD)) return true; return false; } - final private boolean jj_3R_57() { - if (jj_3R_36()) return true; + final private boolean jj_3R_104() { + if (jj_scan_token(TK_INTDIV)) return true; return false; } - final private boolean jj_3R_56() { - if (jj_3R_37()) return true; + final private boolean jj_3R_103() { + if (jj_scan_token(59)) return true; return false; } - final private boolean jj_3R_48() { + final private boolean jj_3R_102() { + if (jj_scan_token(58)) return true; + return false; + } + + final private boolean jj_3R_96() { Token xsp; xsp = jj_scanpos; - if (jj_3R_56()) { + if (jj_3R_102()) { jj_scanpos = xsp; - if (jj_3R_57()) { + if (jj_3R_103()) { jj_scanpos = xsp; - if (jj_3R_58()) return true; + if (jj_3R_104()) { + jj_scanpos = xsp; + if (jj_3R_105()) return true; } } + } + if (jj_3R_92()) return true; return false; } - final private boolean jj_3R_98() { - if (jj_3R_31()) return true; + final private boolean jj_3R_88() { + if (jj_3R_92()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_96()) { jj_scanpos = xsp; break; } + } return false; } - final private boolean jj_3R_77() { - if (jj_scan_token(TK_FOR)) return true; + final private boolean jj_3R_47() { + if (jj_3R_13()) return true; return false; } - final private boolean jj_3R_97() { - if (jj_3R_98()) return true; + final private boolean jj_3R_46() { + if (jj_scan_token(TK_NEG)) return true; return false; } - final private boolean jj_3R_96() { - if (jj_scan_token(42)) return true; - return false; - } - - final private boolean jj_3R_35() { + final private boolean jj_3R_33() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_46()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_47()) { + jj_scanpos = xsp; if (jj_3R_48()) return true; + } return false; } - final private boolean jj_3R_95() { - if (jj_scan_token(37)) return true; + final private boolean jj_3R_19() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_33()) { + jj_scanpos = xsp; + if (jj_3R_34()) { + jj_scanpos = xsp; + if (jj_3R_35()) return true; + } + } return false; } - final private boolean jj_3R_22() { - if (jj_3R_37()) return true; - return false; - } - - final private boolean jj_3R_94() { + final private boolean jj_3R_98() { if (jj_scan_token(38)) return true; return false; } - final private boolean jj_3R_21() { - if (jj_3R_36()) return true; + final private boolean jj_3R_127() { + if (jj_scan_token(TK_ELSE)) return true; return false; } - final private boolean jj_3R_93() { - if (jj_scan_token(NUMBER)) return true; + final private boolean jj_3R_97() { + if (jj_scan_token(37)) return true; return false; } - final private boolean jj_3R_20() { - if (jj_scan_token(42)) return true; - if (jj_3R_35()) return true; + final private boolean jj_3R_123() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_127()) jj_scanpos = xsp; + if (jj_3R_65()) return true; return false; } - final private boolean jj_3R_92() { + final private boolean jj_3R_91() { Token xsp; xsp = jj_scanpos; - if (jj_3R_93()) { + if (jj_3R_97()) { jj_scanpos = xsp; - if (jj_3R_94()) { - jj_scanpos = xsp; - if (jj_3R_95()) { - jj_scanpos = xsp; - if (jj_3R_96()) { - jj_scanpos = xsp; - if (jj_3R_97()) return true; + if (jj_3R_98()) return true; } - } - } - } + if (jj_3R_88()) return true; return false; } final private boolean jj_3R_26() { - if (jj_3R_41()) return true; + if (jj_3R_43()) return true; return false; } + final private boolean jj_3R_73() { + if (jj_3R_88()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_91()) { jj_scanpos = xsp; break; } + } + return false; + } + final private boolean jj_3R_25() { - if (jj_3R_40()) return true; + if (jj_3R_42()) return true; return false; } - final private boolean jj_3R_76() { + final private boolean jj_3R_119() { if (jj_scan_token(TK_IF)) return true; + if (jj_scan_token(42)) return true; + if (jj_3R_20()) return true; + if (jj_scan_token(43)) return true; + if (jj_3R_65()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_123()) jj_scanpos = xsp; return false; } final private boolean jj_3R_24() { - if (jj_3R_39()) return true; + if (jj_3R_41()) return true; return false; } - final private boolean jj_3R_14() { - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(23)) { - jj_scanpos = xsp; - if (jj_scan_token(14)) { - jj_scanpos = xsp; - if (jj_scan_token(15)) return true; - } - } - xsp = jj_scanpos; - if (jj_3R_20()) jj_scanpos = xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_21()) { jj_scanpos = xsp; break; } - } - xsp = jj_scanpos; - if (jj_3R_22()) jj_scanpos = xsp; + final private boolean jj_3R_87() { + if (jj_3R_65()) return true; return false; } + final private boolean jj_3R_86() { + if (jj_3R_39()) return true; + return false; + } + final private boolean jj_3R_23() { - if (jj_3R_38()) return true; + if (jj_3R_40()) return true; return false; } - final private boolean jj_3R_91() { - if (jj_3R_92()) return true; + final private boolean jj_3R_85() { + if (jj_3R_74()) return true; return false; } - final private boolean jj_3R_15() { + final private boolean jj_3R_84() { + if (jj_3R_73()) return true; + return false; + } + + final private boolean jj_3R_14() { Token xsp; while (true) { xsp = jj_scanpos; @@ -2118,21 +2551,6 @@ return false; } - final private boolean jj_3R_46() { - if (jj_scan_token(TK_FALSE)) return true; - return false; - } - - final private boolean jj_3R_45() { - if (jj_scan_token(TK_TRUE)) return true; - return false; - } - - final private boolean jj_3R_54() { - if (jj_3R_61()) return true; - return false; - } - public as2jTokenManager token_source; SimpleCharStream jj_input_stream; public Token token, jj_nt; @@ -2150,12 +2568,12 @@ jj_la1_1(); } private static void jj_la1_0() { - jj_la1_0 = new int[] {0x40000000,0x180cb80,0x40000000,0x0,0x40000000,0x10000,0x180cb80,0x40000000,0x80c000,0x0,0x10000,0x0,0x0,0x0,0x0,0x0,0x1facf80,0x0,0x1facf80,0x40000,0x40040000,0x0,0x0,0x0,0x0,0x0,0x10000,0x0,0x0,0x0,0x1facf80,0x800,0x180c080,0x180cb80,0x80c000,0x0,0x40000000,0x0,0x0,0x41e0cf80,0x0,0x1000080,0x0,0x41e0cb80,0x41e0cb80,0x0,0x0,0x1e0cf80,0x1e0cb80,0x0,0x41e0cb80,0x0,0x0,0x0,0x3000,0x3000,0x0,0x1a0cb80,0x1000080,0x0,}; + jj_la1_0 = new int[] {0x40000000,0x180cb80,0x40000000,0x0,0x40000000,0x10000,0x180cb80,0x40000000,0x80c000,0x0,0x10000,0x0,0x0,0x0,0x0,0x0,0x41facf80,0x0,0x41facf80,0x40000,0x40040000,0x0,0x0,0x0,0x0,0x0,0x41e0cf80,0x10000,0x0,0x0,0x0,0x41facf80,0x800,0x180c080,0x180cb80,0x80c000,0x0,0x0,0x0,0x41e0cf80,0x0,0x1000080,0x0,0x41e0cb80,0x41e0cb80,0x0,0x0,0x1e0cf80,0x1e0cb80,0x0,0x41e0cb80,0x0,0x0,0x0,0x3000,0x3000,0x0,0x1a0cb80,0x1000080,0x0,}; } private static void jj_la1_1() { - jj_la1_1 = new int[] {0x0,0x0,0x0,0x4,0x0,0xe0,0x0,0x0,0x0,0x1,0x0,0x8,0x10,0xe0,0x104,0x104,0x1564,0x200,0x1564,0x0,0x0,0x6020,0x6020,0x20,0x1164,0x1164,0x0,0x8,0x210,0x210,0x1564,0x0,0x0,0x0,0x0,0x400,0x0,0x10000,0x8000,0x10460,0x8000,0x10000,0x20000,0x10460,0x10460,0x20000,0x80000,0x460,0x460,0x3f06000,0x10460,0x3f06000,0x60,0x60,0xc000000,0xc000000,0x10000000,0x460,0x0,0x10000,}; + jj_la1_1 = new int[] {0x0,0x0,0x0,0x4,0x0,0xe0,0x0,0x0,0x0,0x1,0x0,0x8,0x10,0xe0,0x104,0x104,0x1564,0x200,0x1564,0x0,0x0,0x6020,0x6020,0x20,0x1164,0x1164,0x460,0x0,0x8,0x210,0x210,0x1564,0x0,0x0,0x0,0x0,0x400,0x10000,0x8000,0x10460,0x8000,0x10000,0x20000,0x10460,0x10460,0x20000,0x80000,0x460,0x460,0x3f06000,0x10460,0x3f06000,0x60,0x60,0xc000000,0xc000000,0x10000000,0x460,0x0,0x10000,}; } - final private JJCalls[] jj_2_rtns = new JJCalls[2]; + final private JJCalls[] jj_2_rtns = new JJCalls[3]; private boolean jj_rescan = false; private int jj_gc = 0; @@ -2375,7 +2793,7 @@ final private void jj_rescan_token() { jj_rescan = true; - for (int i = 0; i < 2; i++) { + for (int i = 0; i < 3; i++) { try { JJCalls p = jj_2_rtns[i]; do { @@ -2384,6 +2802,7 @@ switch (i) { case 0: jj_3_1(); break; case 1: jj_3_2(); break; + case 2: jj_3_3(); break; } } p = p.next; Modified: trunk/src/jason/bb/DefaultBeliefBase.java =================================================================== --- trunk/src/jason/bb/DefaultBeliefBase.java 2015-03-31 19:06:26 UTC (rev 1828) +++ trunk/src/jason/bb/DefaultBeliefBase.java 2015-03-31 21:08:14 UTC (rev 1829) @@ -320,7 +320,7 @@ public void add(Literal l, boolean addInEnd) { map.put(new LiteralWrapper(l), l); if (addInEnd) { - list.addLast(l); + list.addLast(l); } else { list.addFirst(l); } Modified: trunk/src/jason/stdlib/asserta.java ====================================... [truncated message content] |
From: <jom...@us...> - 2015-03-31 19:06:34
|
Revision: 1828 http://sourceforge.net/p/jason/svn/1828 Author: jomifred Date: 2015-03-31 19:06:26 +0000 (Tue, 31 Mar 2015) Log Message: ----------- inicial implementation of asserta/z Modified Paths: -------------- trunk/src/jason/asSyntax/Rule.java trunk/src/jason/bb/DefaultBeliefBase.java trunk/src/jason/stdlib/abolish.java trunk/src/test/BeliefBaseTest.java trunk/src/test/RuleTest.java Added Paths: ----------- trunk/src/jason/stdlib/asserta.java trunk/src/jason/stdlib/assertz.java Modified: trunk/src/jason/asSyntax/Rule.java =================================================================== --- trunk/src/jason/asSyntax/Rule.java 2015-03-31 17:28:01 UTC (rev 1827) +++ trunk/src/jason/asSyntax/Rule.java 2015-03-31 19:06:26 UTC (rev 1828) @@ -44,6 +44,8 @@ private LogicalFormula body = null; + private boolean isTerm = false; // it is true when the rule is used as a term ( { p :- q } ) + public Rule(Literal head, LogicalFormula body) { super(head); if (head.isRule()) { @@ -67,6 +69,14 @@ public boolean isRule() { return true; } + + public void setAsTerm(boolean b) { + isTerm = b; + } + + public boolean isTerm() { + return isTerm; + } @Override public boolean equals(Object o) { Modified: trunk/src/jason/bb/DefaultBeliefBase.java =================================================================== --- trunk/src/jason/bb/DefaultBeliefBase.java 2015-03-31 17:28:01 UTC (rev 1827) +++ trunk/src/jason/bb/DefaultBeliefBase.java 2015-03-31 19:06:26 UTC (rev 1828) @@ -53,7 +53,7 @@ * belsMap is a table where the key is the bel.getFunctorArity and the value * is a list of literals with the same functorArity. */ - private Map<PredicateIndicator, BelEntry> belsMap = new ConcurrentHashMap<PredicateIndicator, BelEntry>(50, (float)0.75, 3); + private Map<PredicateIndicator, BelEntry> belsMap = new ConcurrentHashMap<PredicateIndicator, BelEntry>(); private int size = 0; @@ -201,7 +201,7 @@ public Literal next() { l = il.next(); - if (!il.hasNext() && ibe.hasNext()) { + while (!il.hasNext() && ibe.hasNext()) { il = ibe.next().list.iterator(); } return l; @@ -315,14 +315,14 @@ final class BelEntry { final private Deque<Literal> list = new LinkedBlockingDeque<Literal>(); // maintains the order of the beliefs - final private Map<LiteralWrapper,Literal> map = new ConcurrentHashMap<LiteralWrapper,Literal>(30,(float)0.75,3); // to find content faster + final private Map<LiteralWrapper,Literal> map = new ConcurrentHashMap<LiteralWrapper,Literal>(); // to find content faster public void add(Literal l, boolean addInEnd) { map.put(new LiteralWrapper(l), l); if (addInEnd) { list.addLast(l); } else { - list.addFirst(l); + list.addFirst(l); } } Modified: trunk/src/jason/stdlib/abolish.java =================================================================== --- trunk/src/jason/stdlib/abolish.java 2015-03-31 17:28:01 UTC (rev 1827) +++ trunk/src/jason/stdlib/abolish.java 2015-03-31 19:06:26 UTC (rev 1828) @@ -49,6 +49,7 @@ </ul> @see jason.stdlib.asserta + @see jason.stdlib.assertz */ public class abolish extends DefaultInternalAction { Added: trunk/src/jason/stdlib/asserta.java =================================================================== --- trunk/src/jason/stdlib/asserta.java (rev 0) +++ trunk/src/jason/stdlib/asserta.java 2015-03-31 19:06:26 UTC (rev 1828) @@ -0,0 +1,74 @@ +//---------------------------------------------------------------------------- +// Copyright (C) 2003 Rafael H. Bordini, Jomi F. Hubner, et al. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// To contact the authors: +// http://www.inf.ufrgs.br/~bordini +// http://www.das.ufsc.br/~jomi +// +//---------------------------------------------------------------------------- + +package jason.stdlib; + +import jason.JasonException; +import jason.asSemantics.DefaultInternalAction; +import jason.asSemantics.TransitionSystem; +import jason.asSemantics.Unifier; +import jason.asSyntax.Literal; +import jason.asSyntax.Term; + +import java.util.List; + +/** + <p>Internal action: <b><code>.asserta</code></b>. + + <p>Description: adds a new belief as the "+" (or "+<") operator. However, it can be used in prolog like rules. + + <p>Parameters:<ul> + <li>+ belief (literal): the belief that will be added in the being of the belief base.<br/> + </ul> + + <p>Examples:<ul> + <li> <code>.asserta(p)</code>: adds <code>p</code> in the belief base.</li> + </ul> + + @see jason.stdlib.assertz + @see jason.stdlib.abolish + + */ +public class asserta extends DefaultInternalAction { + + @Override public int getMinArgs() { return 1; } + @Override public int getMaxArgs() { return 1; } + + @Override protected void checkArguments(Term[] args) throws JasonException { + super.checkArguments(args); // check number of arguments + if (!args[0].isLiteral()) + throw JasonException.createWrongArgument(this,"first argument must be a ground literal."); + } + + @Override public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception { + checkArguments(args); + + List<Literal>[] result = ts.getAg().brf((Literal)args[0],null,null,false); + if (result != null) { // really added something + // generate events + ts.updateEvents(result,null); + } + return true; + } + +} Added: trunk/src/jason/stdlib/assertz.java =================================================================== --- trunk/src/jason/stdlib/assertz.java (rev 0) +++ trunk/src/jason/stdlib/assertz.java 2015-03-31 19:06:26 UTC (rev 1828) @@ -0,0 +1,74 @@ +//---------------------------------------------------------------------------- +// Copyright (C) 2003 Rafael H. Bordini, Jomi F. Hubner, et al. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// To contact the authors: +// http://www.inf.ufrgs.br/~bordini +// http://www.das.ufsc.br/~jomi +// +//---------------------------------------------------------------------------- + +package jason.stdlib; + +import jason.JasonException; +import jason.asSemantics.DefaultInternalAction; +import jason.asSemantics.TransitionSystem; +import jason.asSemantics.Unifier; +import jason.asSyntax.Literal; +import jason.asSyntax.Term; + +import java.util.List; + +/** + <p>Internal action: <b><code>.assertz</code></b>. + + <p>Description: adds a new belief as the "+>" operator. However, it can be used in prolog like rules. + + <p>Parameters:<ul> + <li>+ belief (literal): the belief that will be added in the end of the belief base.<br/> + </ul> + + <p>Examples:<ul> + <li> <code>.assertz(p)</code>: adds <code>p</code> in the belief base.</li> + </ul> + + @see jason.stdlib.asserta + @see jason.stdlib.abolish + + */ +public class assertz extends DefaultInternalAction { + + @Override public int getMinArgs() { return 1; } + @Override public int getMaxArgs() { return 1; } + + @Override protected void checkArguments(Term[] args) throws JasonException { + super.checkArguments(args); // check number of arguments + if (!args[0].isLiteral()) + throw JasonException.createWrongArgument(this,"first argument must be a ground literal."); + } + + @Override public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception { + checkArguments(args); + + List<Literal>[] result = ts.getAg().brf((Literal)args[0],null,null,true); + if (result != null) { // really added something + // generate events + ts.updateEvents(result,null); + } + return true; + } + +} Modified: trunk/src/test/BeliefBaseTest.java =================================================================== --- trunk/src/test/BeliefBaseTest.java 2015-03-31 17:28:01 UTC (rev 1827) +++ trunk/src/test/BeliefBaseTest.java 2015-03-31 19:06:26 UTC (rev 1828) @@ -180,7 +180,7 @@ while (itl.hasNext()) { Literal l = itl.next(); if (l.getFunctor().startsWith("testRemIt")) { - itl.remove(); + itl.remove(); } } assertEquals(iteratorSize(bb.getPercepts()), 0); Modified: trunk/src/test/RuleTest.java =================================================================== --- trunk/src/test/RuleTest.java 2015-03-31 17:28:01 UTC (rev 1827) +++ trunk/src/test/RuleTest.java 2015-03-31 19:06:26 UTC (rev 1828) @@ -7,6 +7,7 @@ import jason.asSyntax.LogExpr; import jason.asSyntax.Rule; import jason.asSyntax.Structure; +import jason.asSyntax.Term; import jason.asSyntax.VarTerm; import jason.asSyntax.parser.ParseException; @@ -151,6 +152,9 @@ assertFalse(r.hasVar(new VarTerm("III"), null)); } + public void testAsTerm() throws ParseException { + // TODO Term t = ASSyntax.parseTerm("{p :- a & b | c}"); + } @SuppressWarnings("unchecked") private int iteratorSize(Iterator i) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2015-03-31 17:28:09
|
Revision: 1827 http://sourceforge.net/p/jason/svn/1827 Author: jomifred Date: 2015-03-31 17:28:01 +0000 (Tue, 31 Mar 2015) Log Message: ----------- concurrent BB Modified Paths: -------------- trunk/src/jason/asSemantics/TransitionSystem.java trunk/src/jason/asSyntax/InternalActionLiteral.java trunk/src/jason/bb/DefaultBeliefBase.java trunk/src/jason/jeditplugin/Config.java trunk/src/jason/stdlib/abolish.java Modified: trunk/src/jason/asSemantics/TransitionSystem.java =================================================================== --- trunk/src/jason/asSemantics/TransitionSystem.java 2015-03-31 12:44:42 UTC (rev 1826) +++ trunk/src/jason/asSemantics/TransitionSystem.java 2015-03-31 17:28:01 UTC (rev 1827) @@ -859,8 +859,9 @@ private Literal prepareBodyForEvent(Literal body, Unifier u, IntendedMeans imRenamedVars) { body = (Literal)body.capply(u); Unifier renamedVars = new Unifier(); - //System.out.println("antes "+body+" "+u+" "); + //getLogger().info("antes "+body+" "+u+" "); body.makeVarsAnnon(renamedVars); // free variables in an event cannot conflict with those in the plan + //getLogger().info("depois "+body+" "+renamedVars); if (imRenamedVars != null) { imRenamedVars.renamedVars = renamedVars; @@ -870,8 +871,8 @@ Map<VarTerm, Term> adds = null; for (VarTerm v: renamedVars) { Term t = u.function.get(v); - if (t != null) { - //System.out.println("adding "+t+"="+renamedVars.function.get(v)); + if (t != null && t.isVar()) { + getLogger().info("adding "+t+"="+v+"="+renamedVars.function.get(v)+" u="+u); if (adds == null) adds = new HashMap<VarTerm, Term>(); try { Modified: trunk/src/jason/asSyntax/InternalActionLiteral.java =================================================================== --- trunk/src/jason/asSyntax/InternalActionLiteral.java 2015-03-31 12:44:42 UTC (rev 1826) +++ trunk/src/jason/asSyntax/InternalActionLiteral.java 2015-03-31 17:28:01 UTC (rev 1827) @@ -134,7 +134,8 @@ }*/ } } catch (ConcurrentModificationException e) { - System.out.println("*-*-* .count concurrent exception - try later"); + System.out.println("*-*-* "+getFunctor()+" concurrent exception - try later"); + e.printStackTrace(); // try again later try { Thread.sleep(200); } catch (InterruptedException e1) { } return logicalConsequence(ag, un); Modified: trunk/src/jason/bb/DefaultBeliefBase.java =================================================================== --- trunk/src/jason/bb/DefaultBeliefBase.java 2015-03-31 12:44:42 UTC (rev 1826) +++ trunk/src/jason/bb/DefaultBeliefBase.java 2015-03-31 17:28:01 UTC (rev 1827) @@ -29,15 +29,13 @@ import jason.asSyntax.PredicateIndicator; import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; +import java.util.Deque; import java.util.HashSet; import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.LinkedBlockingDeque; import java.util.logging.Level; import java.util.logging.Logger; @@ -55,7 +53,7 @@ * belsMap is a table where the key is the bel.getFunctorArity and the value * is a list of literals with the same functorArity. */ - private Map<PredicateIndicator, BelEntry> belsMap = new ConcurrentHashMap<PredicateIndicator, BelEntry>(); + private Map<PredicateIndicator, BelEntry> belsMap = new ConcurrentHashMap<PredicateIndicator, BelEntry>(50, (float)0.75, 3); private int size = 0; @@ -259,7 +257,8 @@ public Iterator<Literal> getCandidateBeliefs(PredicateIndicator pi) { BelEntry entry = belsMap.get(pi); if (entry != null) - return Collections.unmodifiableList(entry.list).iterator(); + //return Collections.unmodifiableList(entry.list).iterator(); + return entry.list.iterator(); else return null; } @@ -271,7 +270,8 @@ } else { BelEntry entry = belsMap.get(l.getPredicateIndicator()); if (entry != null) - return Collections.unmodifiableList(entry.list).iterator(); + //return Collections.unmodifiableList(entry.list).iterator(); + return entry.list.iterator(); else return null; } @@ -314,15 +314,15 @@ /** each predicate indicator has one BelEntry assigned to it */ final class BelEntry { - final private List<Literal> list = new LinkedList<Literal>(); // maintains the order of the beliefs - final private Map<LiteralWrapper,Literal> map = new HashMap<LiteralWrapper,Literal>(); // to find content faster + final private Deque<Literal> list = new LinkedBlockingDeque<Literal>(); // maintains the order of the beliefs + final private Map<LiteralWrapper,Literal> map = new ConcurrentHashMap<LiteralWrapper,Literal>(30,(float)0.75,3); // to find content faster public void add(Literal l, boolean addInEnd) { map.put(new LiteralWrapper(l), l); if (addInEnd) { - list.add(l); + list.addLast(l); } else { - list.add(0,l); + list.addFirst(l); } } Modified: trunk/src/jason/jeditplugin/Config.java =================================================================== --- trunk/src/jason/jeditplugin/Config.java 2015-03-31 12:44:42 UTC (rev 1826) +++ trunk/src/jason/jeditplugin/Config.java 2015-03-31 17:28:01 UTC (rev 1827) @@ -330,6 +330,10 @@ if (getProperty(NB_TH_SCH) == null) { put(NB_TH_SCH, "2"); } + + if (getProperty(SHORT_UNNAMED_VARS) == null) { + put(SHORT_UNNAMED_VARS,"true"); + } // Default infrastructures put("infrastructure.Centralised", CentralisedFactory.class.getName()); Modified: trunk/src/jason/stdlib/abolish.java =================================================================== --- trunk/src/jason/stdlib/abolish.java 2015-03-31 12:44:42 UTC (rev 1826) +++ trunk/src/jason/stdlib/abolish.java 2015-03-31 17:28:01 UTC (rev 1827) @@ -34,19 +34,22 @@ <p>Internal action: <b><code>.abolish</code></b>. <p>Description: removes all beliefs that match the argument. As for the - "-" operator, an event will be generated for each deletion. + "-" operator, an event will be generated for each deletion. + Different from the "-" operator, which consider "self" as the default source, .abolish will ignore the source if not informed. <p>Parameters:<ul> <li>+ pattern (literal or variable): the "pattern" for what should be removed.<br/> </ul> <p>Examples:<ul> - <li> <code>.abolish(b(_))</code>: remove all <code>b/1</code> beliefs, regardless of the argument value.</li> + <li> <code>.abolish(b(_))</code>: remove all <code>b/1</code> beliefs, regardless of the argument value and the source of the belief.</li> <li> <code>.abolish(c(_,t))</code>: remove all <code>c/2</code> beliefs where the second argument is <code>2</code>.</li> <li> <code>.abolish(c(_,_)[source(ag1)])</code>: remove all <code>c/2</code> beliefs that have <code>ag1</code> as source.</li> <li> <code>.abolish(_[source(ag1)])</code>: remove any beliefs that have <code>ag1</code> as source.</li> </ul> + @see jason.stdlib.asserta + */ public class abolish extends DefaultInternalAction { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2015-03-31 12:44:45
|
Revision: 1826 http://sourceforge.net/p/jason/svn/1826 Author: jomifred Date: 2015-03-31 12:44:42 +0000 (Tue, 31 Mar 2015) Log Message: ----------- improve meta events with finish state (achieved, unachieved or dropped) Modified Paths: -------------- trunk/demos/meta-events/robot.asl trunk/src/jason/asSemantics/GoalListener.java trunk/src/jason/asSemantics/GoalListenerForMetaEvents.java trunk/src/jason/asSemantics/TransitionSystem.java trunk/src/jason/stdlib/fail_goal.java trunk/src/jason/stdlib/resume.java trunk/src/jason/stdlib/succeed_goal.java trunk/src/jason/stdlib/suspend.java Modified: trunk/demos/meta-events/robot.asl =================================================================== --- trunk/demos/meta-events/robot.asl 2015-03-27 17:34:55 UTC (rev 1825) +++ trunk/demos/meta-events/robot.asl 2015-03-31 12:44:42 UTC (rev 1826) @@ -4,7 +4,7 @@ /* Plans for goals */ -+!move <- move; !!move. ++!move <- move; !move. /* Plans for perception */ Modified: trunk/src/jason/asSemantics/GoalListener.java =================================================================== --- trunk/src/jason/asSemantics/GoalListener.java 2015-03-27 17:34:55 UTC (rev 1825) +++ trunk/src/jason/asSemantics/GoalListener.java 2015-03-31 12:44:42 UTC (rev 1826) @@ -6,12 +6,13 @@ public interface GoalListener { public enum GoalStates { started, suspended, resumed, finished, failed } ; + public enum FinishStates { achieved, unachieved, dropped } ; /** method called when a new goal is produced by operator ! */ public void goalStarted(Event goal); - /** method called when a goal is successfully finished */ - public void goalFinished(Trigger goal); + /** method called when a goal is (un)successfully finished */ + public void goalFinished(Trigger goal, FinishStates result); /** method called when a goal is failed */ public void goalFailed(Trigger goal); Modified: trunk/src/jason/asSemantics/GoalListenerForMetaEvents.java =================================================================== --- trunk/src/jason/asSemantics/GoalListenerForMetaEvents.java 2015-03-27 17:34:55 UTC (rev 1825) +++ trunk/src/jason/asSemantics/GoalListenerForMetaEvents.java 2015-03-31 12:44:42 UTC (rev 1826) @@ -24,8 +24,8 @@ generateGoalStateEvent(goal.getLiteral(), goal.getType(), GoalStates.failed, null); } - public void goalFinished(Trigger goal) { - generateGoalStateEvent(goal.getLiteral(), goal.getType(), GoalStates.finished, null); + public void goalFinished(Trigger goal, FinishStates result) { + generateGoalStateEvent(goal.getLiteral(), goal.getType(), GoalStates.finished, result.toString()); } public void goalResumed(Trigger goal) { Modified: trunk/src/jason/asSemantics/TransitionSystem.java =================================================================== --- trunk/src/jason/asSemantics/TransitionSystem.java 2015-03-27 17:34:55 UTC (rev 1825) +++ trunk/src/jason/asSemantics/TransitionSystem.java 2015-03-31 12:44:42 UTC (rev 1826) @@ -27,6 +27,7 @@ import jason.NoValueException; import jason.RevisionFailedException; import jason.architecture.AgArch; +import jason.asSemantics.GoalListener.FinishStates; import jason.asSyntax.ASSyntax; import jason.asSyntax.Atom; import jason.asSyntax.BinaryStructure; @@ -158,7 +159,7 @@ public void intentionDropped(Intention i) { for (IntendedMeans im: i) //.getIMs()) if (im.getTrigger().isAddition() && im.getTrigger().isGoal()) - gl.goalFinished(im.getTrigger()); + gl.goalFinished(im.getTrigger(), FinishStates.dropped); } public void intentionSuspended(Intention i, String reason) { @@ -916,13 +917,14 @@ IntendedMeans topIM = i.pop(); Trigger topTrigger = topIM.getTrigger(); Literal topLiteral = topTrigger.getLiteral(); - if (logger.isLoggable(Level.FINE)) logger.fine("Returning from IM "+topIM.getPlan().getLabel()+", te="+topIM.getPlan().getTrigger()+" unif="+topIM.unif); + if (logger.isLoggable(Level.FINE)) + logger.fine("Returning from IM "+topIM.getPlan().getLabel()+", te="+topTrigger+" unif="+topIM.unif); - // produce ^!g[state(finished)] event - if (topTrigger.getOperator() == TEOperator.add && topTrigger.isGoal()) { - if (hasGoalListener()) - for (GoalListener gl: goalListeners) - gl.goalFinished(topTrigger); + // produce ^!g[state(finished)[reason(achieved)]] event + if (!topTrigger.isMetaEvent() && topTrigger.isGoal() && hasGoalListener()) { + for (GoalListener gl: goalListeners) { + gl.goalFinished(topTrigger, FinishStates.achieved); + } } // if has finished a failure handling IM ... @@ -1099,8 +1101,11 @@ if (im.isGoalAdd()) { // notify listener if (hasGoalListener()) - for (GoalListener gl: goalListeners) + for (GoalListener gl: goalListeners) { gl.goalFailed(im.getTrigger()); + if (!failEventIsRelevant) + gl.goalFinished(im.getTrigger(), FinishStates.unachieved); + } if (failEventIsRelevant) { confP.C.addEvent(failEvent); Modified: trunk/src/jason/stdlib/fail_goal.java =================================================================== --- trunk/src/jason/stdlib/fail_goal.java 2015-03-27 17:34:55 UTC (rev 1825) +++ trunk/src/jason/stdlib/fail_goal.java 2015-03-31 12:44:42 UTC (rev 1826) @@ -29,6 +29,7 @@ import jason.asSemantics.Intention; import jason.asSemantics.TransitionSystem; import jason.asSemantics.Unifier; +import jason.asSemantics.GoalListener.FinishStates; import jason.asSyntax.Literal; import jason.asSyntax.Term; import jason.asSyntax.Trigger; @@ -47,6 +48,8 @@ is a goal if there is a triggering event <code>+!G</code> in any plan within any intention; also note that intentions can be suspended hence appearing in sets E, PA, or PI of the agent's circumstance as well. + <br/> + The meta-event <code>^!G[state(failed)]</code> is produced. <p>Example:<ul> @@ -109,6 +112,9 @@ return 2; } else { // i is finished or without failure plan ts.getLogger().fine("'.fail_goal("+g+")' is removing the intention without event:\n" + i); + if (ts.hasGoalListener()) + for (GoalListener gl: ts.getGoalListeners()) + gl.goalFinished(g, FinishStates.unachieved); return 3; } } Modified: trunk/src/jason/stdlib/resume.java =================================================================== --- trunk/src/jason/stdlib/resume.java 2015-03-27 17:34:55 UTC (rev 1825) +++ trunk/src/jason/stdlib/resume.java 2015-03-31 12:44:42 UTC (rev 1826) @@ -44,6 +44,8 @@ <b><code>.resume(<i>G</i>)</code></b>. <p>Description: resume goals <i>G</i> that were suspended by <code>.suspend</code>. + <br/> + The meta-event <code>^!G[state(resumed)]</code> is produced. <p>Example:<ul> Modified: trunk/src/jason/stdlib/succeed_goal.java =================================================================== --- trunk/src/jason/stdlib/succeed_goal.java 2015-03-27 17:34:55 UTC (rev 1825) +++ trunk/src/jason/stdlib/succeed_goal.java 2015-03-31 12:44:42 UTC (rev 1826) @@ -32,6 +32,7 @@ import jason.asSemantics.Intention; import jason.asSemantics.TransitionSystem; import jason.asSemantics.Unifier; +import jason.asSemantics.GoalListener.FinishStates; import jason.asSyntax.Literal; import jason.asSyntax.Term; import jason.asSyntax.Trigger; @@ -49,6 +50,8 @@ is a goal if there is a triggering event <code>+!G</code> in any plan within any intention; also note that intentions can be suspended hence appearing in E, PA, or PI as well. + <br/> + The meta-event <code>^!G[state(finished)]</code> is produced. <p>Example:<ul> @@ -196,7 +199,7 @@ if (i != null && i.dropGoal(g, un)) { if (ts.hasGoalListener()) for (GoalListener gl: ts.getGoalListeners()) - gl.goalFinished(g); + gl.goalFinished(g, FinishStates.achieved); // continue the intention if (!i.isFinished()) { // could be finished after i.dropGoal() !! @@ -218,7 +221,7 @@ if (i != null) { if (ts.hasGoalListener()) for (GoalListener gl: ts.getGoalListeners()) - gl.goalFinished(e.getTrigger()); + gl.goalFinished(e.getTrigger(), FinishStates.achieved); i.peek().removeCurrentStep(); ts.applyClrInt(i); C.addIntention(i); Modified: trunk/src/jason/stdlib/suspend.java =================================================================== --- trunk/src/jason/stdlib/suspend.java 2015-03-27 17:34:55 UTC (rev 1825) +++ trunk/src/jason/stdlib/suspend.java 2015-03-31 12:44:42 UTC (rev 1826) @@ -47,7 +47,9 @@ running until the internal action <code>.resume</code> change the state of those intentions. A literal <i>G</i> is a goal if there is a triggering event <code>+!G</code> in any plan within - any intention in I, E, PI, or PA. + any intention in I, E, PI, or PA. + <br/> + The meta-event <code>^!G[state(suspended)]</code> is produced. <p>Examples:<ul> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2015-03-27 17:34:57
|
Revision: 1825 http://sourceforge.net/p/jason/svn/1825 Author: jomifred Date: 2015-03-27 17:34:55 +0000 (Fri, 27 Mar 2015) Log Message: ----------- show suspended state of intentions in mind inspector Modified Paths: -------------- trunk/src/jason/asSemantics/Intention.java trunk/src/jason/util/asl2xml.java trunk/src/xml/agInspection.xsl Modified: trunk/src/jason/asSemantics/Intention.java =================================================================== --- trunk/src/jason/asSemantics/Intention.java 2015-03-13 17:23:55 UTC (rev 1824) +++ trunk/src/jason/asSemantics/Intention.java 2015-03-27 17:34:55 UTC (rev 1825) @@ -229,6 +229,7 @@ //if (intendedMeans.isEmpty()) // eint.appendChild( initialTrigger.getAsDOM(document)); eint.setAttribute("finished", ""+isFinished()); + eint.setAttribute("suspended", ""+isSuspended()); return eint; } Modified: trunk/src/jason/util/asl2xml.java =================================================================== --- trunk/src/jason/util/asl2xml.java 2015-03-13 17:23:55 UTC (rev 1824) +++ trunk/src/jason/util/asl2xml.java 2015-03-27 17:34:55 UTC (rev 1825) @@ -67,9 +67,13 @@ } public String transform(Document agState) throws Exception { - StringWriter so = new StringWriter(); - getTransformer().transform(new DOMSource(agState), new StreamResult(so)); - return so.toString(); + try { + StringWriter so = new StringWriter(); + getTransformer().transform(new DOMSource(agState), new StreamResult(so)); + return so.toString(); + } catch (IndexOutOfBoundsException e) { + return ""; + } } protected Transformer transCache = null; Modified: trunk/src/xml/agInspection.xsl =================================================================== --- trunk/src/xml/agInspection.xsl 2015-03-13 17:23:55 UTC (rev 1824) +++ trunk/src/xml/agInspection.xsl 2015-03-27 17:34:55 UTC (rev 1825) @@ -268,6 +268,9 @@ <xsl:if test="string-length(@pending) > 0"> <b><xsl:value-of select="@pending" /></b> </xsl:if> + <xsl:if test="string-length(@suspended) > 0 and @suspended='true' and not(starts-with(@pending,'suspen'))"> + <xsl:text> (suspended) </xsl:text> + </xsl:if> </td> <td valign="top"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2015-03-13 17:23:58
|
Revision: 1824 http://sourceforge.net/p/jason/svn/1824 Author: jomifred Date: 2015-03-13 17:23:55 +0000 (Fri, 13 Mar 2015) Log Message: ----------- fix bug in resume/suspend Modified Paths: -------------- trunk/src/jason/stdlib/resume.java trunk/src/jason/stdlib/suspend.java trunk/src/jason/stdlib/wait.java Modified: trunk/src/jason/stdlib/resume.java =================================================================== --- trunk/src/jason/stdlib/resume.java 2015-03-06 22:09:17 UTC (rev 1823) +++ trunk/src/jason/stdlib/resume.java 2015-03-13 17:23:55 UTC (rev 1824) @@ -25,6 +25,7 @@ import jason.JasonException; import jason.asSemantics.Circumstance; +import jason.asSemantics.CircumstanceListener; import jason.asSemantics.DefaultInternalAction; import jason.asSemantics.Event; import jason.asSemantics.Intention; @@ -86,22 +87,30 @@ Iterator<String> ik = C.getPendingIntentions().keySet().iterator(); while (ik.hasNext()) { String k = ik.next(); - if (k.startsWith(suspend.SUSPENDED_INT)) { - Intention i = C.getPendingIntentions().get(k); - if (i.hasTrigger(g, un)) { - i.setSuspended(false); + Intention i = C.getPendingIntentions().get(k); + if (i.isSuspended() && i.hasTrigger(g, un)) { + i.setSuspended(false); + boolean notify = true; + if (k.startsWith(suspend.SUSPENDED_INT)) { // if not SUSPENDED_INT, it was suspended while already in PI, so, do not remove it from PI, just change the suspeded status ik.remove(); - // remove the IA .suspend in case of self-suspend - if (k.startsWith(suspend.SELF_SUSPENDED_INT)) - i.peek().removeCurrentStep(); - // add it back in I if not in PA - if (! C.getPendingActions().containsKey(i.getId())) + if (! C.getPendingActions().containsKey(i.getId())) { C.resumeIntention(i); - - //System.out.println("res "+g+" from I "+i.getId()); + notify = false; // the resumeIntention already notifies + } } + + // notify meta event listeners + if (notify && C.getListeners() != null) + for (CircumstanceListener el : C.getListeners()) + el.intentionResumed(i); + + // remove the IA .suspend in case of self-suspend + if (k.startsWith(suspend.SELF_SUSPENDED_INT)) + i.peek().removeCurrentStep(); + + //System.out.println("res "+g+" from I "+i.getId()); } } Modified: trunk/src/jason/stdlib/suspend.java =================================================================== --- trunk/src/jason/stdlib/suspend.java 2015-03-06 22:09:17 UTC (rev 1823) +++ trunk/src/jason/stdlib/suspend.java 2015-03-13 17:23:55 UTC (rev 1824) @@ -184,7 +184,6 @@ */ } - // TODO: consider the case of suspending something that is already suspended. return true; } Modified: trunk/src/jason/stdlib/wait.java =================================================================== --- trunk/src/jason/stdlib/wait.java 2015-03-06 22:09:17 UTC (rev 1823) +++ trunk/src/jason/stdlib/wait.java 2015-03-13 17:23:55 UTC (rev 1824) @@ -24,6 +24,7 @@ package jason.stdlib; import jason.JasonException; +import jason.asSemantics.Agent; import jason.asSemantics.Circumstance; import jason.asSemantics.CircumstanceListener; import jason.asSemantics.DefaultInternalAction; @@ -36,10 +37,10 @@ import jason.asSyntax.NumberTerm; import jason.asSyntax.NumberTermImpl; import jason.asSyntax.PlanBody; +import jason.asSyntax.PlanBody.BodyType; import jason.asSyntax.PlanBodyImpl; import jason.asSyntax.Term; import jason.asSyntax.Trigger; -import jason.asSyntax.PlanBody.BodyType; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -159,7 +160,7 @@ startTime = System.currentTimeMillis(); if (timeout >= 0) { - ts.getAg().getScheduler().schedule(new Runnable() { + Agent.getScheduler().schedule(new Runnable() { public void run() { resume(true); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2015-03-06 22:09:19
|
Revision: 1823 http://sourceforge.net/p/jason/svn/1823 Author: jomifred Date: 2015-03-06 22:09:17 +0000 (Fri, 06 Mar 2015) Log Message: ----------- improvements in meta events related to dropped intentions Modified Paths: -------------- trunk/src/jason/asSemantics/Circumstance.java trunk/src/jason/stdlib/drop_desire.java Modified: trunk/src/jason/asSemantics/Circumstance.java =================================================================== --- trunk/src/jason/asSemantics/Circumstance.java 2015-03-02 11:44:12 UTC (rev 1822) +++ trunk/src/jason/asSemantics/Circumstance.java 2015-03-06 22:09:17 UTC (rev 1823) @@ -149,20 +149,45 @@ } public boolean removeEvent(Event ev) { + boolean removed = false; if (ev.equals(AE)) { AE = null; - return true; + removed = true; + } else { + removed = E.remove(ev); } - return E.remove(ev); + if (removed && ev.getIntention() != null && listeners != null) + for (CircumstanceListener el : listeners) + el.intentionDropped(ev.getIntention()); + return removed; } + // remove events based on a match with a trigger + public void removeEvents(Trigger te, Unifier un) { + Iterator<Event> ie = E.iterator(); + while (ie.hasNext()) { + Event ev = ie.next(); + Trigger t = ev.getTrigger(); + if (ev.getIntention() != Intention.EmptyInt) { // since the unifier of the intention will not be used, apply it to the event before comparing to the event to be dropped + t = t.capply(ev.getIntention().peek().getUnif()); + } + if (un.clone().unifiesNoUndo(te, t)) { + ie.remove(); + if (ev.getIntention() != null && listeners != null) + for (CircumstanceListener el : listeners) + el.intentionDropped(ev.getIntention()); + } + } + } + public void clearEvents() { // notify listeners if (listeners != null) for (CircumstanceListener el : listeners) { for (Event ev: E) - el.intentionDropped(ev.getIntention()); - if (AE != null) + if (ev.getIntention() != null) + el.intentionDropped(ev.getIntention()); + if (AE != null && AE.getIntention() != null) el.intentionDropped(AE.getIntention()); } @@ -199,6 +224,10 @@ public Event removeAtomicEvent() { Event e = AE; AE = null; + if (e != null && e.getIntention() != null && listeners != null) + for (CircumstanceListener el : listeners) + el.intentionDropped(e.getIntention()); + return e; /*if (!hasAtomicEvent) return null; @@ -458,9 +487,32 @@ } public Event removePendingEvent(String pendingId) { - return PE.remove(pendingId); + Event e = PE.remove(pendingId); + if (e != null && listeners != null && e.getIntention() != null) + for (CircumstanceListener el : listeners) + el.intentionDropped(e.getIntention()); + return e; } + public void removePendingEvents(Trigger te, Unifier un) { + Iterator<Event> ie = PE.values().iterator(); + while (ie.hasNext()) { + Event ev = ie.next(); + Trigger t = ev.getTrigger(); + if (ev.getIntention() != Intention.EmptyInt) { // since the unifier of the intention will not be used, apply it to the event before comparing to the event to be dropped + t = t.capply(ev.getIntention().peek().getUnif()); + } + if (un.clone().unifiesNoUndo(te, t)) { + ie.remove(); + + if (listeners != null && ev.getIntention() != null) + for (CircumstanceListener el : listeners) + el.intentionDropped(ev.getIntention()); + } + } + + } + /** actions */ public ActionExec getAction() { Modified: trunk/src/jason/stdlib/drop_desire.java =================================================================== --- trunk/src/jason/stdlib/drop_desire.java 2015-03-02 11:44:12 UTC (rev 1822) +++ trunk/src/jason/stdlib/drop_desire.java 2015-03-06 22:09:17 UTC (rev 1823) @@ -24,8 +24,6 @@ package jason.stdlib; import jason.asSemantics.Circumstance; -import jason.asSemantics.Event; -import jason.asSemantics.Intention; import jason.asSemantics.TransitionSystem; import jason.asSemantics.Unifier; import jason.asSyntax.Literal; @@ -34,9 +32,7 @@ import jason.asSyntax.Trigger.TEOperator; import jason.asSyntax.Trigger.TEType; -import java.util.Iterator; - /** <p>Internal action: <b><code>.drop_desire(<i>D</i>)</code></b>. @@ -85,12 +81,15 @@ Trigger te = new Trigger(TEOperator.add, TEType.achieve, l); // search in E - dropEvt(te, un, C.getEventsPlusAtomic()); + C.removeEvents(te, un); + //dropEvt(te, un, C.getEventsPlusAtomic()); - // search in PE (only the event need to be checked, the related intention is handeled by dropInt) - dropEvt(te, un, C.getPendingEvents().values().iterator()); + // search in PE (only the event need to be checked, the related intention is handled by dropInt) + C.removePendingEvents(te, un); + //dropEvt(te, un, C.getPendingEvents().values().iterator()); } + /* moved to circumstance private static void dropEvt(Trigger te, Unifier un, Iterator<Event> ie) { while (ie.hasNext()) { Event ei = ie.next(); @@ -102,5 +101,5 @@ ie.remove(); } } - } + }*/ } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2015-03-02 11:44:20
|
Revision: 1822 http://sourceforge.net/p/jason/svn/1822 Author: jomifred Date: 2015-03-02 11:44:12 +0000 (Mon, 02 Mar 2015) Log Message: ----------- update release notes Modified Paths: -------------- trunk/build.xml trunk/examples/domestic-robot/HouseView.java trunk/release-notes.txt Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2015-03-02 11:20:49 UTC (rev 1821) +++ trunk/build.xml 2015-03-02 11:44:12 UTC (rev 1822) @@ -13,7 +13,7 @@ <property name="dist.properties" value="${basedir}/bin/dist.properties" /> <property name="version" value="1" /> - <property name="release" value="4.1" /> + <property name="release" value="4.2" /> <property name="distDir" value="${env.HOME}/tmp/x/Jason-${version}.${release}" /> <property name="distFile" value="${env.HOME}/Jason-${version}.${release}" /> @@ -187,7 +187,7 @@ <attribute name="Main-Class" value="jason.infra.centralised.RunCentralisedMAS"/> </manifest> </jar> - <!--delete file="default.mas2j" /--> + <delete file="default.mas2j" /> </target> <target name="signjar" depends="jar"> Modified: trunk/examples/domestic-robot/HouseView.java =================================================================== --- trunk/examples/domestic-robot/HouseView.java 2015-03-02 11:20:49 UTC (rev 1821) +++ trunk/examples/domestic-robot/HouseView.java 2015-03-02 11:44:12 UTC (rev 1822) @@ -43,7 +43,7 @@ drawString(g, x, y, defaultFont, o); break; } - repaint(); + repaint(); } @Override Modified: trunk/release-notes.txt =================================================================== --- trunk/release-notes.txt 2015-03-02 11:20:49 UTC (rev 1821) +++ trunk/release-notes.txt 2015-03-02 11:44:12 UTC (rev 1822) @@ -1,11 +1,13 @@ --------------------------- version 1.4.2 -revision XXX on SVN +revision 1821 on SVN --------------------------- New features - REPL button on MASConsole and jason-repl.jar + this feature allows the user to easily create + and run agents while the MAS is running --------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2015-03-02 11:20:56
|
Revision: 1821 http://sourceforge.net/p/jason/svn/1821 Author: jomifred Date: 2015-03-02 11:20:49 +0000 (Mon, 02 Mar 2015) Log Message: ----------- fix link in doc/index.html Modified Paths: -------------- trunk/doc/index.html Modified: trunk/doc/index.html =================================================================== --- trunk/doc/index.html 2015-02-25 12:34:59 UTC (rev 1820) +++ trunk/doc/index.html 2015-03-02 11:20:49 UTC (rev 1821) @@ -9,14 +9,14 @@ Local documentation: <ul> -<li><a href="Jason.pdf">Manual</a> (pdf)</li><br/> +<li><a href="Jason.pdf">First Manual</a> (pdf)</li><br/> <li><a href="mini-tutorial/getting-started/index.html">Getting Started with <b><i>Jason</i></b></a> (html)</li> <li><a href="mini-tutorial/jason-jade/index.html">Interoperating <b><i>Jason</i></b> and JADE</a> (mini-tutorial -- html)</li><br> <li><a href="faq.html">FAQ</a> (html)</li><br/> -<li><a href="api/jason/stdlib/package-summary.html#package_description">Stantard internal actions</a> (html)</li> +<li><a href="api/jason/stdlib/package-summary.html#package.description">Stantard internal actions</a> (html)</li> <li><a href="api/jason/functions/package-summary.html">Stantard arithmetic functions</a> (html)</li> <li>API of all classes: generated by <a href="api/index.html">JavaDoc</a>.</li><br> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2015-02-25 12:35:07
|
Revision: 1820 http://sourceforge.net/p/jason/svn/1820 Author: jomifred Date: 2015-02-25 12:34:59 +0000 (Wed, 25 Feb 2015) Log Message: ----------- update EIS Modified Paths: -------------- trunk/applications/eis-jason/Carriage-1agent.mas2j trunk/applications/eis-jason/Carriage-2agents.mas2j trunk/applications/eis-jason/build.xml trunk/applications/eis-jason/examples/elevator/elevator.mas2j trunk/applications/eis-jason/src/asl/robot2.asl trunk/applications/eis-jason/src/java/jason/eis/EISAdapter.java trunk/examples/cleaning-robots/MarsEnv.java trunk/examples/cleaning-robots/r1.asl trunk/examples/domestic-robot/HouseView.java trunk/examples/domestic-robot/owner.asl trunk/lib/c4jason.jar Modified: trunk/applications/eis-jason/Carriage-1agent.mas2j =================================================================== --- trunk/applications/eis-jason/Carriage-1agent.mas2j 2014-12-10 20:42:30 UTC (rev 1819) +++ trunk/applications/eis-jason/Carriage-1agent.mas2j 2015-02-25 12:34:59 UTC (rev 1820) @@ -1,22 +1,22 @@ -/* - Example of Jason EIS integration - - In this example one agent acts on two entities (robot1 and robot2) - - -- created on September 08, 2009 -*/ - -MAS demo1ag { - infrastructure: Centralised - - // Environment initialisation - environment: jason.eis.EISAdapter( - "lib/eiscarriage-0.3.jar", // jar file containing the environment implementation - agent_entity(robot,robot1), agent_entity(robot,robot2) // agent x entities relation - ) - - agents: - robot; - - aslSourcePath: "src/asl"; -} \ No newline at end of file +/* + Example of Jason EIS integration + + In this example one agent acts on two entities (robot1 and robot2) + + -- created on September 08, 2009 +*/ + +MAS demo1ag { + infrastructure: Centralised + + // Environment initialisation + environment: jason.eis.EISAdapter( + "lib/eiscarriage-0.3.jar", // jar file containing the environment implementation + agent_entity(robot,robot1), agent_entity(robot,robot2) // agent x entities relation + ) + + agents: + robot; + + aslSourcePath: "src/asl"; +} Modified: trunk/applications/eis-jason/Carriage-2agents.mas2j =================================================================== --- trunk/applications/eis-jason/Carriage-2agents.mas2j 2014-12-10 20:42:30 UTC (rev 1819) +++ trunk/applications/eis-jason/Carriage-2agents.mas2j 2015-02-25 12:34:59 UTC (rev 1820) @@ -1,24 +1,24 @@ -/* - Example of Jason EIS integration - - In this example there is one agent for each entity and they have - the same identities (agent is "robot1" and entity is "robot1") - - -- created on September 08, 2009 -*/ - -MAS demo2ag { - infrastructure: Centralised - - environment: jason.eis.EISAdapter( - "lib/eiscarriage-0.3.jar" // jar file containing the environment implementation - // agent x entities relation: - // agent_entity(robot1,robot1), agent_entity(robot2,robot2)) // the default relation: - ) - - agents: - robot1; - robot2; - - aslSourcePath: "src/asl"; -} \ No newline at end of file +/* + Example of Jason EIS integration + + In this example there is one agent for each entity and they have + the same identities (agent is "robot1" and entity is "robot1") + + -- created on September 08, 2009 +*/ + +MAS demo2ag { + infrastructure: Centralised + + environment: jason.eis.EISAdapter( + "lib/eiscarriage-0.3.jar" // jar file containing the environment implementation + // agent x entities relation: + // agent_entity(robot1,robot1), agent_entity(robot2,robot2)) // the default relation: + ) + + agents: + robot1; + robot2; + + aslSourcePath: "src/asl"; +} Modified: trunk/applications/eis-jason/build.xml =================================================================== (Binary files differ) Modified: trunk/applications/eis-jason/examples/elevator/elevator.mas2j =================================================================== --- trunk/applications/eis-jason/examples/elevator/elevator.mas2j 2014-12-10 20:42:30 UTC (rev 1819) +++ trunk/applications/eis-jason/examples/elevator/elevator.mas2j 2015-02-25 12:34:59 UTC (rev 1820) @@ -15,23 +15,23 @@ environment: jason.eis.EISAdapter( "lib/elevatorenv.jar", // EIS environment - agent_entity(ag1,car0), // entities, agent ag is responsible for elevator1 + agent_entity(ag1,car0), // entities, agent ag1 is responsible for elevator0 agent_entity(ag2,car1), agent_entity(ag3,car2), - map("Simulation","Random Rider Insertion"), - map("Floors",10), - map("Cars",3), - map("RandomSeed",635359), - map("Capacity",8), - map("People",20), - map("InsertionTime",50000), - map("TimeFactor",0), - map("Controller","EIS Controller"), - map("InsertionTimeHr","0.3"), - map("StandardDev",1), - map("NPeoplePerFloor",8), - map("Insert2ndReqAt", 29000) - ) + map("Simulation","Random Rider Insertion"), + map("Floors",10), + map("Cars",3), + map("RandomSeed",635359), + map("Capacity",8), + map("People",20), + map("InsertionTime",50000), + map("TimeFactor",0), + map("Controller","EIS Controller"), + map("InsertionTimeHr","0.3"), + map("StandardDev",1), + map("NPeoplePerFloor",8), + map("Insert2ndReqAt", 29000) + ) agents: ag #3; Modified: trunk/applications/eis-jason/src/asl/robot2.asl =================================================================== --- trunk/applications/eis-jason/src/asl/robot2.asl 2014-12-10 20:42:30 UTC (rev 1819) +++ trunk/applications/eis-jason/src/asl/robot2.asl 2015-02-25 12:34:59 UTC (rev 1820) @@ -10,4 +10,4 @@ +!start : true <- wait; push; !start. -+step(X) : carriagePos(C) <- .print("Step ",X,", carriage at ",C). \ No newline at end of file ++step(X) : carriagePos(C) <- .print("Step ",X,", carriage at ",C). Modified: trunk/applications/eis-jason/src/java/jason/eis/EISAdapter.java =================================================================== --- trunk/applications/eis-jason/src/java/jason/eis/EISAdapter.java 2014-12-10 20:42:30 UTC (rev 1819) +++ trunk/applications/eis-jason/src/java/jason/eis/EISAdapter.java 2015-02-25 12:34:59 UTC (rev 1820) @@ -77,7 +77,7 @@ Map<String,Parameter> initMapArgs = new HashMap<String, Parameter>(); List<String[]> agEnt = new ArrayList<String[]>(); - // identify initial paramaters + // identify initial parameters for (int i=1; i<args.length; i++) { Term t = ASSyntax.parseTerm(args[i]); if (t.isStructure()) { @@ -117,7 +117,7 @@ } } } else { - // associate agents to entities + // associate agents to entities for (String[] p: agEnt) { String agName = p[0]; if (!ei.getAgents().contains(agName)) { Modified: trunk/examples/cleaning-robots/MarsEnv.java =================================================================== --- trunk/examples/cleaning-robots/MarsEnv.java 2014-12-10 20:42:30 UTC (rev 1819) +++ trunk/examples/cleaning-robots/MarsEnv.java 2015-02-25 12:34:59 UTC (rev 1820) @@ -209,6 +209,7 @@ g.setColor(Color.white); } super.drawString(g, x, y, defaultFont, label); + repaint(); } public void drawGarb(Graphics g, int x, int y) { Modified: trunk/examples/cleaning-robots/r1.asl =================================================================== --- trunk/examples/cleaning-robots/r1.asl 2014-12-10 20:42:30 UTC (rev 1819) +++ trunk/examples/cleaning-robots/r1.asl 2015-02-25 12:34:59 UTC (rev 1820) @@ -12,14 +12,15 @@ +!check(slots) : not garbage(r1) <- next(slot); - !!check(slots). + !check(slots). +!check(slots). +@lg[atomic] +garbage(r1) : not .desire(carry_to(r2)) <- !carry_to(r2). -+!carry_to(R) ++!carry_to(R) <- // remember where to go back ?pos(r1,X,Y); -+pos(last,X,Y); @@ -29,7 +30,7 @@ // goes back and continue to check !at(last); - !!check(slots). + !check(slots). +!take(S,L) : true <- !ensure_pick(S); Modified: trunk/examples/domestic-robot/HouseView.java =================================================================== --- trunk/examples/domestic-robot/HouseView.java 2014-12-10 20:42:30 UTC (rev 1819) +++ trunk/examples/domestic-robot/HouseView.java 2015-02-25 12:34:59 UTC (rev 1820) @@ -43,6 +43,7 @@ drawString(g, x, y, defaultFont, o); break; } + repaint(); } @Override Modified: trunk/examples/domestic-robot/owner.asl =================================================================== --- trunk/examples/domestic-robot/owner.asl 2014-12-10 20:42:30 UTC (rev 1819) +++ trunk/examples/domestic-robot/owner.asl 2015-02-25 12:34:59 UTC (rev 1820) @@ -22,7 +22,7 @@ <- .random(X); .wait(X*5000+2000); // i get bored at random times .send(robot, askOne, time(_), R); // when bored, I ask the robot about the time .print(R); - !!check_bored. + !check_bored. +msg(M)[source(Ag)] : true <- .print("Message from ",Ag,": ",M); Modified: trunk/lib/c4jason.jar =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-12-10 20:42:33
|
Revision: 1819 http://sourceforge.net/p/jason/svn/1819 Author: jomifred Date: 2014-12-10 20:42:30 +0000 (Wed, 10 Dec 2014) Log Message: ----------- add EIS-jason Modified Paths: -------------- trunk/build.xml trunk/pom.xml Added Paths: ----------- trunk/applications/eis-jason/ trunk/applications/eis-jason/.classpath trunk/applications/eis-jason/.project trunk/applications/eis-jason/.settings/ trunk/applications/eis-jason/.settings/org.eclipse.jdt.core.prefs trunk/applications/eis-jason/Carriage-1agent.mas2j trunk/applications/eis-jason/Carriage-2agents.mas2j trunk/applications/eis-jason/build.xml trunk/applications/eis-jason/doc/ trunk/applications/eis-jason/doc/Makefile trunk/applications/eis-jason/doc/eis-jason.html trunk/applications/eis-jason/doc/eis-jason.tex trunk/applications/eis-jason/doc/jason.css trunk/applications/eis-jason/examples/ trunk/applications/eis-jason/examples/domestic-robot/ trunk/applications/eis-jason/examples/domestic-robot/DomesticRobot.mas2j trunk/applications/eis-jason/examples/domestic-robot/EISHouseEnv.java trunk/applications/eis-jason/examples/domestic-robot/HouseEnv.java trunk/applications/eis-jason/examples/domestic-robot/HouseModel.java trunk/applications/eis-jason/examples/domestic-robot/HouseView.java trunk/applications/eis-jason/examples/domestic-robot/build.xml trunk/applications/eis-jason/examples/domestic-robot/doc/ trunk/applications/eis-jason/examples/domestic-robot/doc/cdHouse.graffle trunk/applications/eis-jason/examples/domestic-robot/doc/cdHouse.pdf trunk/applications/eis-jason/examples/domestic-robot/doc/eis-doc.txt trunk/applications/eis-jason/examples/domestic-robot/doc/overview.png trunk/applications/eis-jason/examples/domestic-robot/eis-domestic-robot.jar trunk/applications/eis-jason/examples/domestic-robot/owner.asl trunk/applications/eis-jason/examples/domestic-robot/robot.asl trunk/applications/eis-jason/examples/domestic-robot/supermarket.asl trunk/applications/eis-jason/examples/domestic-robot/time/ trunk/applications/eis-jason/examples/domestic-robot/time/check.java trunk/applications/eis-jason/examples/elevator/ trunk/applications/eis-jason/examples/elevator/.classpath trunk/applications/eis-jason/examples/elevator/.project trunk/applications/eis-jason/examples/elevator/ElevatorEnvironment.pdf trunk/applications/eis-jason/examples/elevator/ag.asl trunk/applications/eis-jason/examples/elevator/elevator.mas2j trunk/applications/eis-jason/examples/elevator/lib/ trunk/applications/eis-jason/examples/elevator/lib/eis-0.3.jar trunk/applications/eis-jason/examples/elevator/lib/eis-jason.jar trunk/applications/eis-jason/examples/elevator/lib/elevatorenv.jar trunk/applications/eis-jason/lib/ trunk/applications/eis-jason/lib/eis-0.3.jar trunk/applications/eis-jason/lib/eis-jason.jar trunk/applications/eis-jason/lib/eiscarriage-0.3.jar trunk/applications/eis-jason/lib/jason.jar trunk/applications/eis-jason/readme.txt trunk/applications/eis-jason/src/ trunk/applications/eis-jason/src/asl/ trunk/applications/eis-jason/src/asl/robot.asl trunk/applications/eis-jason/src/asl/robot1.asl trunk/applications/eis-jason/src/asl/robot2.asl trunk/applications/eis-jason/src/java/ trunk/applications/eis-jason/src/java/jason/ trunk/applications/eis-jason/src/java/jason/eis/ trunk/applications/eis-jason/src/java/jason/eis/EISAdapter.java trunk/applications/eis-jason/src/java/jason/eis/JasonAdapter.java trunk/applications/eis-jason/src/java/jason/eis/Translator.java Added: trunk/applications/eis-jason/.classpath =================================================================== (Binary files differ) Index: trunk/applications/eis-jason/.classpath =================================================================== --- trunk/applications/eis-jason/.classpath 2014-11-03 10:51:43 UTC (rev 1818) +++ trunk/applications/eis-jason/.classpath 2014-12-10 20:42:30 UTC (rev 1819) Property changes on: trunk/applications/eis-jason/.classpath ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/xml \ No newline at end of property Added: trunk/applications/eis-jason/.project =================================================================== (Binary files differ) Index: trunk/applications/eis-jason/.project =================================================================== --- trunk/applications/eis-jason/.project 2014-11-03 10:51:43 UTC (rev 1818) +++ trunk/applications/eis-jason/.project 2014-12-10 20:42:30 UTC (rev 1819) Property changes on: trunk/applications/eis-jason/.project ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/xml \ No newline at end of property Added: trunk/applications/eis-jason/.settings/org.eclipse.jdt.core.prefs =================================================================== --- trunk/applications/eis-jason/.settings/org.eclipse.jdt.core.prefs (rev 0) +++ trunk/applications/eis-jason/.settings/org.eclipse.jdt.core.prefs 2014-12-10 20:42:30 UTC (rev 1819) @@ -0,0 +1,12 @@ +#Thu Feb 11 17:32:52 BRST 2010 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 Added: trunk/applications/eis-jason/Carriage-1agent.mas2j =================================================================== --- trunk/applications/eis-jason/Carriage-1agent.mas2j (rev 0) +++ trunk/applications/eis-jason/Carriage-1agent.mas2j 2014-12-10 20:42:30 UTC (rev 1819) @@ -0,0 +1,22 @@ +/* + Example of Jason EIS integration + + In this example one agent acts on two entities (robot1 and robot2) + + -- created on September 08, 2009 +*/ + +MAS demo1ag { + infrastructure: Centralised + + // Environment initialisation + environment: jason.eis.EISAdapter( + "lib/eiscarriage-0.3.jar", // jar file containing the environment implementation + agent_entity(robot,robot1), agent_entity(robot,robot2) // agent x entities relation + ) + + agents: + robot; + + aslSourcePath: "src/asl"; +} \ No newline at end of file Added: trunk/applications/eis-jason/Carriage-2agents.mas2j =================================================================== --- trunk/applications/eis-jason/Carriage-2agents.mas2j (rev 0) +++ trunk/applications/eis-jason/Carriage-2agents.mas2j 2014-12-10 20:42:30 UTC (rev 1819) @@ -0,0 +1,24 @@ +/* + Example of Jason EIS integration + + In this example there is one agent for each entity and they have + the same identities (agent is "robot1" and entity is "robot1") + + -- created on September 08, 2009 +*/ + +MAS demo2ag { + infrastructure: Centralised + + environment: jason.eis.EISAdapter( + "lib/eiscarriage-0.3.jar" // jar file containing the environment implementation + // agent x entities relation: + // agent_entity(robot1,robot1), agent_entity(robot2,robot2)) // the default relation: + ) + + agents: + robot1; + robot2; + + aslSourcePath: "src/asl"; +} \ No newline at end of file Added: trunk/applications/eis-jason/build.xml =================================================================== (Binary files differ) Index: trunk/applications/eis-jason/build.xml =================================================================== --- trunk/applications/eis-jason/build.xml 2014-11-03 10:51:43 UTC (rev 1818) +++ trunk/applications/eis-jason/build.xml 2014-12-10 20:42:30 UTC (rev 1819) Property changes on: trunk/applications/eis-jason/build.xml ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/xml \ No newline at end of property Added: trunk/applications/eis-jason/doc/Makefile =================================================================== --- trunk/applications/eis-jason/doc/Makefile (rev 0) +++ trunk/applications/eis-jason/doc/Makefile 2014-12-10 20:42:30 UTC (rev 1819) @@ -0,0 +1,19 @@ +TARGET = eis-jason + +html: $(TARGET).tex Makefile + latex2html -split 0 -style jason.css \ + -white -image_type=png \ + -dir html -mkdir -toc_stars \ + -show_section_numbers -noinfo -address "Jomi F. Hubner" -html_version 3.2,math \ + -no_navigation $(TARGET).tex + cp html/$(TARGET).html . + rm -rf html + +clean: + rm -f $(TARGET).ps *.log $(TARGET).aux $(TARGET).out || true + rm -rf auto || true + rm -rf *pdf || true + find . -name *bak -exec rm {} \; || true + find . -name *~ -exec rm {} \; || true + rm -rf html + Added: trunk/applications/eis-jason/doc/eis-jason.html =================================================================== --- trunk/applications/eis-jason/doc/eis-jason.html (rev 0) +++ trunk/applications/eis-jason/doc/eis-jason.html 2014-12-10 20:42:30 UTC (rev 1819) @@ -0,0 +1,390 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> + +<!--Converted with LaTeX2HTML 2008 (1.71) +original version by: Nikos Drakos, CBLU, University of Leeds +* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan +* with significant contributions from: + Jens Lippmann, Marek Rouchal, Martin Wilck and others --> +<HTML> +<HEAD> +<TITLE>Jason and EIS integration (release 0.3)</TITLE> +<META NAME="description" CONTENT="Jason and EIS integration (release 0.3)"> +<META NAME="resource-type" CONTENT="document"> +<META NAME="distribution" CONTENT="global"> + +<META NAME="Generator" CONTENT="LaTeX2HTML v2008"> +<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"> + +<LINK REL="STYLESHEET" HREF="jason.css"> + +</HEAD> + +<BODY > + +<P> + +<H1 ALIGN="CENTER">Jason and EIS integration +<BR><FONT SIZE="-1">(release 0.3)</FONT></H1> +<DIV> + +</DIV> + +<P> + +<H3>Abstract:</H3> +<DIV> +This document describes (i) how to use environments developed as + defined by the Environment Interface Standard + (<A HREF="http://cig.in.tu-clausthal.de/eis">EIS</A>) in + <A HREF="http://jason.sf.net">Jason</A> projects; and (ii) how Jason + environment can be adapted to be used as EIS environment. +</DIV> +<P> + +<P> +<BR> + +<H2><A NAME="SECTION00010000000000000000"> +Contents</A> +</H2> +<!--Table of Contents--> + +<UL> +<LI><A NAME="tex2html12" + HREF="eis-jason.html#SECTION00020000000000000000">Using EIS environments in Jason</A> +<UL> +<LI><A NAME="tex2html13" + HREF="eis-jason.html#SECTION00021000000000000000">Jason Project Definition</A> +<LI><A NAME="tex2html14" + HREF="eis-jason.html#SECTION00022000000000000000">Agent programming</A> +<LI><A NAME="tex2html15" + HREF="eis-jason.html#SECTION00023000000000000000">Code of robot1.asl in project demo2ag</A> +<LI><A NAME="tex2html16" + HREF="eis-jason.html#SECTION00024000000000000000">Code of robot2.asl in project demo2ag</A> +<LI><A NAME="tex2html17" + HREF="eis-jason.html#SECTION00025000000000000000">Code of robot.asl in project demo1ag</A> +<LI><A NAME="tex2html18" + HREF="eis-jason.html#SECTION00026000000000000000">How to create a project with Jason-EIS integration</A> +</UL> +<BR> +<LI><A NAME="tex2html19" + HREF="eis-jason.html#SECTION00030000000000000000">EISifying Jason environments</A> +<LI><A NAME="tex2html20" + HREF="eis-jason.html#SECTION00040000000000000000">Data Translation</A> +</UL> +<!--End of Table of Contents--> +<P> + +<H1><A NAME="SECTION00020000000000000000"> +Using EIS environments in Jason</A> +</H1> + +<P> +Jason projects can use EIS environments by means of the +EISAdapter. EISAdapter is a Jason environment, i.e. it follows all +requirements of an environment for Jason projects, that delegates +perception and action to an EIS environment. It basically maps agents +actions to EIS actions and gives EIS perception back to Jason agents. + +<P> + +<H2><A NAME="SECTION00021000000000000000"> +Jason Project Definition</A> +</H2> + +<P> +EIS has the concept of <I>entities</I> which are associated to agents +that can then control those entities. Since Jason does not have this +concept, we propose two solutions: + +<UL> +<LI>The relation agent-entity is very simple: each agent has exactly + one entity and their names are the same. In this case, the Jason + designer does not need to specify the relation. +</LI> +<LI>The designer defines all the relations in the project. +</LI> +</UL> + +<P> +The Carriage example is used in the sequence to illustrate the two +solutions (see EIS documentation for more details about this +environment). + +<P> +Using the first solution, the Jason project for the Carriage environment is: +<PRE> +MAS demo2ag { + infrastructure: Centralised + + environment: jason.eis.EISAdapter( + "lib/eis-0.2-carriage.jar" // jar file containing the + // environment implementation + ) + + agents: + robot1; + robot2; +} +</PRE> +Notice that the environment class is +<TT>jason.eis.EISAdapter</TT>. This class loads the EIS environment +provided in the jar file and delegates action/perception to +it. Regarding entities, each agent will control an entity that has the +same name as it, i.e. agent robot1 controls entity robot1 and agent +robot2 controls entity robot2. + +<P> +Using the second solution, the Jason project for the Carriage environment is: +<PRE> +MAS demo1ag { + infrastructure: Centralised + + environment: jason.eis.EISAdapter( + "lib/eis-0.2-carriage.jar" // jar file containing the + // environment implementation + agent_entity(robot,robot1), + agent_entity(robot,robot2) // agent x entities relation + ) + + agents: + robot; +} +</PRE> +In this case, the entities associated to each agent are explicitly +defined by pairs <agent>, <entity>. In the above example, agent robot +will control both entities of the environment. + +<P> +If parameters in the form ``id = value'' need to be used, the map +structure have to be used, for instance: +<PRE> +MAS wumpus { + + infrastructure: Centralised + + environment: jason.eis.EISAdapter( + "lib/wumpusenv.jar", // EIS environment + agent_entity(ag,agent), // entities + map(file,"maps/wumpus.kt5.wld")) // initialisation parameters + agents: + ag; +} +</PRE> + +<P> + +<H2><A NAME="SECTION00022000000000000000"> +Agent programming</A> +</H2> + +<P> +The agents are programmed as usual. When the agent needs to handle +entities, two solutions are implemented. + +<P> +<DL> +<DT><STRONG>perception</STRONG></DT> +<DD>every perception given by the EIS environment is + annotated with the entity that has produced the perception. E.g., + the perception in the Carriage example is: +<PRE> +carriagePos(2)[entity(robot2),source(percept)] +</PRE> + +<P> +</DD> +<DT><STRONG>action</STRONG></DT> +<DD>actions are sent to all entities by default, e.g.: +<PRE> +... push; ... +</PRE> + +<P> +When the programmer wants to define a target entity he/she has to + use a special action <TT>ae</TT> with to arguments: the action and + the entity (as string). E.g.: +<PRE> +ae(push,"robot1") +</PRE> +</DD> +</DL> + +<P> +As examples, it follows the code of the three agents used in the two +projects cited in the previous section. + +<P> + +<H2><A NAME="SECTION00023000000000000000"> +Code of robot1.asl in project demo2ag</A> +</H2> +<PRE> +!start. // initial goal + ++!start // plan to achieve the goal + <- push; // act on its entity + !!start. // continue doing the same +</PRE> +Notice that actions are used as usual in Jason. + +<P> + +<H2><A NAME="SECTION00024000000000000000"> +Code of robot2.asl in project demo2ag</A> +</H2> +<PRE> +!start. // initial goal + ++!start + <- wait; + push; + !!start. + ++step(X) : carriagePos(C) + <- .print("Step ",X,", carriage at ",C). +</PRE> + +<P> + +<H2><A NAME="SECTION00025000000000000000"> +Code of robot.asl in project demo1ag</A> +</H2> +<PRE> +!start1. // this agent has two intentions, one for each entity +!start2. + + ++!start1 <- ae(push,"robot1"); !!start1. // act on entity robot1 ++!start2 <- ae(wait,"robot2"); ae(push,"robot2"); !!start2. // act on entity robot2 + ++step(X) : carriagePos(C) + <- .print("Step ",X,", carriage at ",C). +</PRE> + +<P> + +<H2><A NAME="SECTION00026000000000000000"> +How to create a project with Jason-EIS integration</A> +</H2> + +<OL> +<LI>Copy eis.jar, eis-jason.jar and the environment .jar files to the lib directory of your project. +</LI> +<LI>Define the environment of Jason project as described in the second section of this document. + +<P> +</LI> +</OL> +<H1><A NAME="SECTION00030000000000000000"> +EISifying Jason environments</A> +</H1> + +<P> +Jason Environments (those defined to be included in Jason Projects) +can be used as an EIS environment quite easily. Only entities have to +be defined, since they do not belong to the Jason concept of environment. + +<P> +The domestic-robot example is used to illustrate the process. All the +code and more details are included in the JasonEIS 0.3 +(<TT><A NAME="tex2html1" + HREF="../examples/domestic-robot/doc/eis-doc.txt">../examples/domestic-robot/doc/eis-doc.txt</A></TT>). + +<P> +<DIV ALIGN="CENTER"> + + <IMG WIDTH="800" SRC="../examples/domestic-robot/doc/overview.png" /> + +</DIV> + +<P> +The following steps describes how to ``export'' a Jason Environment to EIS: + +<OL> +<LI>Create a new class that extends the Jason Adapter for EIS + environment. In its constructor instantiate the Jason Environment + class and define the entities: +<PRE> +public class EISHouseEnv extends JasonAdapter { + + public EISHouseEnv() { + jasonEnv = new HouseEnv(); // create the instance of Jason Environment + try { + addEntity("robot"); + addEntity("owner"); + addEntity("supermarket"); + } catch (EntityException e) { + e.printStackTrace(); + } + } + +} +</PRE> + The JasonAdapter class will be in charge to map perception and + action between Jason and EIS. It also maps the INIT command to the + init method in Jason environments and the KILL command to the stop + method. (The other commands are ignored since they do not have + counter part in Jason.) + +<P> +</LI> +<LI>Create a jar file that includes your new class, the Jason + classes, and the Jason-EIS classes. For instance (from build.xml of + domestic-robot): +<PRE> + <target name="jar" depends="compile"> + <delete file="${ant.project.name}.jar" /> + <copy file="${jasonJar}" tofile="${ant.project.name}.jar" /> + <jar update="yes" jarfile="${ant.project.name}.jar" > + <fileset dir="${build.dir}"> + <include name="**/*.class" /> + </fileset> + <fileset dir="${jason-eis-dir}/bin/classes"> + <include name="jason/**/*.class" /> + </fileset> + <manifest> + <attribute name="Main-Class" value="EISHouseEnv"/> + </manifest> + </jar> + </target> +</PRE> +</LI> +</OL> + +<P> + +<H1><A NAME="SECTION00040000000000000000"> +Data Translation</A> +</H1> + +<P> +Data types in EIS and Jason are different, they are so translated as +defined in the following table. + +<P> +<TABLE CELLPADDING=3 BORDER="1"> +<TR><TD ALIGN="CENTER"><I>Type in EIS</I></TD> +<TD ALIGN="CENTER"><I>Type in Jason</I></TD> +</TR> +<TR><TD ALIGN="CENTER">Identifier</TD> +<TD ALIGN="CENTER">Term</TD> +</TR> +<TR><TD ALIGN="CENTER">Numeral</TD> +<TD ALIGN="CENTER">NumberTerm</TD> +</TR> +<TR><TD ALIGN="CENTER">ParameterList</TD> +<TD ALIGN="CENTER">ListTerm</TD> +</TR> +<TR><TD ALIGN="CENTER">Function</TD> +<TD ALIGN="CENTER">Literal</TD> +</TR> +</TABLE> + +<P> +<BR><HR> +<ADDRESS> +Jomi F. Hubner +</ADDRESS> +</BODY> +</HTML> Added: trunk/applications/eis-jason/doc/eis-jason.tex =================================================================== --- trunk/applications/eis-jason/doc/eis-jason.tex (rev 0) +++ trunk/applications/eis-jason/doc/eis-jason.tex 2014-12-10 20:42:30 UTC (rev 1819) @@ -0,0 +1,268 @@ +\documentclass{article} +\usepackage{graphicx} +\usepackage{html} +\usepackage{hthtml} + + +\begin{document} + +\title{Jason and EIS integration \\\small{(release 0.3)}} +%\author{Jomi F. H\"ubner} +\maketitle + +\begin{abstract} + This document describes (i) how to use environments developed as + defined by the Environment Interface Standard + (\htlink{EIS}{http://cig.in.tu-clausthal.de/eis}) in + \htlink{Jason}{http://jason.sf.net} projects; and (ii) how Jason + environment can be adapted to be used as EIS environment. +\end{abstract} + +\tableofcontents + + +\section*{Using EIS environments in Jason} + +Jason projects can use EIS environments by means of the +EISAdapter. EISAdapter is a Jason environment, i.e. it follows all +requirements of an environment for Jason projects, that delegates +perception and action to an EIS environment. It basically maps agents +actions to EIS actions and gives EIS perception back to Jason agents. + + +\subsection*{Jason Project Definition} + +EIS has the concept of \emph{entities} which are associated to agents +that can then control those entities. Since Jason does not have this +concept, we propose two solutions: +\begin{itemize} +\item The relation agent-entity is very simple: each agent has exactly + one entity and their names are the same. In this case, the Jason + designer does not need to specify the relation. +\item The designer defines all the relations in the project. +\end{itemize} + +The Carriage example is used in the sequence to illustrate the two +solutions (see EIS documentation for more details about this +environment). + +Using the first solution, the Jason project for the Carriage environment is: +\begin{verbatim} +MAS demo2ag { + infrastructure: Centralised + + environment: jason.eis.EISAdapter( + "lib/eis-0.2-carriage.jar" // jar file containing the + // environment implementation + ) + + agents: + robot1; + robot2; +} +\end{verbatim} +Notice that the environment class is +\texttt{jason.eis.EISAdapter}. This class loads the EIS environment +provided in the jar file and delegates action/perception to +it. Regarding entities, each agent will control an entity that has the +same name as it, i.e. agent robot1 controls entity robot1 and agent +robot2 controls entity robot2. + +Using the second solution, the Jason project for the Carriage environment is: +\begin{verbatim} +MAS demo1ag { + infrastructure: Centralised + + environment: jason.eis.EISAdapter( + "lib/eis-0.2-carriage.jar" // jar file containing the + // environment implementation + agent_entity(robot,robot1), + agent_entity(robot,robot2) // agent x entities relation + ) + + agents: + robot; +} +\end{verbatim} +In this case, the entities associated to each agent are explicitly +defined by pairs <agent>, <entity>. In the above example, agent robot +will control both entities of the environment. + +If parameters in the form ``id = value'' need to be used, the map +structure have to be used, for instance: +\begin{verbatim} +MAS wumpus { + + infrastructure: Centralised + + environment: jason.eis.EISAdapter( + "lib/wumpusenv.jar", // EIS environment + agent_entity(ag,agent), // entities + map(file,"maps/wumpus.kt5.wld")) // initialisation parameters + agents: + ag; +} +\end{verbatim} + +\subsection*{Agent programming} + +The agents are programmed as usual. When the agent needs to handle +entities, two solutions are implemented. + +\begin{description} +\item[perception] every perception given by the EIS environment is + annotated with the entity that has produced the perception. E.g., + the perception in the Carriage example is: +\begin{verbatim} +carriagePos(2)[entity(robot2),source(percept)] +\end{verbatim} + +\item[action] actions are sent to all entities by default, e.g.: +\begin{verbatim} +... push; ... +\end{verbatim} + + When the programmer wants to define a target entity he/she has to + use a special action \texttt{ae} with to arguments: the action and + the entity (as string). E.g.: +\begin{verbatim} +ae(push,"robot1") +\end{verbatim} +\end{description} + +As examples, it follows the code of the three agents used in the two +projects cited in the previous section. + +\subsection*{Code of robot1.asl in project demo2ag} +\begin{verbatim} +!start. // initial goal + ++!start // plan to achieve the goal + <- push; // act on its entity + !!start. // continue doing the same +\end{verbatim} +Notice that actions are used as usual in Jason. + + +\subsection*{Code of robot2.asl in project demo2ag} +\begin{verbatim} +!start. // initial goal + ++!start + <- wait; + push; + !!start. + ++step(X) : carriagePos(C) + <- .print("Step ",X,", carriage at ",C). +\end{verbatim} + +\subsection*{Code of robot.asl in project demo1ag} +\begin{verbatim} +!start1. // this agent has two intentions, one for each entity +!start2. + + ++!start1 <- ae(push,"robot1"); !!start1. // act on entity robot1 ++!start2 <- ae(wait,"robot2"); ae(push,"robot2"); !!start2. // act on entity robot2 + ++step(X) : carriagePos(C) + <- .print("Step ",X,", carriage at ",C). +\end{verbatim} + +\subsection*{How to create a project with Jason-EIS integration} +\begin{enumerate} +\item Copy eis.jar, eis-jason.jar and the environment .jar files to the lib directory of your project. +\item Define the environment of Jason project as described in the second section of this document. +\end{itemize} + + +\section*{EISifying Jason environments} + +Jason Environments (those defined to be included in Jason Projects) +can be used as an EIS environment quite easily. Only entities have to +be defined, since they do not belong to the Jason concept of environment. + +The domestic-robot example is used to illustrate the process. All the +code and more details are included in the JasonEIS 0.3 +(\url{../examples/domestic-robot/doc/eis-doc.txt}). + +\begin{center} +\begin{rawhtml} + <IMG WIDTH="800" SRC="../examples/domestic-robot/doc/overview.png" /> +\end{rawhtml} +\end{center} + +The following steps describes how to ``export'' a Jason Environment to EIS: +\begin{enumerate} +\item Create a new class that extends the Jason Adapter for EIS + environment. In its constructor instantiate the Jason Environment + class and define the entities: +\begin{verbatim} +public class EISHouseEnv extends JasonAdapter { + + public EISHouseEnv() { + jasonEnv = new HouseEnv(); // create the instance of Jason Environment + try { + addEntity("robot"); + addEntity("owner"); + addEntity("supermarket"); + } catch (EntityException e) { + e.printStackTrace(); + } + } + +} +\end{verbatim} + The JasonAdapter class will be in charge to map perception and + action between Jason and EIS. It also maps the INIT command to the + init method in Jason environments and the KILL command to the stop + method. (The other commands are ignored since they do not have + counter part in Jason.) + +% Note that Jason Environments suppose that the init method is always +% called; while EIS defines INIT command as optional. The above +% solution guarantees that init will be called, but it can be called +% twice (in the constructor and by the INIT command). With that +% solution the Jason environment have to be prepared to have its init +% method called twice. + + +\item Create a jar file that includes your new class, the Jason + classes, and the Jason-EIS classes. For instance (from build.xml of + domestic-robot): +\begin{verbatim} + <target name="jar" depends="compile"> + <delete file="${ant.project.name}.jar" /> + <copy file="${jasonJar}" tofile="${ant.project.name}.jar" /> + <jar update="yes" jarfile="${ant.project.name}.jar" > + <fileset dir="${build.dir}"> + <include name="**/*.class" /> + </fileset> + <fileset dir="${jason-eis-dir}/bin/classes"> + <include name="jason/**/*.class" /> + </fileset> + <manifest> + <attribute name="Main-Class" value="EISHouseEnv"/> + </manifest> + </jar> + </target> +\end{verbatim} +\end{enumerate} + + + +\section*{Data Translation} + +Data types in EIS and Jason are different, they are so translated as +defined in the following table. + +\begin{tabular}{cc} + \emph{Type in EIS} & \emph{Type in Jason} \\ \hline + Identifier & Term \\ + Numeral & NumberTerm \\ + ParameterList & ListTerm \\ + Function & Literal +\end{tabular} + +\end{enumerate} Added: trunk/applications/eis-jason/doc/jason.css =================================================================== --- trunk/applications/eis-jason/doc/jason.css (rev 0) +++ trunk/applications/eis-jason/doc/jason.css 2014-12-10 20:42:30 UTC (rev 1819) @@ -0,0 +1,81 @@ +/* Century Schoolbook font is very similar to Computer Modern Math: cmmi */ +.MATH { font-family: "Century Schoolbook", serif; } +.MATH I { font-family: "Century Schoolbook", serif; font-shape: italic } +.BOLDMATH { font-family: "Century Schoolbook", serif; font-weight: bold } + +/* implement both fixed-size and relative sizes */ +SMALL.XTINY { font-size : xx-small } +SMALL.TINY { font-size : x-small } +SMALL.SCRIPTSIZE { font-size : smaller } +SMALL.FOOTNOTESIZE { font-size : small } +SMALL.SMALL { } +BIG.LARGE { } +BIG.XLARGE { font-size : large } +BIG.XXLARGE { font-size : x-large } +BIG.HUGE { font-size : larger } +BIG.XHUGE { font-size : xx-large } + +a { + text-decoration: none; +} + +/* Page background color */ +body { background-color: white; + font-family: verdana, arial, helvetica, sanserif; } +/* mathematics styles */ +DIV.displaymath { } /* math displays */ +TD.eqno { } /* equation-number cells */ + + +H0 { + color: black; + font-size: 170%; + text-align: center; + display: block; + border-top: 1px solid black; + border-bottom: 1px solid black; + + /*margin-left: -1em;*/ + padding-top: 20px; + padding-bottom: 20px; + padding-left: 10px; + padding-right: 10px; +} + +H1 { + color: darkblue; + font-size: 130%; + display: block; + text-align: left; + + padding-top: 10px; + padding-bottom: 0px; + /*padding-left: 10px; */ + padding-right: 10px; + /*margin-left: -1em;*/ + border-bottom: 1px solid black; +} + +H2 { + color: darkblue; + font-size: 110%; + display: block; + text-align: left; + + padding-top: 5px; + padding-bottom: 0px; + /*padding-left: 10px; */ + padding-right: 10px; + /*margin-left: -1em;*/ +} + +HR { width: 100%; height: 1px;} + +PRE +{ + padding: 1em; + white-space: pre; + background-color: #F8F8F8; + border: 1px solid black; + font-family: Courier, fixed, serif; +} Added: trunk/applications/eis-jason/examples/domestic-robot/DomesticRobot.mas2j =================================================================== --- trunk/applications/eis-jason/examples/domestic-robot/DomesticRobot.mas2j (rev 0) +++ trunk/applications/eis-jason/examples/domestic-robot/DomesticRobot.mas2j 2014-12-10 20:42:30 UTC (rev 1819) @@ -0,0 +1,25 @@ +/* Jason Project + + The environment is accessed by means of EIS + + Jason Agent -> EIS -> Jason Environment + +*/ + +MAS domestic_robot { + infrastructure: Centralised + + environment: jason.eis.EISAdapter( + "eis-domestic-robot.jar", // jar file containing the environment implementation + // agent x entities relation: + agent_entity(robot,robot), agent_entity(owner,owner), agent_entity(supermarket,supermarket), + // environment parameters + map(arg1,gui(on)) // replace for gui(off) to disable the environment GUI + ) + + agents: robot; + owner; + supermarket; + +} + Property changes on: trunk/applications/eis-jason/examples/domestic-robot/DomesticRobot.mas2j ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: trunk/applications/eis-jason/examples/domestic-robot/EISHouseEnv.java =================================================================== --- trunk/applications/eis-jason/examples/domestic-robot/EISHouseEnv.java (rev 0) +++ trunk/applications/eis-jason/examples/domestic-robot/EISHouseEnv.java 2014-12-10 20:42:30 UTC (rev 1819) @@ -0,0 +1,33 @@ +import jason.eis.JasonAdapter; +import eis.exceptions.EntityException; +import eis.iilang.Action; + + +public class EISHouseEnv extends JasonAdapter { + + public EISHouseEnv() { + jasonEnv = new HouseEnv(); // create the instance of Jason Environment + try { + addEntity("robot"); + addEntity("owner"); + addEntity("supermarket"); + } catch (EntityException e) { + e.printStackTrace(); + } + } + + @Override + protected boolean isSupportedByEntity(Action arg0, String arg1) { + return true; + } + + @Override + protected boolean isSupportedByEnvironment(Action arg0) { + return true; + } + + @Override + protected boolean isSupportedByType(Action arg0, String arg1) { + return true; + } +} Added: trunk/applications/eis-jason/examples/domestic-robot/HouseEnv.java =================================================================== --- trunk/applications/eis-jason/examples/domestic-robot/HouseEnv.java (rev 0) +++ trunk/applications/eis-jason/examples/domestic-robot/HouseEnv.java 2014-12-10 20:42:30 UTC (rev 1819) @@ -0,0 +1,128 @@ +import jason.asSyntax.*; +import jason.environment.Environment; +import jason.environment.grid.Location; +import java.util.logging.Logger; + +public class HouseEnv extends Environment { + + // common literals + public static final Literal of = Literal.parseLiteral("open(fridge)"); + public static final Literal clf = Literal.parseLiteral("close(fridge)"); + public static final Literal gb = Literal.parseLiteral("get(beer)"); + public static final Literal hb = Literal.parseLiteral("hand_in(beer)"); + public static final Literal sb = Literal.parseLiteral("sip(beer)"); + public static final Literal hob = Literal.parseLiteral("has(owner,beer)"); + + public static final Literal af = Literal.parseLiteral("at(robot,fridge)"); + public static final Literal ao = Literal.parseLiteral("at(robot,owner)"); + + static Logger logger = Logger.getLogger(HouseEnv.class.getName()); + + HouseModel model = null; // the model of the grid + HouseView view = null; + + @Override + public void init(String[] args) { + model = new HouseModel(); + if (args.length == 0 || args.length == 1 && !args[0].equals("gui(off)")) { + if (view != null) { // in case init is called twice + view.setVisible(false); + view.dispose(); + } + view = new HouseView(model); + model.setView(view); + } + + updatePercepts(); + } + + public void stop() { + if (view != null) { + view.setVisible(false); + view.dispose(); + } + } + + + /** creates the agents percepts based on the HouseModel */ + void updatePercepts() { + // clear the percepts of the agents + clearPercepts("robot"); + clearPercepts("owner"); + + // get the robot location + Location lRobot = model.getAgPos(0); + + // add agent location to its percepts + if (lRobot.equals(model.lFridge)) { + addPercept("robot", af); + } + if (lRobot.equals(model.lOwner)) { + addPercept("robot", ao); + } + + // add beer "status" the percepts + if (model.fridgeOpen) { + addPercept("robot", Literal.parseLiteral("stock(beer,"+model.availableBeers+")")); + } + if (model.sipCount > 0) { + addPercept("robot", hob); + addPercept("owner", hob); + } + } + + + @Override + public boolean executeAction(String ag, Structure action) { + System.out.println("["+ag+"] doing: "+action); + boolean result = false; + if (action.equals(of)) { // of = open(fridge) + result = model.openFridge(); + + } else if (action.equals(clf)) { // clf = close(fridge) + result = model.closeFridge(); + + } else if (action.getFunctor().equals("move_towards")) { + String l = action.getTerm(0).toString(); + Location dest = null; + if (l.equals("fridge")) { + dest = model.lFridge; + } else if (l.equals("owner")) { + dest = model.lOwner; + } + + try { + result = model.moveTowards(dest); + } catch (Exception e) { + e.printStackTrace(); + } + + } else if (action.equals(gb)) { + result = model.getBeer(); + + } else if (action.equals(hb)) { + result = model.handInBeer(); + + } else if (action.equals(sb)) { + result = model.sipBeer(); + + } else if (action.getFunctor().equals("deliver")) { + // wait 4 seconds to finish "deliver" + try { + Thread.sleep(4000); + result = model.addBeer( (int)((NumberTerm)action.getTerm(1)).solve()); + } catch (Exception e) { + logger.info("Failed to execute action deliver!"+e); + } + + } else { + logger.info("Failed to execute action "+action); + } + + if (result) { + updatePercepts(); + try { Thread.sleep(100); } catch (Exception e) {} + } + return result; + } +} Property changes on: trunk/applications/eis-jason/examples/domestic-robot/HouseEnv.java ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: trunk/applications/eis-jason/examples/domestic-robot/HouseModel.java =================================================================== --- trunk/applications/eis-jason/examples/domestic-robot/HouseModel.java (rev 0) +++ trunk/applications/eis-jason/examples/domestic-robot/HouseModel.java 2014-12-10 20:42:30 UTC (rev 1819) @@ -0,0 +1,110 @@ +import jason.environment.grid.GridWorldModel; +import jason.environment.grid.Location; + +/** class that implements the Model of Domestic Robot application */ +public class HouseModel extends GridWorldModel { + + // constants for the grid objects + public static final int FRIDGE = 16; + public static final int OWNER = 32; + + // the grid size + public static final int GSize = 7; + + boolean fridgeOpen = false; // whether the fridge is open + boolean carryingBeer = false; // whether the robot is carrying beer + int sipCount = 0; // how many sip the owner did + int availableBeers = 2; // how many beers are available + + Location lFridge = new Location(0,0); + Location lOwner = new Location(GSize-1,GSize-1); + + public HouseModel() { + // create a 7x7 grid with one mobile agent + super(GSize, GSize, 1); + + // initial location of robot (column 3, line 3) + // ag code 0 means the robot + setAgPos(0, GSize/2, GSize/2); + + // initial location of fridge and owner + add(FRIDGE, lFridge); + add(OWNER, lOwner); + } + + boolean openFridge() { + if (!fridgeOpen) { + fridgeOpen = true; + return true; + } else { + return false; + } + } + + boolean closeFridge() { + if (fridgeOpen) { + fridgeOpen = false; + return true; + } else { + return false; + } + } + + boolean moveTowards(Location dest) { + Location r1 = getAgPos(0); + if (r1.x < dest.x) r1.x++; + else if (r1.x > dest.x) r1.x--; + if (r1.y < dest.y) r1.y++; + else if (r1.y > dest.y) r1.y--; + setAgPos(0, r1); // move the robot in the grid + + // repaint the fridge and owner locations + if (view != null) { + view.update(lFridge.x,lFridge.y); + view.update(lOwner.x,lOwner.y); + } + return true; + } + + boolean getBeer() { + if (fridgeOpen && availableBeers > 0 && !carryingBeer) { + availableBeers--; + carryingBeer = true; + if (view != null) + view.update(lFridge.x,lFridge.y); + return true; + } else { + return false; + } + } + + boolean addBeer(int n) { + availableBeers += n; + if (view != null) + view.update(lFridge.x,lFridge.y); + return true; + } + + boolean handInBeer() { + if (carryingBeer) { + sipCount = 10; + carryingBeer = false; + if (view != null) + view.update(lOwner.x,lOwner.y); + return true; + } else { + return false; + } + } + + boolean sipBeer() { + if (sipCount > 0) { + sipCount--; + if (view != null) + view.update(lOwner.x,lOwner.y); + return true; + } else { + return false; + } + } +} Added: trunk/applications/eis-jason/examples/domestic-robot/HouseView.java =================================================================== --- trunk/applications/eis-jason/examples/domestic-robot/HouseView.java (rev 0) +++ trunk/applications/eis-jason/examples/domestic-robot/HouseView.java 2014-12-10 20:42:30 UTC (rev 1819) @@ -0,0 +1,59 @@ +import jason.environment.grid.*; + +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics; + + +/** class that implements the View of Domestic Robot application */ +public class HouseView extends GridWorldView { + + HouseModel hmodel; + + public HouseView(HouseModel model) { + super(model, "Domestic Robot", 700); + hmodel = model; + defaultFont = new Font("Arial", Font.BOLD, 16); // change default font + setVisible(true); + repaint(); + } + + /** draw application objects */ + @Override + public void draw(Graphics g, int x, int y, int object) { + Location lRobot = hmodel.getAgPos(0); + super.drawAgent(g, x, y, Color.lightGray, -1); + switch (object) { + case HouseModel.FRIDGE: + if (lRobot.equals(hmodel.lFridge)) { + super.drawAgent(g, x, y, Color.yellow, -1); + } + g.setColor(Color.black); + drawString(g, x, y, defaultFont, "Fridge ("+hmodel.availableBeers+")"); + break; + case HouseModel.OWNER: + if (lRobot.equals(hmodel.lOwner)) { + super.drawAgent(g, x, y, Color.yellow, -1); + } + String o = "Owner"; + if (hmodel.sipCount > 0) { + o += " ("+hmodel.sipCount+")"; + } + g.setColor(Color.black); + drawString(g, x, y, defaultFont, o); + break; + } + } + + @Override + public void drawAgent(Graphics g, int x, int y, Color c, int id) { + Location lRobot = hmodel.getAgPos(0); + if (!lRobot.equals(hmodel.lOwner) && !lRobot.equals(hmodel.lFridge)) { + c = Color.yellow; + if (hmodel.carryingBeer) c = Color.orange; + super.drawAgent(g, x, y, c, -1); + g.setColor(Color.black); + super.drawString(g, x, y, defaultFont, "Robot"); + } + } +} Added: trunk/applications/eis-jason/examples/domestic-robot/build.xml =================================================================== (Binary files differ) Index: trunk/applications/eis-jason/examples/domestic-robot/build.xml =================================================================== --- trunk/applications/eis-jason/examples/domestic-robot/build.xml 2014-11-03 10:51:43 UTC (rev 1818) +++ trunk/applications/eis-jason/examples/domestic-robot/build.xml 2014-12-10 20:42:30 UTC (rev 1819) Property changes on: trunk/applications/eis-jason/examples/domestic-robot/build.xml ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/xml \ No newline at end of property Added: trunk/applications/eis-jason/examples/domestic-robot/doc/cdHouse.graffle =================================================================== (Binary files differ) Index: trunk/applications/eis-jason/examples/domestic-robot/doc/cdHouse.graffle =================================================================== --- trunk/applications/eis-jason/examples/domestic-robot/doc/cdHouse.graffle 2014-11-03 10:51:43 UTC (rev 1818) +++ trunk/applications/eis-jason/examples/domestic-robot/doc/cdHouse.graffle 2014-12-10 20:42:30 UTC (rev 1819) Property changes on: trunk/applications/eis-jason/examples/domestic-robot/doc/cdHouse.graffle ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +application/xml \ No newline at end of property Added: trunk/applications/eis-jason/examples/domestic-robot/doc/cdHouse.pdf =================================================================== (Binary files differ) Index: trunk/applications/eis-jason/examples/domestic-robot/doc/cdHouse.pdf =================================================================== --- trunk/applications/eis-jason/examples/domestic-robot/doc/cdHouse.pdf 2014-11-03 10:51:43 UTC (rev 1818) +++ trunk/applications/eis-jason/examples/domestic-robot/doc/cdHouse.pdf 2014-12-10 20:42:30 UTC (rev 1819) Property changes on: trunk/applications/eis-jason/examples/domestic-robot/doc/cdHouse.pdf ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/pdf \ No newline at end of property Added: trunk/applications/eis-jason/examples/domestic-robot/doc/eis-doc.txt =================================================================== --- trunk/applications/eis-jason/examples/domestic-robot/doc/eis-doc.txt (rev 0) +++ trunk/applications/eis-jason/examples/domestic-robot/doc/eis-doc.txt 2014-12-10 20:42:30 UTC (rev 1819) @@ -0,0 +1,68 @@ +EIS Documentation for Domestic-Robot environment +------------------------------------------------ + +* Environment description + +A domestic robot has the goal of serving beer to its owner. Its +mission is quite simple, it just receives some beer requests from the +owner, goes to the fridge, takes out a bottle of beer, and brings it +back to the owner. However, the robot should also be concerned with +the beer stock (and eventually order more beer using the supermarket� its +home delivery service) and some rules hard-wired into the robot by +the Department of Health (in this example this rule defines the limit +of daily beer consumption). + +A more detailed description is provided in the Jason Book, chapter 3. + +* Jar-file: eis-documestic-robot.jar + +* Entities: one robot, one owner, and one supermarket + +* Actions + + (see overview.png for a Prometheus diagram) + +- for entity robot: + - open(fridge) + - get(beer) + - close(fridge) + - hand_in(beer) + - move_towards(Place) + +- for entity owner + - sip(beer) + +- for entity supermarket + - deliver(beer,N) + +Most of the actions have obvious meanings, except perhaps +move_towards. Again, to simplify the example, the way the robot moves +in the house is greatly simplified. We assume that when it performs +the action move_towards(fridge), its hardware (or the simulator) +performs one step towards the fridge, so the robot does not need to be +concerned with the path to reach the fridge. + +* Percepts + +- at(robot,Place): to simplify the example, only two places are + perceived: fridge (when the robot is in front of the fridge) and + owner (when the robot is next to the owner). Thus, depending on its + location in the house, the robot will perceive either + at(robot,fridge) or at(robot,owner), or of course no at percept at + all (in case it is in neither of those places). + +- stock(beer,N): when the fridge is open, the robot will perceive how + many beers are stored in the fridge (the quantity is represented by + the variable N). + +- has(owner,beer): is perceived by the robot and the owner when the + owner has a (non-empty) bottle of beer. + + +* Environment-management + +The environment supports INIT commands with one parameter: "gui(on)" or +"gui(off)". This parameter creates or not the GUI of the environment. + +The KILL command is also supported and simply closes the GUI window. + Added: trunk/applications/eis-jason/examples/domestic-robot/doc/overview.png =================================================================== (Binary files differ) Index: trunk/applications/eis-jason/examples/domestic-robot/doc/overview.png =================================================================== --- trunk/applications/eis-jason/examples/domestic-robot/doc/overview.png 2014-11-03 10:51:43 UTC (rev 1818) +++ trunk/applications/eis-jason/examples/domestic-robot/doc/overview.png 2014-12-10 20:42:30 UTC (rev 1819) Property changes on: trunk/applications/eis-jason/examples/domestic-robot/doc/overview.png ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +image/png \ No newline at end of property Added: trunk/applications/eis-jason/examples/domestic-robot/eis-domestic-robot.jar =================================================================== (Binary files differ) Index: trunk/applications/eis-jason/examples/domestic-robot/eis-domestic-robot.jar =================================================================== --- trunk/applications/eis-jason/examples/domestic-robot/eis-domestic-robot.jar 2014-11-03 10:51:43 UTC (rev 1818) +++ trunk/applications/eis-jason/examples/domestic-robot/eis-domestic-robot.jar 2014-12-10 20:42:30 UTC (rev 1819) Property changes on: trunk/applications/eis-jason/examples/domestic-robot/eis-domestic-robot.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/java-archive \ No newline at end of property Added: trunk/applications/eis-jason/examples/domestic-robot/owner.asl =================================================================== --- trunk/applications/eis-jason/examples/domestic-robot/owner.asl (rev 0) +++ trunk/applications/eis-jason/examples/domestic-robot/owner.asl 2014-12-10 20:42:30 UTC (rev 1819) @@ -0,0 +1,30 @@ +/* Initial goals */ + +!get(beer). // initial goal: get a beer +!check_bored. // initial goal: verify whether I am getting bored + ++!get(beer) : true + <- .send(robot, achieve, has(owner,beer)). + ++has(owner,beer) : true + <- !drink(beer). +-has(owner,beer) : true + <- !get(beer). + +// while I have beer, sip ++!drink(beer) : has(owner,beer) + <- sip(beer); + !drink(beer). ++!drink(beer) : not has(owner,beer) + <- true. + ++!check_bored : true + <- .random(X); .wait(X*5000+2000); // i get bored at random times + .send(robot, askOne, time(_), R); // when bored, I ask the robot about the time + .print(R); + !!check_bored. + ++msg(M)[source(Ag)] : true + <- .print("Message from ",Ag,": ",M); + -msg(M). + Property changes on: trunk/applications/eis-jason/examples/domestic-robot/owner.asl ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: trunk/applications/eis-jason/examples/domestic-robot/robot.asl =================================================================== --- trunk/applications/eis-jason/examples/domestic-robot/robot.asl (rev 0) +++ trunk/applications/eis-jason/examples/domestic-robot/robot.asl 2014-12-10 20:42:30 UTC (rev 1819) @@ -0,0 +1,70 @@ +/* Initial beliefs and rules */ + +// initially, I believe that there is some beer in the fridge +available(beer,fridge). + +// my owner should not consume more than 10 beers a day :-) +limit(beer,10). + +too_much(B) :- + .date(YY,MM,DD) & + .count(consumed(YY,MM,DD,_,_,_,B),QtdB) & + limit(B,Limit) & + QtdB > Limit. + + +/* Plans */ + ++!has(owner,beer) + : available(beer,fridge) & not too_much(beer) + <- !at(robot,fridge); + open(fridge); + get(beer); + close(fridge); + !at(robot,owner); + hand_in(beer); + //?has(owner,beer); + // remember that another beer has been consumed + .date(YY,MM,DD); .time(HH,NN,SS); + +consumed(YY,MM,DD,HH,NN,SS,beer). + ++!has(owner,beer) + : not available(beer,fridge) + <- .send(supermarket, achieve, order(beer,5)); + !at(robot,fridge). // go to fridge and wait there. + ++!has(owner,beer) + : too_much(beer) & limit(beer,L) + <- .concat("The Department of Health does not allow me to give you more than ", L, + " beers a day! I am very sorry about that!",M); + .send(owner,tell,msg(M)). + + +-!has(_,_)[code_line(CL)] + : true + <- .current_intention(I); + .print("Failed to achieve goal '!has(_,_)'. Line: ",CL,". Current intention is: ",I). + ++!at(robot,P) : at(robot,P) <- true. ++!at(robot,P) : not at(robot,P) + <- move_towards(P); + !at(robot,P). + +// when the supermarket makes a delivery, try the 'has' goal again ++delivered(beer,_Qtd,_OrderId)[source(supermarket)] + : true + <- +available(beer,fridge); + !has(owner,beer). + +// when the fridge is opened, the beer stock is perceived +// and thus the available belief is updated ++stock(beer,0) + : available(beer,fridge) + <- -available(beer,fridge). ++stock(beer,N) + : N > 0 & not available(beer,fridge) + <- -+available(beer,fridge). + ++?time(T) : true + <- time.check(T). + Property changes on: trunk/applications/eis-jason/examples/domestic-robot/robot.asl ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: trunk/applications/eis-jason/examples/domestic-robot/supermarket.asl =================================================================== --- trunk/applications/eis-jason/examples/domestic-robot/supermarket.asl (rev 0) +++ trunk/applications/eis-jason/examples/domestic-robot/supermarket.asl 2014-12-10 20:42:30 UTC (rev 1819) @@ -0,0 +1,10 @@ +last_order_id(1). // initial belief + +// plan to achieve the goal "order" for agent Ag ++!order(Product,Qtd)[source(Ag)] : true + <- ?last_order_id(N); + OrderId = N + 1; + -+last_order_id(OrderId); + deliver(Product,Qtd); + .send(Ag, tell, delivered(Product,Qtd,OrderId)). + Property changes on: trunk/applications/eis-jason/examples/domestic-robot/supermarket.asl ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: trunk/applications/eis-jason/examples/domestic-robot/time/check.java =================================================================== --- trunk/applications/eis-jason/examples/domestic-robot/time/check.java (rev 0) +++ trunk/applications/eis-jason/examples/domestic-robot/time/check.java 2014-12-10 20:42:30 UTC (rev 1819) @@ -0,0 +1,21 @@ +package time; + +import jason.asSemantics.DefaultInternalAction; +import jason.asSemantics.TransitionSystem; +import jason.asSemantics.Unifier; +import jason.asSyntax.StringTermImpl; +import jason.asSyntax.Term; + +import java.text.SimpleDateFormat; +import java.util.Date; + +public class check extends DefaultInternalAction { + + @Override + public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception { + String time = (new SimpleDateFormat("HH:mm:ss")).format(new Date()); + ts.getLogger().info("Check Time="+time); + return un.unifies(args[0], new StringTermImpl(time)); + } +} + Property changes on: trunk/applications/eis-jason/examples/domestic-robot/time/check.java ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: trunk/applications/eis-jason/examples/elevator/.classpath =================================================================== (Binary files differ) Index: trunk/applications/eis-jason/examples/elevator/.classpath =================================================================== --- trunk/applications/eis-jason/examples/elevator/.classpath 2014-11-03 10:51:43 UTC (rev 1818) +++ trunk/applications/eis-jason/examples/elevator/.classpath 2014-12-10 20:42:30 UTC (rev 1819) Property changes on: trunk/applications/eis-jason/examples/elevator/.classpath ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/xml \ No newline at end of property Added: trunk/applications/eis-jason/examples/elevator/.project =================================================================== (Binary files differ) Index: trunk/applications/eis-jason/examples/elevator/.project =================================================================== --- trunk/applications/eis-jason/examples/elevator/.project 2014-11-03 10:51:43 UTC (rev 1818) +++ trunk/applications/eis-jason/examples/elevator/.project 2014-12-10 20:42:30 UTC (rev 1819) Property changes on: trunk/applications/eis-jason/examples/elevator/.project ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/xml \ No newline at end of property Added: trunk/applications/eis-jason/examples/elevator/ElevatorEnvironment.pdf =================================================================== (Binary files differ) Index: trunk/applications/eis-jason/examples/elevator/ElevatorEnvironment.pdf =================================================================== --- trunk/applications/eis-jason/examples/elevator/ElevatorEnvironment.pdf 2014-11-03 10:51:43 UTC (rev 1818) +++ trunk/applications/eis-jason/examples/elevator/ElevatorEnvironment.pdf 2014-12-10 20:42:30 UTC (rev 1819) Property changes on: trunk/applications/eis-jason/examples/elevator/ElevatorEnvironment.pdf ____________... [truncated message content] |
From: <jom...@us...> - 2014-11-03 10:51:52
|
Revision: 1818 http://sourceforge.net/p/jason/svn/1818 Author: jomifred Date: 2014-11-03 10:51:43 +0000 (Mon, 03 Nov 2014) Log Message: ----------- copy hash code while clonning Modified Paths: -------------- trunk/src/jason/asSemantics/Agent.java trunk/src/jason/asSyntax/ListTermImpl.java trunk/src/jason/asSyntax/LiteralImpl.java trunk/src/jason/asSyntax/PredicateIndicator.java trunk/src/jason/asSyntax/Structure.java trunk/src/jason/asSyntax/UnnamedVar.java trunk/src/jason/asSyntax/VarTerm.java Modified: trunk/src/jason/asSemantics/Agent.java =================================================================== --- trunk/src/jason/asSemantics/Agent.java 2014-10-19 18:06:01 UTC (rev 1817) +++ trunk/src/jason/asSemantics/Agent.java 2014-11-03 10:51:43 UTC (rev 1818) @@ -508,14 +508,14 @@ // if l is not a rule and has free vars (like l(X)), convert it into a rule like "l(X) :- true." if (!b.isRule() && !b.isGround()) b = new Rule(b,Literal.LTrue); - - b = (Literal)b.capply(null); // to solve arithmetic expressions // does not do BRF for rules (and so do not produce events +bel for rules) - if (b.isRule()) + if (b.isRule()) { getBB().add(b); - else + } else { + b = (Literal)b.capply(null); // to solve arithmetic expressions addBel(b); + } } initialBels.clear(); } Modified: trunk/src/jason/asSyntax/ListTermImpl.java =================================================================== --- trunk/src/jason/asSyntax/ListTermImpl.java 2014-10-19 18:06:01 UTC (rev 1817) +++ trunk/src/jason/asSyntax/ListTermImpl.java 2014-11-03 10:51:43 UTC (rev 1818) @@ -89,6 +89,7 @@ ListTermImpl t = new ListTermImpl(); if (term != null) t.term = this.term.clone(); if (next != null) t.next = this.next.clone(); + t.hashCodeCache = this.hashCodeCache; return t; } Modified: trunk/src/jason/asSyntax/LiteralImpl.java =================================================================== --- trunk/src/jason/asSyntax/LiteralImpl.java 2014-10-19 18:06:01 UTC (rev 1817) +++ trunk/src/jason/asSyntax/LiteralImpl.java 2014-11-03 10:51:43 UTC (rev 1818) @@ -130,7 +130,9 @@ @Override public Term clone() { - return new LiteralImpl(this); + Literal l = new LiteralImpl(this); + l.hashCodeCache = this.hashCodeCache; + return l; } @Override Modified: trunk/src/jason/asSyntax/PredicateIndicator.java =================================================================== --- trunk/src/jason/asSyntax/PredicateIndicator.java 2014-10-19 18:06:01 UTC (rev 1817) +++ trunk/src/jason/asSyntax/PredicateIndicator.java 2014-11-03 10:51:43 UTC (rev 1818) @@ -57,9 +57,8 @@ } private int calcHash() { - final int PRIME = 31; - int t = PRIME * arity; - if (functor != null) t = PRIME * t + functor.hashCode(); + int t = 31 * arity; + if (functor != null) t = 31 * t + functor.hashCode(); return t; } Modified: trunk/src/jason/asSyntax/Structure.java =================================================================== --- trunk/src/jason/asSyntax/Structure.java 2014-10-19 18:06:01 UTC (rev 1817) +++ trunk/src/jason/asSyntax/Structure.java 2014-11-03 10:51:43 UTC (rev 1818) @@ -209,7 +209,9 @@ /** make a deep copy of the terms */ public Term clone() { - return new Structure(this); + Structure s = new Structure(this); + s.hashCodeCache = this.hashCodeCache; + return s; } @Override Modified: trunk/src/jason/asSyntax/UnnamedVar.java =================================================================== --- trunk/src/jason/asSyntax/UnnamedVar.java 2014-10-19 18:06:01 UTC (rev 1817) +++ trunk/src/jason/asSyntax/UnnamedVar.java 2014-11-03 10:51:43 UTC (rev 1818) @@ -66,6 +66,7 @@ public Term clone() { UnnamedVar newv = new UnnamedVar(getFunctor()); newv.myId = this.myId; + newv.hashCodeCache = this.hashCodeCache; if (hasAnnot()) newv.addAnnots(this.getAnnots().cloneLT()); return newv; Modified: trunk/src/jason/asSyntax/VarTerm.java =================================================================== --- trunk/src/jason/asSyntax/VarTerm.java 2014-10-19 18:06:01 UTC (rev 1817) +++ trunk/src/jason/asSyntax/VarTerm.java 2014-11-03 10:51:43 UTC (rev 1818) @@ -82,6 +82,13 @@ } @Override + protected int calcHashCode() { + int result = getFunctor().hashCode(); + if (negated()) result += 3271; + return result; + } + + @Override public Term capply(Unifier u) { if (u != null) { Term vl = u.get(this); @@ -124,7 +131,8 @@ // do not call constructor with term parameter! VarTerm t = new VarTerm(super.getFunctor()); t.setNegated(!negated()); - t.srcInfo = this.srcInfo; + t.srcInfo = this.srcInfo; + t.hashCodeCache = this.hashCodeCache; if (hasAnnot()) t.setAnnots(getAnnots().cloneLT()); return t; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-10-19 18:06:10
|
Revision: 1817 http://sourceforge.net/p/jason/svn/1817 Author: jomifred Date: 2014-10-19 18:06:01 +0000 (Sun, 19 Oct 2014) Log Message: ----------- remove killed agents from web mind inspector Modified Paths: -------------- trunk/src/jason/architecture/MindInspectorWeb.java trunk/src/jason/asSemantics/Agent.java trunk/src/jason/infra/centralised/KillAgentGUI.java trunk/src/jason/infra/centralised/RunCentralisedMAS.java trunk/src/jason/infra/repl/ReplAgGUI.java trunk/src/jason/infra/repl/print_unifier.java trunk/src/jason/jeditplugin/Config.java Modified: trunk/src/jason/architecture/MindInspectorWeb.java =================================================================== --- trunk/src/jason/architecture/MindInspectorWeb.java 2014-10-17 18:58:11 UTC (rev 1816) +++ trunk/src/jason/architecture/MindInspectorWeb.java 2014-10-19 18:06:01 UTC (rev 1817) @@ -191,6 +191,12 @@ } } + public synchronized void removeAg(Agent ag) { + String agName = ag.getTS().getUserAgArch().getAgName(); + registeredAgents.remove(agName); + histories.remove(agName); + } + public synchronized void addAgState(Agent ag, Document mind, boolean hasHistory) { String agName = ag.getTS().getUserAgArch().getAgName(); List<Document> h = histories.get(agName); Modified: trunk/src/jason/asSemantics/Agent.java =================================================================== --- trunk/src/jason/asSemantics/Agent.java 2014-10-17 18:58:11 UTC (rev 1816) +++ trunk/src/jason/asSemantics/Agent.java 2014-10-19 18:06:01 UTC (rev 1817) @@ -257,12 +257,16 @@ //if (scheduler != null) // scheduler.shutdownNow(); - for (InternalAction ia: internalActions.values()) + for (InternalAction ia: internalActions.values()) { try { ia.destroy(); } catch (Exception e) { e.printStackTrace(); } + } + if (MindInspectorWeb.isRunning()) { + MindInspectorWeb.get().removeAg(this); + } } /** Modified: trunk/src/jason/infra/centralised/KillAgentGUI.java =================================================================== --- trunk/src/jason/infra/centralised/KillAgentGUI.java 2014-10-17 18:58:11 UTC (rev 1816) +++ trunk/src/jason/infra/centralised/KillAgentGUI.java 2014-10-19 18:06:01 UTC (rev 1817) @@ -25,7 +25,7 @@ } protected void initComponents() { - services = RunCentralisedMAS.getRunner().getEnvironmentInfraTier().getRuntimeServices(); + services = RunCentralisedMAS.getRunner().getRuntimeServices(); getContentPane().setLayout(new BorderLayout()); // Fields Modified: trunk/src/jason/infra/centralised/RunCentralisedMAS.java =================================================================== --- trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2014-10-17 18:58:11 UTC (rev 1816) +++ trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2014-10-19 18:06:01 UTC (rev 1817) @@ -37,6 +37,7 @@ import jason.runtime.MASConsoleGUI; import jason.runtime.MASConsoleLogFormatter; import jason.runtime.MASConsoleLogHandler; +import jason.runtime.RuntimeServicesInfraTier; import jason.runtime.Settings; import java.awt.FlowLayout; @@ -362,19 +363,7 @@ @Override public void actionPerformed(ActionEvent e) { f.setVisible(false); - - CentralisedAgArch agArch = new CentralisedAgArch(); - agArch.setAgName(n.getText()); - agArch.setEnvInfraTier(env); - try { - agArch.createArchs(null, ReplAgGUI.class.getName(), null, null, new Settings(), RunCentralisedMAS.this); - Thread agThread = new Thread(agArch); - agArch.setThread(agThread); - agThread.start(); - } catch (JasonException e1) { - e1.printStackTrace(); - } - addAg(agArch); + createReplAg(n.getText()); } }); f.setLayout(new FlowLayout()); @@ -387,10 +376,30 @@ MASConsoleGUI.get().addButton(btStartAg); } + protected void createReplAg(String n) { + CentralisedAgArch agArch = new CentralisedAgArch(); + agArch.setAgName(n); + agArch.setEnvInfraTier(env); + try { + agArch.createArchs(null, ReplAgGUI.class.getName(), null, null, new Settings(), RunCentralisedMAS.this); + Thread agThread = new Thread(agArch); + agArch.setThread(agThread); + agThread.start(); + } catch (JasonException e1) { + e1.printStackTrace(); + } + addAg(agArch); + } + + public static RunCentralisedMAS getRunner() { return runner; } + public RuntimeServicesInfraTier getRuntimeServices() { + return new CentralisedRuntimeServices(runner); + } + public CentralisedExecutionControl getControllerInfraTier() { return control; } Modified: trunk/src/jason/infra/repl/ReplAgGUI.java =================================================================== --- trunk/src/jason/infra/repl/ReplAgGUI.java 2014-10-17 18:58:11 UTC (rev 1816) +++ trunk/src/jason/infra/repl/ReplAgGUI.java 2014-10-19 18:06:01 UTC (rev 1817) @@ -16,7 +16,8 @@ JTextField command = null; JTextArea output = null; - + JFrame frame; + //asl2html agTransformer = new asl2html("/xml/agInspection.xsl"); //JTextPane mindPanel = null; @@ -83,19 +84,19 @@ output.append("\n"); - JFrame f = new JFrame(".:: REPL Interface for "+getTS().getUserAgArch().getAgName()+" ::."); - f.getContentPane().setLayout(new BorderLayout()); - f.getContentPane().add(BorderLayout.NORTH,command); + frame = new JFrame(".:: REPL Interface for "+getTS().getUserAgArch().getAgName()+" ::."); + frame.getContentPane().setLayout(new BorderLayout()); + frame.getContentPane().add(BorderLayout.NORTH,command); //f.getContentPane().add(BorderLayout.CENTER, new JScrollPane(mindPanel)); - f.getContentPane().add(BorderLayout.CENTER,new JScrollPane(output)); + frame.getContentPane().add(BorderLayout.CENTER,new JScrollPane(output)); - f.pack(); + frame.pack(); int h = 200; int w = (int)(h*2*1.618); - f.setBounds((int)(h*0.618), 20, w, h); - f.setLocation(lastPos, 200+lastPos); + frame.setBounds((int)(h*0.618), 20, w, h); + frame.setLocation(lastPos, 200+lastPos); lastPos += 50; - f.setVisible(true); + frame.setVisible(true); } @Override @@ -108,6 +109,12 @@ output.append(s+"\n"); } + @Override + public void stopAg() { + frame.setVisible(false); + super.stopAg(); + } + /* private String lastMind = ""; Modified: trunk/src/jason/infra/repl/print_unifier.java =================================================================== --- trunk/src/jason/infra/repl/print_unifier.java 2014-10-17 18:58:11 UTC (rev 1816) +++ trunk/src/jason/infra/repl/print_unifier.java 2014-10-19 18:06:01 UTC (rev 1817) @@ -13,6 +13,7 @@ //if (! v.getFunctor().equals("Cmd__TR")) ts.getLogger().info(v+"="+un.get(v)); } + ts.getLogger().info("done"); return true; } Modified: trunk/src/jason/jeditplugin/Config.java =================================================================== --- trunk/src/jason/jeditplugin/Config.java 2014-10-17 18:58:11 UTC (rev 1816) +++ trunk/src/jason/jeditplugin/Config.java 2014-10-19 18:06:01 UTC (rev 1817) @@ -191,7 +191,10 @@ /** Returns the path to the java home directory */ public String getJavaHome() { - return getProperty(JAVA_HOME); + String h = getProperty(JAVA_HOME); + if (! h.endsWith(File.separator)) + h += File.separator; + return h; } /** Returns the path to the ant home directory (where its jars are stored) */ @@ -639,7 +642,7 @@ if (bt.exists()) { in = new BufferedReader(new FileReader(bt)); } else { - bt = new File(Config.get().getJasonHome()+"/src/templates/"+templateName); + bt = new File(getHome()+"/src/templates/"+templateName); if (bt.exists()) { in = new BufferedReader(new FileReader(bt)); } else { @@ -662,6 +665,10 @@ } } + protected String getHome() { + return getJasonHome(); + } + public InputStream getDetaultResource(String templateName) throws IOException { return TransitionSystem.class.getResource("/templates/"+templateName).openStream(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-10-17 18:58:15
|
Revision: 1816 http://sourceforge.net/p/jason/svn/1816 Author: jomifred Date: 2014-10-17 18:58:11 +0000 (Fri, 17 Oct 2014) Log Message: ----------- improve return of buf Modified Paths: -------------- trunk/src/jason/asSemantics/Agent.java trunk/src/jason/asSemantics/Intention.java trunk/src/test/TermTest.java Modified: trunk/src/jason/asSemantics/Agent.java =================================================================== --- trunk/src/jason/asSemantics/Agent.java 2014-10-17 15:44:12 UTC (rev 1815) +++ trunk/src/jason/asSemantics/Agent.java 2014-10-17 18:58:11 UTC (rev 1816) @@ -675,10 +675,13 @@ return pl; } - /** Belief Update Function: adds/removes percepts into belief base */ - public void buf(List<Literal> percepts) { + /** Belief Update Function: adds/removes percepts into belief base. + * + * @return the number of changes (add + dels) + */ + public int buf(List<Literal> percepts) { if (percepts == null) { - return; + return 0; } // stat @@ -756,6 +759,7 @@ qCache.reset(); if (qProfiling != null) qProfiling.newUpdateCycle(getTS().getUserAgArch().getCycleNumber(), adds+dels, System.nanoTime()-startTime); + return adds + dels; } public QueryCacheSimple getQueryCache() { Modified: trunk/src/jason/asSemantics/Intention.java =================================================================== --- trunk/src/jason/asSemantics/Intention.java 2014-10-17 15:44:12 UTC (rev 1815) +++ trunk/src/jason/asSemantics/Intention.java 2014-10-17 18:58:11 UTC (rev 1816) @@ -181,7 +181,7 @@ } public int hashCode() { - return new Integer(id).hashCode(); + return id; } public Intention clone() { Modified: trunk/src/test/TermTest.java =================================================================== --- trunk/src/test/TermTest.java 2014-10-17 15:44:12 UTC (rev 1815) +++ trunk/src/test/TermTest.java 2014-10-17 18:58:11 UTC (rev 1816) @@ -129,7 +129,7 @@ c2.add(ASSyntax.parseTerm("x")); c1.retainAll(c2); - assertEquals("[back_pos(9,7), x]",c1.toString()); + assertTrue("[back_pos(9,7), x]".equals(c1.toString()) || "[x, back_pos(9,7)]".equals(c1.toString())); } public void testUnifies() throws ParseException { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |