Search code examples
typescommunicationanylogicagentstatechart

check state of another statechart agent type Anylogic


I am in the statechart of the one agent type (Person) and I want to send a message to another agent type (Person2) in a certain state (atHome), but when I use code below the program throws me an error

for( Person2 m : main.person2s ) {

   if( m.inState(atHome)==true ) { 
       send("hi", m);
   }
}

what should I do to call another agent type in a certain state?


Solution

  • Try this instead

    for( Person2 m : main.person2s ) {
    
       if( m.inState(m.atHome) ) { 
           send("hi", m);
       }
    }