MaDKit forum

Welcome All !
Please, use explicit topic names when creating new threads. Thanks.

You are not logged in.

#1 2016-05-02 21:52:47

Registered: 2016-05-02
Posts: 4

How to launch

Hi, maybe this is a trivial question, but I am completely new to Java and OOprogramming.
I am trying to run the Termites simulation in turtlekit 2.4.9 and I cannot run it using the Tk2Launcher by using the newSimulation method:

(launch = instance of Tk2Launcher).

The problem is that in the XMLParser (specifically in the method: document = builder.parse( configFile); ) , the compiler throws NullPointerException. Java returned: 1 BUILD FAILED. C:\Users\Ximo\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53:

I thought the program did not recognize the XML file, but I added:

boolean exist = configFile.exists(); just before document = builder.parse( configFile); and the result of the debugger is that exist is true.

I tried to launch the simulation building a single launcher, which is shown as follows:

package edu.turtlekit2.demos.termites;

import edu.turtlekit2.kernel.agents.Observer;
import edu.turtlekit2.kernel.agents.Turtle;
import edu.turtlekit2.kernel.agents.Viewer;
import edu.turtlekit2.kernel.environment.TurtleEnvironment;
import madkit.kernel.Agent;
import madkit.kernel.AbstractAgent;
import madkit.kernel.Kernel;

* @author Ximo
public class Launcher extends Agent {
     public static void main(String args[])  {
          Launcher myLauncher = new Launcher();
          String name = "Termites";
          TurtleEnvironment environment = new TurtleEnvironment();
          environment.initialize(150, 110, true);
          PatchInitializer myPatch = new PatchInitializer(0.4f);
          myLauncher.launchObserver (myPatch, name);
          for (int i = 0; i < 400; i++){
              Termite myTerm = new Termite();
              myTerm.initialisation((int) (Math.random() * (double)150), ((int) (Math.random()*(double)110)), environment, i, null);             
          Viewer myView = new Viewer ();
          myView.cellSize = 10;
          myLauncher.launchObserver (myView, name);
     public void launchEnvironment(TurtleEnvironment agent, String name){
         launchAgent(agent, name, true);
     public void launchObserver (Observer obs, String name){
         launchAgent(obs, name, true);


It fails at compiling again, with the same NullPointerException. Java returned: 1 BUILD FAILED. C:\Users\Ximo\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53:
I do not know what is happening. Thank you very much for your help in advance.


#2 2016-05-03 09:10:02

From: Montpellier
Registered: 2009-03-24
Posts: 172

Re: How to launch


A first answer is that TurtleKit 2 is a bit out-of-date compared to how TurtleKit 3 is now working (much more simpler despite the alpha tag). So a first answer could be that you should first try to use this version. For instance, one way (there are others) of running the termite simulation is just about executing the main method which is in the Termite class (from the demo zip file) once the TurtleKit jar file is in the class path of your IDE.
Do not hesitate to post again if you encounter any problem using it.



Board footer