Skip to content

Commit

Permalink
Updates debug printing lines
Browse files Browse the repository at this point in the history
  • Loading branch information
ronaldosvieira committed Jun 16, 2017
1 parent 27f1be7 commit 151ea6c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 24 deletions.
37 changes: 15 additions & 22 deletions src/mind/Mind.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public void update() {
// todo: try to merge perceptions
// if many of same type then merge all with distance = centroid

// System.out.println(being.getName() + " before -> " + perceptions);

// updates perceptions in working memory
workingMemory.stream()
.filter(tP -> perceptions.containsKey(tP.getSource().getId()))
Expand All @@ -51,39 +53,23 @@ public void update() {
perceptions.remove(id);
});

// System.out.println(being.getName() + " after -> " + perceptions);

workingMemory.removeIf(tP -> !tP.get("exists", Boolean.class));

for (Perception perception : perceptions.values()) {
workingMemory.add(new TemporalPerception(perception));

/*System.out.println("Living thing '" + this.being.getName()
+ "' just saw '" + perception.name() + "'.");*/
+ "' just saw perceived '" + perception.name() + "' with "
+ perception.get("from", String.class) + ".");*/

while (workingMemory.size() > 4) {
workingMemory.remove(0);
}
}

//System.out.println(being.getName() + being.getId() + ": " + workingMemory);

// todo: do stuff based on current working memory
/*for (TemporalPerception tP : workingMemory) {
if (!tP.get("is-alive", Boolean.class)) continue;
double size1 = tP.get("size", Double.class);
double size2 = being.getSemantic().get("size", Double.class);
if (size1 < size2) {
if (being.getCurrentGoal() instanceof MoveRandomly) {
Goal newGoal = new GoalChain(new MoveTo(being))
.then(new Attack(being))
.input(tP)
.get();
being.setCurrentGoal(newGoal);
System.out.println(being + " -> " + tP.name());
}
}
}*/
// System.out.println(being.getName() + being.getId() + ": " + workingMemory);

Need mostIntenseNeed = being.getNeeds().stream()
.sorted(Comparator.comparingDouble((Need n) -> {
Expand All @@ -102,11 +88,18 @@ public void update() {
+ (intensity * (1 + sources)));*/
return intensity * (1 + sources);
}).reversed())
//.sorted(Comparator.comparingDouble(Need::getIntensity).reversed())
.map(need -> {
// System.out.println(being + ": " + need.getName() + " -> " + need.getIntensity());
return need;
})
.findFirst()
.orElse(null);

if (mostIntenseNeed != currentNeed)
if (mostIntenseNeed != currentNeed) {
System.out.println(being.getName() + " changed need to " + mostIntenseNeed.getName());
being.setCurrentGoal(mostIntenseNeed.getGoal());
}

currentNeed = mostIntenseNeed;

Expand Down
5 changes: 5 additions & 0 deletions src/mind/goal/FleeFrom.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public void cycle(List<TemporalPerception> workingMemory) {

@Override
public boolean check() {
/*System.out.println(getAnimal().getName() + " flee-from - "
+ perception + " "
+ perception.get("timestamp", Long.class) + " "
+ perception.get("distance", Vector2f.class).length() + " "
+ perception.get("from", String.class) + " ");*/
return perception
.get("distance", Vector2f.class)
.length() > this.distance;
Expand Down
4 changes: 2 additions & 2 deletions src/mind/goal/MoveTo.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public Goal input(Perception perception) {
@Override
public void cycle(List<TemporalPerception> workingMemory) {
if (perception == null) System.out.println(getAnimal().getName() + " move-to null");
System.out.println(getAnimal().getName() + " move-to - "
/*System.out.println(getAnimal().getName() + " move-to - "
+ perception.get("timestamp", Long.class) + " "
+ perception.get("distance", Vector2f.class).length());
+ perception.get("distance", Vector2f.class).length());*/
getAnimal().setMovementSpeed(5);

direction = perception
Expand Down

0 comments on commit 151ea6c

Please sign in to comment.