diff --git a/example/cbs.cpp b/example/cbs.cpp index 1bdb3d0b..b7fb7714 100644 --- a/example/cbs.cpp +++ b/example/cbs.cpp @@ -430,7 +430,7 @@ class Environment { // This is a trick to avoid changing the rest of the code significantly // After an agent disappeared, put it at a unique but invalid position // This will cause all calls to equalExceptTime(.) to return false. - return State(-1 * agentIdx, -1, -1); + return State(-1, -1 * (agentIdx + 1), -1); } return solution[agentIdx].states.back().first; } diff --git a/example/ecbs.cpp b/example/ecbs.cpp index 268336ae..6480abf5 100644 --- a/example/ecbs.cpp +++ b/example/ecbs.cpp @@ -498,7 +498,7 @@ class Environment { // This is a trick to avoid changing the rest of the code significantly // After an agent disappeared, put it at a unique but invalid position // This will cause all calls to equalExceptTime(.) to return false. - return State(-1 * agentIdx, -1, -1); + return State(-1, -1 * (agentIdx+1), -1); } return solution[agentIdx].states.back().first; } diff --git a/test/issue28.yaml b/test/issue28.yaml new file mode 100644 index 00000000..f0bb6dd3 --- /dev/null +++ b/test/issue28.yaml @@ -0,0 +1,17 @@ +map: + dimensions: [4, 4] + obstacles: + - [0, 2] + - [0, 3] + - [1, 3] + - [3, 3] +agents: + - name: agent0 + start: [1, 2] + goal: [3, 0] + - name: agent1 + start: [3, 2] + goal: [2, 2] + - name: agent2 + start: [2, 1] + goal: [0, 0] diff --git a/test/test_cbs.py b/test/test_cbs.py index a46ace43..c3a2a2a9 100644 --- a/test/test_cbs.py +++ b/test/test_cbs.py @@ -43,5 +43,9 @@ def test_someAtGoal_disappearingAgents(self): r = self.runCBS("../test/mapf_someAtGoal.yaml", additionalArgs=["--disappear-at-goal"]) self.assertTrue(r["statistics"]["cost"] == 1) + def test_issue28_disappearingAgents(self): + r = self.runCBS("../test/issue28.yaml", additionalArgs=["--disappear-at-goal"]) + self.assertTrue(r["statistics"]["cost"] == 8) + if __name__ == '__main__': unittest.main() diff --git a/test/test_ecbs.py b/test/test_ecbs.py index d7651b58..c0192eb3 100644 --- a/test/test_ecbs.py +++ b/test/test_ecbs.py @@ -45,5 +45,9 @@ def test_someAtGoal_disappearingAgents(self): r = self.runECBS("../test/mapf_someAtGoal.yaml", 1.0, additionalArgs=["--disappear-at-goal"]) self.assertTrue(r["statistics"]["cost"] == 1) + def test_issue28_disappearingAgents(self): + r = self.runECBS("../test/issue28.yaml", 1.0, additionalArgs=["--disappear-at-goal"]) + self.assertTrue(r["statistics"]["cost"] == 8) + if __name__ == '__main__': unittest.main()