Hello all. I’m fairly new to this framework to please bear with me. Ok, so I’ve implemented the console and it works well - I know how can I register command etc. and they work like charm. However, what I’m trying to do is to create natural language and computational linguistic console. In other words - a console that would respond in some intelligent way basing on what you have input. This is an artificial intelligence area. I’ve started working on the parsing algorithms but I can’t test them because I don’t know how can I capture the input from the console :/. Here’s the code I’m using atm:
[xml]
<?xml version=“1.0” encoding=“UTF-8”?>
<nifty>
<useControls filename=“nifty-default-controls.xml” />
<useStyles filename=“nifty-default-styles.xml” />
<screen id=“start”>
<layer id=“background” childLayout=“center”>
</layer>
<layer id=“layerWithButtons” childLayout=“center” height=“100%” width=“100%”>
<panel id=“panelTop” height=“75%” width=“100%” align=“center” valign=“center” childLayout=“horizontal” visibleToMouse=“true”>
<panel id=“panelList” height=“75%” width=“70%” align=“center” valign=“center” childLayout=“horizontal” visibleToMouse=“true”>
<control id=“console” name=“nifty-console” lines=“25” align=“center” valign=“center”>
</control>
</panel>
</panel>
</layer>
</screen>
<screen id=“end”>
<layer id=“layer” backgroundColor="#0000" childLayout=“center”>
<panel id=“panel” height=“25%” width=“35%” align=“center” valign=“center” backgroundColor="#ffff" childLayout=“center” visibleToMouse=“true”>
<interact onClick=“quit()”/>
<effect>
<onStartScreen name=“move” mode=“in” direction=“top” length=“300” startDelay=“0” inherit=“true”/>
<onEndScreen name=“move” mode=“out” direction=“bottom” length=“300” startDelay=“0” inherit=“true”/>
<onHover name=“pulsate” scaleFactor=“0.008” startColor="#f600" endColor="#ffff" post=“true”/>
</effect>
<text id=“text” font=“aurulent-sans-16.fnt” color="#000f" text=“Welcome to 3D London Underground Simulator!” align=“center” valign=“center” />
</panel>
</layer>
</screen>
</nifty>
[/xml]
[java]package mygame;
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.niftygui.NiftyJmeDisplay;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.controls.Console;
import de.lessvoid.nifty.controls.ConsoleCommands;
import de.lessvoid.nifty.controls.ConsoleCommands.ConsoleCommand;
import de.lessvoid.nifty.controls.ConsoleExecuteCommandEvent;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.nifty.screen.ScreenController;
public class Main extends SimpleApplication implements ScreenController {
private Nifty nifty;
private Screen screen;
private Console console;
public static void main(String[] args) {
Main app = new Main();
app.start();
}
@Override
public void simpleInitApp()
{
NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, viewPort);
nifty = niftyDisplay.getNifty();
nifty.fromXml(“Interface/screen.xml”, “start”);
viewPort.addProcessor(niftyDisplay);
this.getFlyByCamera().setDragToRotate(true);
this.getFlyByCamera().setEnabled(false);
console = nifty.getScreen(“start”).findNiftyControl(“console”, Console.class);
console.output(“Hello World :)”);
}
public void onConsoleExecuteCommandEvent(final String id, final ConsoleExecuteCommandEvent cEvent )
{
String consoleInput = cEvent.getCommandLine();
System.out.println(consoleInput);
}
@Override
public void simpleUpdate(float tpf) {
}
@Override
public void simpleRender(RenderManager rm) {
}
public void bind(Nifty nifty, Screen screen) {
this.nifty=nifty;
this.screen=screen;
}
public void onStartScreen() {
}
public void onEndScreen() {
}
}
[/java]
So what I want to do is:
- capture input from the console
- parse it using my algorithms
- send an output back to the console
I will gladly share the parsing algorithms to this forum when I finish them- in the meantime, can anyone help me with this? I know I’m probably missing something trivial, but then again - I’m just a noobie. Any guidance is very much appreciated!