Monkey Brains

Can someone explain to me how to use monkey brains because the wiki is not complete?

This is the example code:

public class Example extends SimpleApplication {

//defining game
private MonkeyBrainsAppState brainsAppState = MonkeyBrainsAppState.getInstance(); 

public static void main(String[] args) {
    Example app = new Example();
    app.start();
}

@Override
public void simpleInitApp() {
    //defining app
    brainsAppState.setApp(this);

    //initialization of Agents with their names and spatials
    Agent agent = new Agent("First agent", createAgentSpatial()); 
    //there isn't any method in framework like createAgentSpatial()
    //user is supposed to build his own spatials for game

    //adding agent to MonkeyBrainsAppState
    brainsAppState.addAgent(agent);

    //setting moveSpeed, rotationSpeed, mass..
    agent.setMoveSpeed(20); 
    agent.setRotationSpeed(30);
    //used for steering behaviors in com.jme3.ai.agents.behaviors.npc.steering
    agent.setMass(40);
    agent.setMaxForce(3);

    //creating main behavior
    //agent can have only one behavior but that behavior can contain other behaviors
    agent.setMainBehavior(new MyCustomBehavior(agent));

    //starting agents
    brainsAppState.start();

}

@Override
public void simpleUpdate(float tpf) {
    brainsAppState.update(tpf);
}

}

I get an error saying that method createAgentSpatial() doesn’t exist. Should I replace it by a Spatial?

And the following line:

agent.setMainBehavior(new MyCustomBehavior(agent));

has a class MyCustomBehavior that doesn’t exist. Should I make my own class and how?

Can somebody help me?

Perhaps the fact is that you use the developed version with github. It differs from what is described in the wiki. It’s better to download the finished 1.0 github release. Because the developed version is in my opinion unfinished. Details about its differences look for on the forum on request “What’s happening with MonkeyBrains?”.

1 Like

Also libgdx-ai exists. I haven’t used MonkeyBrains not I know how to compare them, but just to give a hint that you have options.

If I remember correctly, its not documented. You know of some docs for it somewhere?

edit:
By not documented I mean nothing but generic descriptions and old, poorly written user examples.

Then probably not. I was satisfied with their wiki (this is probably the generic description part you were referring to) and they did have a bunch of example projects listed there that you could download and tryout. But in all it is pretty small library.
We are utilizing the steering, path finding and the AI state machines. The steering is really hard to get right, but I’m still blaming myself for that.

I was not able to make the wanderer working as I also wanted that libgdx ai lib for my steering part, it always ran straight on… in the end I was faster doing it myself, it’s not very complicated actually.