|
@@ -70,7 +70,9 @@ const moveTrains = (trains: Train[], stations: Station[]) => {
|
70
|
70
|
for (const train of trains) {
|
71
|
71
|
// choose a destination randomly with a bias towards larger stations
|
72
|
72
|
if (train.destination === undefined) {
|
73
|
|
- const closeStations = Station.stationsWithinRadius(stations, train.location, MAX_JOURNEY);
|
|
73
|
+ const otherStations = stations.filter(station => station !== train.origin);
|
|
74
|
+ const closeStations = Station.stationsWithinRadius(otherStations, train.location,
|
|
75
|
+ MAX_JOURNEY);
|
74
|
76
|
const closeStationWeights = closeStations.map(station => station.population);
|
75
|
77
|
train.destination = weightedRandom(closeStations, closeStationWeights);
|
76
|
78
|
}
|
|
@@ -140,10 +142,14 @@ const run = () => {
|
140
|
142
|
|
141
|
143
|
graphics.clear();
|
142
|
144
|
fpsText.text = `${Math.round(ticker.FPS)}`;
|
143
|
|
- graphics.lineStyle(1, 0xaeaeae, 1);
|
144
|
145
|
|
|
146
|
+ graphics.lineStyle(1, 0xFFA500, 1);
|
145
|
147
|
drawStations(stations, graphics);
|
|
148
|
+
|
|
149
|
+ graphics.lineStyle(1, 0xAEAEAE, 1);
|
146
|
150
|
drawTrains(trains, graphics);
|
|
151
|
+
|
|
152
|
+ // TODO: ?
|
147
|
153
|
// drawLine(line, graphics);
|
148
|
154
|
});
|
149
|
155
|
ticker.start();
|