I have found an example
FUZZIFY Our_Health
TERM Near_Death := (0, 0) (0, 0.50) (0, 1) (0, 1) (7, 0.66) (26, 0.22) (50.50, 0) ;
TERM Good := (14, 0) (22.50, 0.25) (31, 0.75) (48.50, 1) (66, 0.75) (74.50, 0.25) (83, 0) ;
TERM Excellent := (50.50, 0) (100, 1) (100, 0) ;
END_FUZZIFY
FUZZIFY Enemy_Health
TERM Near_Death := (0, 0) (0, 1) (50.50, 0) ;
TERM Good := (14, 0) (48.50, 1) (83.50, 0) ;
TERM Excellent := (50.50, 0) (100, 1) (100, 0) ;
END_FUZZIFY
FUZZIFY Aggressiveness
TERM Run_Away := 1;
TERM Fight_Defensively := 2;
TERM All_Out_Attack := 3;
END_FUZZIFY
DEFUZZIFY valve
METHOD: MoM;
END_DEFUZZIFY
RULEBLOCK first
AND:MIN;
ACCU:MAX;
RULE 0: IF (Our_Health IS Near_Death) AND (Enemy_Health IS Near_Death) THEN (Aggressiveness IS Fight_Defensively);
RULE 1: IF (Our_Health IS Near_Death) AND (Enemy_Health IS Good) THEN (Aggressiveness IS Run_Away);
RULE 2: IF (Our_Health IS Near_Death) AND (Enemy_Health IS Excellent) THEN (Aggressiveness IS Run_Away);
RULE 3: IF (Our_Health IS Good) AND (Enemy_Health IS Near_Death) THEN (Aggressiveness IS All_Out_Attack);
RULE 4: IF (Our_Health IS Good) AND (Enemy_Health IS Good) THEN (Aggressiveness IS Fight_Defensively);
RULE 5: IF (Our_Health IS Good) AND (Enemy_Health IS Excellent) THEN (Aggressiveness IS Fight_Defensively);
RULE 6: IF (Our_Health IS Excellent) AND (Enemy_Health IS Near_Death) THEN (Aggressiveness IS All_Out_Attack);
RULE 7: IF (Our_Health IS Excellent) AND (Enemy_Health IS Good) THEN (Aggressiveness IS All_Out_Attack);
RULE 8: IF (Our_Health IS Excellent) AND (Enemy_Health IS Excellent) THEN (Aggressiveness IS Fight_Defensively);
END_RULEBLOCK
END_FUNCTION_BLOCK
How to put this in my PLC?
i did write my own fuzzer.lib, however there is a document which describes above.
has anybody done it?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
anybody busy in this field for codesys?
I have found an example
FUZZIFY Our_Health
TERM Near_Death := (0, 0) (0, 0.50) (0, 1) (0, 1) (7, 0.66) (26, 0.22) (50.50, 0) ;
TERM Good := (14, 0) (22.50, 0.25) (31, 0.75) (48.50, 1) (66, 0.75) (74.50, 0.25) (83, 0) ;
TERM Excellent := (50.50, 0) (100, 1) (100, 0) ;
END_FUZZIFY
FUZZIFY Enemy_Health
TERM Near_Death := (0, 0) (0, 1) (50.50, 0) ;
TERM Good := (14, 0) (48.50, 1) (83.50, 0) ;
TERM Excellent := (50.50, 0) (100, 1) (100, 0) ;
END_FUZZIFY
FUZZIFY Aggressiveness
TERM Run_Away := 1;
TERM Fight_Defensively := 2;
TERM All_Out_Attack := 3;
END_FUZZIFY
DEFUZZIFY valve
METHOD: MoM;
END_DEFUZZIFY
RULEBLOCK first
AND:MIN;
ACCU:MAX;
RULE 0: IF (Our_Health IS Near_Death) AND (Enemy_Health IS Near_Death) THEN (Aggressiveness IS Fight_Defensively);
RULE 1: IF (Our_Health IS Near_Death) AND (Enemy_Health IS Good) THEN (Aggressiveness IS Run_Away);
RULE 2: IF (Our_Health IS Near_Death) AND (Enemy_Health IS Excellent) THEN (Aggressiveness IS Run_Away);
RULE 3: IF (Our_Health IS Good) AND (Enemy_Health IS Near_Death) THEN (Aggressiveness IS All_Out_Attack);
RULE 4: IF (Our_Health IS Good) AND (Enemy_Health IS Good) THEN (Aggressiveness IS Fight_Defensively);
RULE 5: IF (Our_Health IS Good) AND (Enemy_Health IS Excellent) THEN (Aggressiveness IS Fight_Defensively);
RULE 6: IF (Our_Health IS Excellent) AND (Enemy_Health IS Near_Death) THEN (Aggressiveness IS All_Out_Attack);
RULE 7: IF (Our_Health IS Excellent) AND (Enemy_Health IS Good) THEN (Aggressiveness IS All_Out_Attack);
RULE 8: IF (Our_Health IS Excellent) AND (Enemy_Health IS Excellent) THEN (Aggressiveness IS Fight_Defensively);
END_RULEBLOCK
END_FUNCTION_BLOCK
How to put this in my PLC?
i did write my own fuzzer.lib, however there is a document which describes above.
has anybody done it?