Skip to content

Commit

Permalink
Included the MindViewer and ported to cst-desktop 1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
rgudwin committed Jun 9, 2022
1 parent d6db1b5 commit 123e074
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 173 deletions.
42 changes: 14 additions & 28 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
//apply plugin: 'java-library-distribution'
apply plugin: 'application'
mainClassName = 'ExperimentMain'

sourceCompatibility = '1.8'
version = '0.0.2'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

// NetBeans will automatically add "run" and "debug" tasks relying on the
// "mainClass" property. You may however define the property prior executing
// tasks by passing a "-PmainClass=<QUALIFIED_CLASS_NAME>" argument.
//
// Note however, that you may define your own "run" and "debug" task if you
// prefer. In this case NetBeans will not add these tasks but you may rely on
// your own implementation.
if (!hasProperty('mainClass')) {
ext.mainClass = 'ExperimentMain'
}
Expand All @@ -22,34 +14,31 @@ repositories {
dirs '../cst/build/libs'
}
mavenCentral()
maven {
url "https://github.com/rosjava/rosjava_mvn_repo/raw/master"
}
maven {
url "https://repository.springsource.com/maven/bundles/release"
}
maven {
url "https://repository.springsource.com/maven/bundles/external"
}
maven { url 'https://jitpack.io' }
// You may define additional repositories, or even remove "mavenCentral()".
// Read more about repositories here:
// http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:repositories
}

dependencies {
// TODO: Add dependencies here ...
// You can read more about how to add dependency here:
// http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:how_to_declare_your_dependencies
//implementation fileTree(dir: 'lib', include: ['*.jar'])
implementation 'com.github.CST-Group:cst:0.6.1'
implementation 'com.github.CST-Group:cst-desktop:1.0.3'
implementation 'com.github.CST-Group:WS3DProxy:0.0.1'
//implementation 'sqlite-jdbc:3.7.2'
//implementation ':cst:0.6.2-full' // To be used while developing CST code
implementation 'org.json:json:20180813'

implementation fileTree(dir: 'lib', include: ['*.jar'])
//implementation 'com.github.CST-Group:cst:0.2.4'
//implementation 'org.json:json:20180813'
testCompile group: 'junit', name: 'junit', version: '4.10'
testImplementation group: 'junit', name: 'junit', version: '4.10'
}

task uberJar(type: Jar) {
jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
archiveClassifier = 'full'
manifest {
attributes(
'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
'Main-Class': mainClassName
)
}
Expand All @@ -58,8 +47,5 @@ task uberJar(type: Jar) {
from {
configurations.runtimeClasspath.findAll { it.name.endsWith('jar') }.collect { zipTree(it) }
}
}
artifacts
{
archives uberJar
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
127 changes: 0 additions & 127 deletions rules.soar

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/java/AgentMind.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
public class AgentMind extends Mind {

private static int creatureBasicSpeed=3;
private static int reachDistance=50;
private static int reachDistance=40;
public ArrayList<Codelet> behavioralCodelets = new ArrayList<Codelet>();
public PlansSubsystemModule psm;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/Environment.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public Environment() {
World.createFood(0, 350, 75);
World.createFood(0, 100, 220);
World.createFood(0, 250, 210);
c = proxy.createCreature(100,450,0);
c = proxy.createCreature(100,450,0,0);
c.start();
grow(w,7);
//c.setRobotID("r0");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ExperimentMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Klaus Raizer, Andre Paraense, Ricardo Ribeiro Gudwin
*****************************************************************************/

import br.unicamp.cst.util.MindViewer;
import br.unicamp.cst.util.viewer.MindViewer;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/codelets/behaviors/EatClosestApple.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ public void proc() {
double appleX=0;
double appleY=0;
try {
appleX=closestApple.getX1();
appleY=closestApple.getY1();
appleX=closestApple.getCenterPosition().getX();
appleY=closestApple.getCenterPosition().getY();
appleName = closestApple.getName();


Expand All @@ -94,7 +94,7 @@ public void proc() {
double distance = pSelf.distance(pApple);
JSONObject message=new JSONObject();
try {
if(distance<reachDistance){ //eat it
if(distance<=reachDistance){ //eat it
message.put("OBJECT", appleName);
message.put("ACTION", "EATIT");
handsMO.setI(message.toString());
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/codelets/behaviors/GoToClosestApple.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public void proc() {
double appleX=0;
double appleY=0;
try {
appleX = closestApple.getX1();
appleY = closestApple.getY1();
appleX = closestApple.getCenterPosition().getX();
appleY = closestApple.getCenterPosition().getY();

} catch (Exception e) {
e.printStackTrace();
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/codelets/motor/LegsActionCodelet.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,15 @@ public void proc() {
int x=0,y=0;
String action=command.getString("ACTION");
if(action.equals("FORAGE")){
//if (!comm.equals(previousLegsAction)) {
if (!comm.equals(previousLegsAction))
if (!comm.equals(previousLegsAction)) {
//if (!comm.equals(previousLegsAction))
log.info("Sending Forage command to agent");
try {
c.rotate(2);
} catch (Exception e) {
e.printStackTrace();
}
}
}
else if(action.equals("GOTO")){
if (!comm.equals(previousLegsAction)) {
Expand Down Expand Up @@ -112,9 +113,10 @@ else if(action.equals("GOTO")){
} catch (JSONException e) {e.printStackTrace();}
}
else {
log.info("Sending stop command to agent");
previousLegsAction = comm;
log.info("Sending stop command to agent");
try {
c.moveto(0,0,0);
//c.moveto(0,0,0);
} catch(Exception e) {
e.printStackTrace();
}
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/codelets/sensors/Vision.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ public void accessMemoryObjects() {
@Override
public void proc() {
c.updateState();

synchronized (visionMO) {
List<Thing> lt = c.getThingsInVision();
//System.out.println("Vision:" + lt.toString());
visionMO.setI(lt);
//Class cl = List.class;
//visionMO.setT(cl);
List<Thing> lt = c.getThingsInVision();
//System.out.println("Vision:" + lt.toString());
visionMO.setI(lt);
//Class cl = List.class;
//visionMO.setT(cl);
}
}//end proc()

Expand Down

0 comments on commit 123e074

Please sign in to comment.