Hello World
This agent prints a message and then stops the ASTRA runtime. This example demonstrates modules, an initial goal and a plan.
Run the example
Use an ASTRA 2.6.1 project from the Quick Start. Save the following code as src/main/astra/Hello.astra.
Hello.astra
agent Hello {
module Console C;
module System S;
initial !init();
plan +!init() {
C.println("Hello World");
S.exit();
}
}
From the project folder, run:
mvn -Dastra.main=Hello
Expected output
[main]Hello World
The program exits after printing the message.
How it works
The initial goal !init() selects the +!init() plan. The Console module prints the message, and System.exit() stops the entire runtime. Finishing a plan alone does not stop the runtime.
Try a change
Change the greeting, then print a second message before calling exit(). Remove exit() and observe that the runtime stays running; use Ctrl+C to stop it.
See Quick Start and AgentSpeak(L) and ASTRA.