Skip to content

Commit bea81d2

Browse files
committed
Minor fix (Obstruction at start position).
1 parent ed37491 commit bea81d2

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

aima-core/src/main/java/aima/core/environment/vacuum/MazeVacuumEnvironment.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,15 @@ public MazeVacuumEnvironment(int xDim, int yDim, double dirtProbability, double
4646
}
4747
}
4848

49-
public void setObstacle(String location, boolean state) {
50-
envState.setLocationState(location, state ? null : LocationState.Clean);
49+
@Override
50+
public void addAgent(Agent<? super VacuumPercept, ? extends Action> agent) {
51+
super.addAgent(agent);
52+
if (envState.getLocationState(getAgentLocation(agent)) == null)
53+
envState.setLocationState(getAgentLocation(agent), LocationState.Clean);
54+
}
55+
56+
public void setObstacle(String location, boolean b) {
57+
envState.setLocationState(location, b ? null : LocationState.Clean);
5158
}
5259

5360
public boolean containsObstacle(String location) {

0 commit comments

Comments
 (0)