|
@@ -73,7 +73,7 @@ class MoveToMechanism(SubjectMechanism):
|
73
|
73
|
found_path = find_path(self.simulation.graph, start, end)
|
74
|
74
|
move.path = []
|
75
|
75
|
|
76
|
|
- for position in found_path[0]:
|
|
76
|
+ for position in found_path[0][1:]:
|
77
|
77
|
x, y = map(int, position.split('.'))
|
78
|
78
|
move.path.append((x, y))
|
79
|
79
|
|
|
@@ -105,10 +105,18 @@ class MoveToMechanism(SubjectMechanism):
|
105
|
105
|
|
106
|
106
|
|
107
|
107
|
class MoveEvent(Event):
|
108
|
|
- def __init__(self, subject_id: int, position: tuple, *args, **kwargs):
|
|
108
|
+ def __init__(
|
|
109
|
+ self,
|
|
110
|
+ subject_id: int,
|
|
111
|
+ from_position: typing.Tuple[int, int],
|
|
112
|
+ to_position: typing.Tuple[int, int],
|
|
113
|
+ *args,
|
|
114
|
+ **kwargs
|
|
115
|
+ ):
|
109
|
116
|
super().__init__(*args, **kwargs)
|
110
|
117
|
self.subject_id = subject_id
|
111
|
|
- self.position = position
|
|
118
|
+ self.from_position = from_position
|
|
119
|
+ self.to_position = to_position
|
112
|
120
|
|
113
|
121
|
def repr_debug(self) -> str:
|
114
|
122
|
return '{}: subject_id:{}, position:{}'.format(
|
|
@@ -147,9 +155,10 @@ class MoveToBehaviour(SubjectBehaviour):
|
147
|
155
|
# TODO: fin de path
|
148
|
156
|
move.path_progression += 1
|
149
|
157
|
new_position = move.path[move.path_progression]
|
|
158
|
+ previous_position = self.subject.position
|
150
|
159
|
self.subject.position = new_position
|
151
|
160
|
|
152
|
|
- return [MoveEvent(self.subject.id, new_position)]
|
|
161
|
+ return [MoveEvent(self.subject.id, previous_position, new_position)]
|
153
|
162
|
|
154
|
163
|
except KeyError:
|
155
|
164
|
# TODO: log ? Il devrait y avoir un move puisque data du run/mechanism !
|