Skip to content

Commit

Permalink
Merge pull request #67 from opennars/pr_pong1
Browse files Browse the repository at this point in the history
Add: Pong: verbosity flag
  • Loading branch information
PtrMan authored Dec 29, 2018
2 parents 7dc20e3 + aa2af77 commit 668b318
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/main/java/org/opennars/lab/microworld/Pong.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.opennars.operator.Operator;

public class Pong extends Frame {
public boolean verbose = true;

public Pong() {
String[] args = {"Pong"};
Expand Down Expand Up @@ -165,25 +166,25 @@ int UpdateSOM(float[] viewField,float reward) //input and reward
if(k%4 == 0) {
Sentence hypo_left = ConceptMonitor.strongestPrecondition(nar, "<{SELF} --> [good]>",
"<(&/,<{left} --> [on]>,+1,(^Right,{SELF}),+1) =/> <{SELF} --> [good]>>");
if(hypo_left != null) {
if(hypo_left != null && verbose) {
System.out.println("HypLeftWrong: " + hypo_left.truth);
}

Sentence hypo_right = ConceptMonitor.strongestPrecondition(nar, "<{SELF} --> [good]>",
"<(&/,<{right} --> [on]>,+12,(^Left,{SELF}),+13) =/> <{SELF} --> [good]>>");
if(hypo_right != null) {
if(hypo_right != null && verbose) {
System.out.println("HypRightWrong: " + hypo_right.truth);
}

Sentence hypo_left_false = ConceptMonitor.strongestPrecondition(nar, "<{SELF} --> [good]>",
"<(&/,<{left} --> [on]>,+1,(^Left,{SELF}),+1) =/> <{SELF} --> [good]>>");
if(hypo_left_false != null) {
if(hypo_left_false != null && verbose) {
System.out.println("HypLeft: " + hypo_left_false.truth);
}

Sentence hypo_right_false = ConceptMonitor.strongestPrecondition(nar, "<{SELF} --> [good]>",
"<(&/,<{right} --> [on]>,+12,(^Right,{SELF}),+13) =/> <{SELF} --> [good]>>");
if(hypo_right_false != null) {
if(hypo_right_false != null && verbose) {
System.out.println("HypRight: " + hypo_right_false.truth);
}
}
Expand All @@ -198,9 +199,11 @@ int UpdateSOM(float[] viewField,float reward) //input and reward
if(Math.abs(agent.x - ball.x) < middle_distance && ball.y < 120) { //same here
String s = "<{SELF} --> [good]>. :|:";
if(!s.equals(this.LastInput)) {
System.out.println("good mr_nars");
if (verbose) {
System.out.println("good mr_nars");
System.out.println(s);
}
nar.addInput(s);
System.out.println(s);
}
this.LastInput = s;
} else {
Expand All @@ -215,14 +218,18 @@ int UpdateSOM(float[] viewField,float reward) //input and reward
String s = "<{right} --> [on]>. :|:";
if(!s.equals(this.LastInput)) {
nar.addInput(s);
System.out.println(s);
if (verbose) {
System.out.println(s);
}
}
this.LastInput = s;
} else {
String s = "<{left} --> [on]>. :|:";
if(!s.equals(this.LastInput)) {
nar.addInput(s);
System.out.println(s);
if (verbose) {
System.out.println(s);
}
}
this.LastInput = s;
}
Expand Down

0 comments on commit 668b318

Please sign in to comment.