From a40e279f486bb5b3ee9fc53533f359f53a2b588a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20L=C3=B6wenstrom?= <jan.loewenstrom@web.de>
Date: Sat, 4 Apr 2020 14:41:58 +0200
Subject: [PATCH] change reward function for antgame to match BA

---
 src/main/java/evironment/antGame/AntWorld.java | 12 ++++++------
 src/main/java/evironment/antGame/Reward.java   | 12 ++++++------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/main/java/evironment/antGame/AntWorld.java b/src/main/java/evironment/antGame/AntWorld.java
index 0a71a31..c9f9453 100644
--- a/src/main/java/evironment/antGame/AntWorld.java
+++ b/src/main/java/evironment/antGame/AntWorld.java
@@ -84,10 +84,10 @@ public class AntWorld implements Environment<AntAction>, Visualizable {
             case PICK_UP:
                 if(myAnt.hasFood()) {
                     // Ant tries to pick up food but can only hold one piece
-                    sc.reward += Reward.FOOD_PICK_UP_FAIL_HAS_FOOD_ALREADY;
+                    sc.reward = Reward.FOOD_PICK_UP_FAIL_HAS_FOOD_ALREADY;
                 } else if(currentCell.getFood() == 0) {
                     // Ant tries to pick up food on cell that has no food on it
-                    sc.reward += Reward.FOOD_PICK_UP_FAIL_NO_FOOD;
+                    sc.reward = Reward.FOOD_PICK_UP_FAIL_NO_FOOD;
                 } else if(currentCell.getFood() > 0) {
                     // Ant successfully picks up food
                     currentCell.setFood(currentCell.getFood() - 1);
@@ -98,13 +98,13 @@ public class AntWorld implements Environment<AntAction>, Visualizable {
             case DROP_DOWN:
                 if(!myAnt.hasFood()) {
                     // Ant had no food to drop
-                    sc.reward += Reward.FOOD_DROP_DOWN_FAIL_NO_FOOD;
+                    sc.reward = Reward.FOOD_DROP_DOWN_FAIL_NO_FOOD;
                 } else {
                     myAnt.setHasFood(false);
                     // negative reward if the agent drops food on any other field
                     // than the starting point
                     if(currentCell.getType() != CellType.START) {
-                        sc.reward += Reward.FOOD_DROP_DOWN_FAIL_NOT_START;
+                        sc.reward = Reward.FOOD_DROP_DOWN_FAIL_NOT_START;
                         // Drop food onto the ground
                         currentCell.setFood(currentCell.getFood() + 1);
                     } else {
@@ -122,10 +122,10 @@ public class AntWorld implements Environment<AntAction>, Visualizable {
         if(!sc.stayOnCell) {
             if(!isInGrid(sc.potentialNextPos)) {
                 sc.stayOnCell = true;
-                sc.reward += Reward.RAN_INTO_WALL;
+                sc.reward = Reward.RAN_INTO_WALL;
             } else if(hitObstacle(sc.potentialNextPos)) {
                 sc.stayOnCell = true;
-                sc.reward += Reward.RAN_INTO_OBSTACLE;
+                sc.reward = Reward.RAN_INTO_OBSTACLE;
             }
         }
 
diff --git a/src/main/java/evironment/antGame/Reward.java b/src/main/java/evironment/antGame/Reward.java
index c2e008d..2ab8f9a 100644
--- a/src/main/java/evironment/antGame/Reward.java
+++ b/src/main/java/evironment/antGame/Reward.java
@@ -3,15 +3,15 @@ package evironment.antGame;
 public class Reward {
     public static final double DEFAULT_REWARD = -1;
     public static final double FOOD_PICK_UP_SUCCESS = 0;
-    public static final double FOOD_PICK_UP_FAIL_NO_FOOD = -1;
-    public static final double FOOD_PICK_UP_FAIL_HAS_FOOD_ALREADY = -1;
+    public static final double FOOD_PICK_UP_FAIL_NO_FOOD = -2;
+    public static final double FOOD_PICK_UP_FAIL_HAS_FOOD_ALREADY = -2;
 
-    public static final double FOOD_DROP_DOWN_FAIL_NO_FOOD = -1;
-    public static final double FOOD_DROP_DOWN_FAIL_NOT_START = -1;
+    public static final double FOOD_DROP_DOWN_FAIL_NO_FOOD = -2;
+    public static final double FOOD_DROP_DOWN_FAIL_NOT_START = -2;
     public static final double FOOD_DROP_DOWN_SUCCESS = 1;
 
     public static final double UNKNOWN_FIELD_EXPLORED = 0;
 
-    public static final double RAN_INTO_WALL = -1;
-    public static final double RAN_INTO_OBSTACLE = -1;
+    public static final double RAN_INTO_WALL = -2;
+    public static final double RAN_INTO_OBSTACLE = -2;
 }