Skip to content

Commit

Permalink
Updated and made compatible with the newest CST and WS3D Software
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed May 9, 2017
1 parent 90b1a2f commit 818ec67
Show file tree
Hide file tree
Showing 17 changed files with 68 additions and 56 deletions.
Binary file modified lib/WS3DProxy.jar
Binary file not shown.
Binary file modified lib/cst.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion nbproject/build-impl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ is divided into following sections:
</chainedmapper>
</pathconvert>
<taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
<copylibs compress="${jar.compress}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" rebase="${copylibs.rebase}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
<copylibs compress="${jar.compress}" excludeFromCopy="${copylibs.excludes}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" rebase="${copylibs.rebase}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
<fileset dir="${build.classes.dir}" excludes="${dist.archive.excludes}"/>
<manifest>
<attribute name="Class-Path" value="${jar.classpath}"/>
Expand Down
30 changes: 10 additions & 20 deletions nbproject/build-impl.xml~
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,12 @@ is divided into following sections:
</not>
</and>
</condition>
<property name="javac.fork" value="${jdkBug6558476}"/>
<condition else="false" property="javac.fork">
<or>
<istrue value="${jdkBug6558476}"/>
<istrue value="${javac.external.vm}"/>
</or>
</condition>
<property name="jar.index" value="false"/>
<property name="jar.index.metainf" value="${jar.index}"/>
<property name="copylibs.rebase" value="true"/>
Expand All @@ -215,6 +220,7 @@ is divided into following sections:
<condition else="" property="testng.debug.mode" value="-mixed">
<istrue value="${junit+testng.available}"/>
</condition>
<property name="java.failonerror" value="true"/>
</target>
<target name="-post-init">
<!-- Empty placeholder for easier customization. -->
Expand Down Expand Up @@ -680,7 +686,7 @@ is divided into following sections:
<sequential>
<property environment="env"/>
<resolve name="profiler.current.path" value="${profiler.info.pathvar}"/>
<java classname="@{classname}" dir="${profiler.info.dir}" fork="true" jvm="${profiler.info.jvm}">
<java classname="@{classname}" dir="${profiler.info.dir}" failonerror="${java.failonerror}" fork="true" jvm="${profiler.info.jvm}">
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
<jvmarg value="${profiler.info.jvmargs.agent}"/>
<jvmarg line="${profiler.info.jvmargs}"/>
Expand Down Expand Up @@ -755,7 +761,7 @@ is divided into following sections:
<attribute default="${debug.classpath}" name="classpath"/>
<element name="customize" optional="true"/>
<sequential>
<java classname="@{classname}" dir="${work.dir}" fork="true">
<java classname="@{classname}" dir="${work.dir}" failonerror="${java.failonerror}" fork="true">
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
<jvmarg line="${debug-args-line}"/>
<jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
Expand All @@ -782,7 +788,7 @@ is divided into following sections:
<attribute default="jvm" name="jvm"/>
<element name="customize" optional="true"/>
<sequential>
<java classname="@{classname}" dir="${work.dir}" fork="true">
<java classname="@{classname}" dir="${work.dir}" failonerror="${java.failonerror}" fork="true">
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
<jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
<redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
Expand Down Expand Up @@ -883,14 +889,6 @@ is divided into following sections:
<propertyfile file="${built-jar.properties}">
<entry key="${basedir}" value=""/>
</propertyfile>
<antcall target="-maybe-call-dep">
<param name="call.built.properties" value="${built-jar.properties}"/>
<param location="${project.cst}" name="call.subproject"/>
<param location="${project.cst}/build.xml" name="call.script"/>
<param name="call.target" value="jar"/>
<param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
<param name="transfer.not.archive.disabled" value="true"/>
</antcall>
</target>
<target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
<target depends="init" name="-check-automatic-build">
Expand Down Expand Up @@ -1372,14 +1370,6 @@ is divided into following sections:
<propertyfile file="${built-clean.properties}">
<entry key="${basedir}" value=""/>
</propertyfile>
<antcall target="-maybe-call-dep">
<param name="call.built.properties" value="${built-clean.properties}"/>
<param location="${project.cst}" name="call.subproject"/>
<param location="${project.cst}/build.xml" name="call.script"/>
<param name="call.target" value="clean"/>
<param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
<param name="transfer.not.archive.disabled" value="true"/>
</antcall>
</target>
<target depends="init" name="-do-clean">
<delete dir="${build.dir}"/>
Expand Down
8 changes: 4 additions & 4 deletions src/AgentMind.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ public class AgentMind extends Mind {

public AgentMind(Environment env) {
super();
// Create RawMemory and Coderack
//Mind m = new Mind();
//RawMemory rawMemory=RawMemory.getInstance();
//CodeRack codeRack=CodeRack.getInstance();

// Declare Memory Objects
MemoryObject legsMO;
Expand Down Expand Up @@ -131,6 +127,10 @@ public AgentMind(Environment env) {
forage.addInput(knownApplesMO);
forage.addOutput(legsMO);
insertCodelet(forage);

// sets a time step for running the codelets to avoid heating too much your machine
for (Codelet c : this.getCodeRack().getAllCodelets())
c.setTimeStep(200);

// Start Cognitive Cycle
start();
Expand Down
9 changes: 5 additions & 4 deletions src/codelets/behaviors/EatClosestApple.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,16 @@ public class EatClosestApple extends Codelet {
List<Thing> known;

public EatClosestApple(int reachDistance) {
setTimeStep(50);
this.reachDistance=reachDistance;
}

@Override
public void accessMemoryObjects() {
closestAppleMO=this.getInput("CLOSEST_APPLE");
innerSenseMO=this.getInput("INNER");
handsMO=this.getOutput("HANDS");
knownMO = this.getOutput("KNOWN_APPLES");
closestAppleMO=(MemoryObject)this.getInput("CLOSEST_APPLE");
innerSenseMO=(MemoryObject)this.getInput("INNER");
handsMO=(MemoryObject)this.getOutput("HANDS");
knownMO = (MemoryObject)this.getOutput("KNOWN_APPLES");
}

@Override
Expand Down
7 changes: 3 additions & 4 deletions src/codelets/behaviors/Forage.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public class Forage extends Codelet {
/**
* Default constructor
*/
public Forage(){

public Forage(){
}

@Override
Expand All @@ -66,8 +65,8 @@ public void proc() {

@Override
public void accessMemoryObjects() {
knownMO = this.getInput("KNOWN_APPLES");
legsMO=this.getOutput("LEGS");
knownMO = (MemoryObject)this.getInput("KNOWN_APPLES");
legsMO=(MemoryObject)this.getOutput("LEGS");

// TODO Auto-generated method stub

Expand Down
6 changes: 3 additions & 3 deletions src/codelets/behaviors/GoToClosestApple.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public GoToClosestApple(int creatureBasicSpeed, int reachDistance) {

@Override
public void accessMemoryObjects() {
closestAppleMO=this.getInput("CLOSEST_APPLE");
selfInfoMO=this.getInput("INNER");
legsMO=this.getOutput("LEGS");
closestAppleMO=(MemoryObject)this.getInput("CLOSEST_APPLE");
selfInfoMO=(MemoryObject)this.getInput("INNER");
legsMO=(MemoryObject)this.getOutput("LEGS");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/codelets/motor/HandsActionCodelet.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public HandsActionCodelet(Creature nc) {

@Override
public void accessMemoryObjects() {
handsMO=this.getInput("HANDS");
handsMO=(MemoryObject)this.getInput("HANDS");
}
public void proc() {

Expand Down
4 changes: 2 additions & 2 deletions src/codelets/motor/LegsActionCodelet.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public LegsActionCodelet(Creature nc) {

@Override
public void accessMemoryObjects() {
legsActionMO=this.getInput("LEGS");
legsActionMO=(MemoryObject)this.getInput("LEGS");
}

@Override
Expand All @@ -75,7 +75,7 @@ public void proc() {
if (!comm.equals(previousLegsAction))
log.info("Sending Forage command to agent");
try {
c.rotate(0.01);
c.rotate(2);
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
4 changes: 2 additions & 2 deletions src/codelets/perception/AppleDetector.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public AppleDetector(){
@Override
public void accessMemoryObjects() {
synchronized(this) {
this.visionMO=this.getInput("VISION");
this.visionMO=(MemoryObject)this.getInput("VISION");
}
this.knownApplesMO=this.getOutput("KNOWN_APPLES");
this.knownApplesMO=(MemoryObject)this.getOutput("KNOWN_APPLES");
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions src/codelets/perception/ClosestAppleDetector.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public ClosestAppleDetector() {

@Override
public void accessMemoryObjects() {
this.knownMO=this.getInput("KNOWN_APPLES");
this.innerSenseMO=this.getInput("INNER");
this.closestAppleMO=this.getOutput("CLOSEST_APPLE");
this.knownMO=(MemoryObject)this.getInput("KNOWN_APPLES");
this.innerSenseMO=(MemoryObject)this.getInput("INNER");
this.closestAppleMO=(MemoryObject)this.getOutput("CLOSEST_APPLE");
}
@Override
public void proc() {
Expand Down
2 changes: 1 addition & 1 deletion src/codelets/sensors/InnerSense.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public InnerSense(Creature nc) {
}
@Override
public void accessMemoryObjects() {
innerSenseMO=this.getOutput("INNER");
innerSenseMO=(MemoryObject)this.getOutput("INNER");
cis = (CreatureInnerSense) innerSenseMO.getI();
}

Expand Down
2 changes: 1 addition & 1 deletion src/codelets/sensors/Vision.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public Vision(Creature nc) {

@Override
public void accessMemoryObjects() {
visionMO=this.getOutput("VISION");
visionMO=(MemoryObject)this.getOutput("VISION");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/memory/CreatureInnerSense.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class CreatureInnerSense {

public String toString() {
if (position != null)
return("Position: "+(int)position.getX()+","+(int)position.getY()+" Pitch: "+pitch+" Fuel: "+fuel);
return("Position: ("+(int)position.getX()+","+(int)position.getY()+") Pitch: "+(int)pitch+" Fuel: "+fuel);
else
return("Position: null,null"+" Pitch: "+pitch+" Fuel: "+fuel);
}
Expand Down
4 changes: 2 additions & 2 deletions src/support/MindView.form
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" alignment="0" pref="400" max="32767" attributes="0"/>
<Component id="jScrollPane1" alignment="0" pref="568" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" alignment="0" pref="300" max="32767" attributes="0"/>
<Component id="jScrollPane1" min="-2" pref="116" max="-2" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
Expand Down
36 changes: 29 additions & 7 deletions src/support/MindView.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.CopyOnWriteArrayList;
import ws3dproxy.model.Thing;
import ws3dproxy.model.World;
import ws3dproxy.util.Constants;

class MVTimerTask extends TimerTask {
MindView mv;
Expand Down Expand Up @@ -68,7 +71,7 @@ public void addMO(MemoryObject moi) {
public void StartTimer() {
t = new Timer();
MVTimerTask tt = new MVTimerTask(this);
t.scheduleAtFixedRate(tt,0,250);
t.scheduleAtFixedRate(tt,0,500);
}

public void tick() {
Expand All @@ -79,15 +82,34 @@ public void tick() {
//Class cl = mo.getT();
//Object k = cl.cast(mo.getI());
Object k = mo.getI();
alltext += mo.name+": "+k+"\n";
String moName = mo.getName();
if (moName.equals("KNOWN_APPLES") || moName.equals("VISION")) {
//alltext += mo.getName()+": "+k+"<-> ";
alltext += mo.getName()+": [ ";
CopyOnWriteArrayList<Thing> l = new CopyOnWriteArrayList<>((List<Thing>)k);
for (Thing t : l) {
String kindofthing = "t";
if (t.getCategory() == Constants.categoryPFOOD) kindofthing = "a";
alltext += kindofthing+"("+(int)(t.getX1()+t.getX2())/2+","+(int)(t.getY1()+t.getY2())/2+") ";
}
alltext += "]\n";
}
else if (moName.equals("CLOSEST_APPLE")) {
Thing t = (Thing)k;
String kindofthing = "t";
if (t.getCategory() == 21) kindofthing = "a";
alltext += moName+": "+kindofthing+"("+(int)(t.getX1()+t.getX2())/2+","+(int)(t.getY1()+t.getY2())/2+")\n";
}
else
alltext += mo.getName()+": "+k+"\n";
}
else
alltext += mo.name+": "+mo.getI()+"\n";

//alltext += mo.getName()+": "+mo.getI()+"\n";
alltext += mo.getName()+":\n";
}
text.setText(alltext);
j++;
if (j == 40) {
if (j == 7) {
try {
World.createFood(0,r.nextInt(800) , r.nextInt(600));
} catch (Exception e) {
Expand Down Expand Up @@ -120,11 +142,11 @@ private void initComponents() {
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 568, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
);

pack();
Expand Down

0 comments on commit 818ec67

Please sign in to comment.