File helloWorld.asl
In the first file, I implement the code of the agent to print the message Hello World.
!start.
+!start <-
.print("Hello World").
In line 1, I define the !start as an initial goal for the agent.
In lines 3 and 4, I define the plan for handling the adoption of the goal !start. Thus, when the agent adopts the goal !start, lines 3 and 4 will be executed. Once the Hello World message is printed, the goal !start is satisfied and no further messages will be printed.
File helloWorld.mas2j
In the second file, I configure the system.
MAS helloWorld {
infrastructure: Centralised
agents:
tom helloWorld;
aslSourcePath:
"src/asl";
}
In line 2, I define that the system will run in the same JVM. Other infrastructures can be set if you want to run it distributed, for example.
In lines 4 and 5, I define an agent named tom that uses the file helloWorld.asl as its main code.
In lines 7 and 8, I define in which directory I have my .asl files, in this case, the file helloWorld.asl.
Final Comments
This version of the Hello World in Jason was implemented using the Jason 1.4.2. You can find more about Jason at http://jason.sf.net/
No comments:
Post a Comment