I am learning Anylogic, at the moment I want to run a bus on a given route with certain bus stops. For this I am using the following logic: carSource->carMoveTo1->selectOutput->carMoveTo2->carDispose. carSource is the place where the bus appears; carMoveTo1 is the stop the bus goes to; selectOutPut is the condition under which the bus ends its route; carMoveTo2 is the road to which the bus follows when the route ends. Also in carMoveTo1 I specify the destination: bus.stops[bus.stop_value++] (this is how I pass the stop count to the bus). In selectOutPut I add a condition: bus.stops.length==bus.stop_value. For the bus I set agent "bus" which has two parameters: stops(type "other" - BusStop[], control type "one-dimensional array") is an array of stops; stop_value(int type) - stops counter. This logic causes an error: the stop_value counter exceeds the limits of stops[] array. As far as I understand, it happens because in carMoveTo1 I'm incrementing the stop_value counter within the bus class from each bus.stops[bus.stop_value++]. How can I make each bus have a separate counter?
P.S. I've tried to refer to this: bus.stops[this.stop_value++] pointer - another error occurs.