-1

I have a problem with a project in AnyLogic:

When it switches from one state to another, a member of my population has to change color. I was able to set the condition, I set the color change but it changes the color of the whole population. Help me, please!

The condition from state to newbus is stock>0. The condition from newbus to state is stock<0. The action in state is testa.setFillColor(lime). The action in newbus is testa.setFillColor(lime).

Emile Zankoul
  • 2,161
  • 2
  • 6
  • 18

1 Answers1

0

Probably your statechart sits on Main and not inside the agent type itself, right?

Put the state chart into the agent type that makes up the population and it will work (as long as testa is the name of some presentation element like a rectangle within that agent type).

Check some example models as many do this as well, if you are confused.

Benjamin
  • 10,603
  • 3
  • 16
  • 28
  • Nono, my grafic is inside the agent type. Where are the example models? – Aurora de Paolis Feb 01 '21 at 15:54
  • then share more info and screenshots on the details pls. Example models can be found under Help/Example Models/. There is a search as well, can't rememeber the exact ones but there are several – Benjamin Feb 01 '21 at 17:24
  • My problem is to access an individual agent from people population and to change his color. There'is a main, with a connection with tha gent population "bus", in the bus i create two state with a link with condition (stock >0) and when the condiction in true a member of population changes color but when i run, all population changes color. – Aurora de Paolis Feb 02 '21 at 10:20
  • You can access individual population members using `main.bus.get(i)` where i is the index of that agent. Check the AnyLogic help searching for "where am I and how do I get to" to learn more about these concepts, they are crucial to master :) – Benjamin Feb 02 '21 at 15:46