← go back

Some sketching of an agent programming language (in a much more literal sense).

It’s very… verbose.

agent Main traits [Runnable Stateful].
-- Runnable: this agent can be run from an outside initiator (e.g. your terminal)
-- Stateful: this agent stores some states (defines the actions [(set name) (to value)] and [(get name)])

use "IO:Output" as Output.
use "Number:Operations" as Number-OP.
use "Text:Operations" as Text-OP.
-- The syntax for the agent selector are "Protocol:Link/To/Agent"
-- Each protocol has their own unique actions.

-- This defines an action which can be asked by other agents.
-- For this one, it also acts as the entry point for the initiator.
on [(run args)] do {
	set i to 1.

	-- Repeatedly does the instructions until a reply is given.
	loop {
		set out to "".

		get i. ask Number-OP to {mod it with 3. reply it.}.
		if it is 0 do {
			get out. ask Text-OP to {add it with "Fizz". reply it.}. set out to it.
		}.
		get i. ask Number-OP to {mod it with 5. reply it.}.
		if it is 0 do {
			get out. ask Text-OP to {add it with "Buzz". reply it.}. set out to it.
		}.

		get out.
		if it is "" do {
			ask Number-OP to {textify it. reply it.}.
			ask Output to {write it. reply it.}.
		}.
		
		get i. ask Number-OP to {add it with 1. reply it.}. set i to it.

		get i. ask Number-OP to {compare it with 100. reply it.}.
		-- Number-OP's compare action replies the flags [equal greater less].
		if it is equal do {
			reply 0.
		}.
	}.
	reply it.
}.
Mar 14, 2024, 4:55 PM (edited)
1 0 0

Comments