let match_message_with_one_state_of_agent (sender : string) (sender_state : string Pervasives.ref) (message_sender : string) (reciever : string) (reciever_initial_state : string) : bool =
let rec find state lActions =
match lActions with [] -> false
|(s::ls) -> if(state = (findState s) && message_sender = (findIknows s))
then true
else find state ls
in
let rec aux2 lStates lActions res =
match lStates with [] -> List.rev res
|((state,boolean)::ls) -> if(find state lActions)
then aux2 ls lActions ((state,boolean)::res)
else aux2 ls lActions res
in
let rec aux l_automate =
match l_automate with
((name,id,current_statesL,lActions):: ls) -> if ((get_name_in_session name id)=sender)
then aux2 (!current_statesL) (List.map (fun e -> match e with (_,_,final) -> final) lActions) []
else aux ls;
| [] -> failwith "Bad automate";
in
let rec find_states states =
match states with [] -> false
|((state,exec)::ls) -> if( (operations_test_treatment_right sender state))
then( if(!exec) then (
if not(in_message_stack sender state message_sender) then
refresh_var_of_state sender state (!tag_number);
operations_affectation_treatment sender state
);
sender_state:=state ;
true
)
else (find_states ls)
in
find_states (aux (!automate))