change reward function for antgame to match BA
This commit is contained in:
parent
9a3452ff9c
commit
a40e279f48
|
@ -84,10 +84,10 @@ public class AntWorld implements Environment<AntAction>, Visualizable {
|
||||||
case PICK_UP:
|
case PICK_UP:
|
||||||
if(myAnt.hasFood()) {
|
if(myAnt.hasFood()) {
|
||||||
// Ant tries to pick up food but can only hold one piece
|
// 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) {
|
} else if(currentCell.getFood() == 0) {
|
||||||
// Ant tries to pick up food on cell that has no food on it
|
// 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) {
|
} else if(currentCell.getFood() > 0) {
|
||||||
// Ant successfully picks up food
|
// Ant successfully picks up food
|
||||||
currentCell.setFood(currentCell.getFood() - 1);
|
currentCell.setFood(currentCell.getFood() - 1);
|
||||||
|
@ -98,13 +98,13 @@ public class AntWorld implements Environment<AntAction>, Visualizable {
|
||||||
case DROP_DOWN:
|
case DROP_DOWN:
|
||||||
if(!myAnt.hasFood()) {
|
if(!myAnt.hasFood()) {
|
||||||
// Ant had no food to drop
|
// 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 {
|
} else {
|
||||||
myAnt.setHasFood(false);
|
myAnt.setHasFood(false);
|
||||||
// negative reward if the agent drops food on any other field
|
// negative reward if the agent drops food on any other field
|
||||||
// than the starting point
|
// than the starting point
|
||||||
if(currentCell.getType() != CellType.START) {
|
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
|
// Drop food onto the ground
|
||||||
currentCell.setFood(currentCell.getFood() + 1);
|
currentCell.setFood(currentCell.getFood() + 1);
|
||||||
} else {
|
} else {
|
||||||
|
@ -122,10 +122,10 @@ public class AntWorld implements Environment<AntAction>, Visualizable {
|
||||||
if(!sc.stayOnCell) {
|
if(!sc.stayOnCell) {
|
||||||
if(!isInGrid(sc.potentialNextPos)) {
|
if(!isInGrid(sc.potentialNextPos)) {
|
||||||
sc.stayOnCell = true;
|
sc.stayOnCell = true;
|
||||||
sc.reward += Reward.RAN_INTO_WALL;
|
sc.reward = Reward.RAN_INTO_WALL;
|
||||||
} else if(hitObstacle(sc.potentialNextPos)) {
|
} else if(hitObstacle(sc.potentialNextPos)) {
|
||||||
sc.stayOnCell = true;
|
sc.stayOnCell = true;
|
||||||
sc.reward += Reward.RAN_INTO_OBSTACLE;
|
sc.reward = Reward.RAN_INTO_OBSTACLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,15 +3,15 @@ package evironment.antGame;
|
||||||
public class Reward {
|
public class Reward {
|
||||||
public static final double DEFAULT_REWARD = -1;
|
public static final double DEFAULT_REWARD = -1;
|
||||||
public static final double FOOD_PICK_UP_SUCCESS = 0;
|
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_NO_FOOD = -2;
|
||||||
public static final double FOOD_PICK_UP_FAIL_HAS_FOOD_ALREADY = -1;
|
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_NO_FOOD = -2;
|
||||||
public static final double FOOD_DROP_DOWN_FAIL_NOT_START = -1;
|
public static final double FOOD_DROP_DOWN_FAIL_NOT_START = -2;
|
||||||
public static final double FOOD_DROP_DOWN_SUCCESS = 1;
|
public static final double FOOD_DROP_DOWN_SUCCESS = 1;
|
||||||
|
|
||||||
public static final double UNKNOWN_FIELD_EXPLORED = 0;
|
public static final double UNKNOWN_FIELD_EXPLORED = 0;
|
||||||
|
|
||||||
public static final double RAN_INTO_WALL = -1;
|
public static final double RAN_INTO_WALL = -2;
|
||||||
public static final double RAN_INTO_OBSTACLE = -1;
|
public static final double RAN_INTO_OBSTACLE = -2;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue