0

I need to solve a problem, which due to my lack of Java training I can't solve. What is the code to write to trace the agent who took a resource? Let me explain better...I have a series of rooms, each agent who enters the structure takes a room which he keeps for his entire stay, and I would like to see in real-time, which rooms are occupied and by which agent. How can I do this? Thank you

Jaco-Ben Vosloo
  • 3,770
  • 2
  • 16
  • 33
Miriana
  • 95
  • 6

1 Answers1

1

You can simply save the resource seized to the agent and vice versa using variables, in the seize block.

Here is a simple example

I have a Person and a RoomResource agent, each with a variable of the other's type.

enter image description here

In this very simple flow chart with a source that creates persons, and a seize connected to a resource pool of RoomResource agents, and the resource units live in a population called roomResource.

enter image description here

You simply specify the following in the seize block

agent.room = unit;
unit.agent = agent;

enter image description here

You will see that agent represents the agent in the block, and unit represents the unit being seized from the resource pool

enter image description here

Now you can visually use this for your agents

enter image description here

Now you can see what Person occupies which room and which room is used for each person by accessing the variable

Jaco-Ben Vosloo
  • 3,770
  • 2
  • 16
  • 33
  • thank you very much for your reply! Once I have displayed the person occupying the room, can I access their variables? – Miriana Aug 03 '21 at 09:00
  • Yes - you can access the person and then all their variables and perhaps have it displayed on the animation in the room. – Jaco-Ben Vosloo Aug 03 '21 at 09:01