jSoar is currently under heavy development and there are no releases on the downloads page so the only way to get it is by checking out the code directly through the subversion server. Once you check out the code, you can build it either with the included Ant build.xml build script or by importing the code into Eclipse. I tried both and had no problems.
Next on to my test case. I want to build a simple Soar agent that responds to a single, simple rule from the soccer domain: "If the ball is controlled by me, then shoot the ball." Here is my Soar rule:
jSoar comes with a set of unit tests that both test the validity of the system as it continues to develop and serve as samples for how the system is to be used. In particular, InputOutputImplTest.java shows how to create and initialize a new Soar agent, attach to the input and output cycle through agent listeners, send data to the agent on the input link and receive the agent's output.
Having an input and output link and a regular decision cycle makes Soar much more friendly to agent developers than other rules engines like Drools. On the flip side, the syntax for spoon-feeding changes into working memory is no fun.
Support for jSoar is provided through the jsoar-dev Google Groups web page.
Here's my simple test java code:
package com.referata.soccer;
import org.jsoar.kernel.Agent;
import org.jsoar.kernel.RunType;
import org.jsoar.kernel.events.InputCycleEvent;
import org.jsoar.kernel.io.InputBuilder;
import org.jsoar.tcl.SoarTclInterface;
import org.jsoar.util.events.SoarEvent;
import org.jsoar.util.events.SoarEventListener;
public class SoccerSoarTest implements SoarEventListener {
private Agent agent;
public SoccerSoarTest() throws Exception {
agent = new Agent();
SoarTclInterface ifc = new SoarTclInterface(agent);
agent.initialize();
agent.getEventManager().addListener(
InputCycleEvent.class, this);
ifc.sourceFile("/res/soccer.soar");
agent.runFor(3, RunType.DECISIONS);
}
/**
* @param args
*/
public static void main(String[] args) throws Exception {
new SoccerSoarTest();
}
@Override
public void onEvent(SoarEvent arg0) {
InputBuilder builder = InputBuilder.create(agent.io);
builder.push("ball").markId("b1").
add("controlledBy", "me");
}
}
No comments:
Post a Comment