104 lines
3.2 KiB
Plaintext
104 lines
3.2 KiB
Plaintext
FUNCTION_BLOCK worker
|
|
|
|
VAR_INPUT
|
|
form1: REAL;
|
|
form2: REAL;
|
|
points: REAL;
|
|
xGform1: REAL;
|
|
xGform2: REAL;
|
|
END_VAR
|
|
|
|
VAR_OUTPUT
|
|
result: REAL;
|
|
END_VAR
|
|
|
|
FUZZIFY form1
|
|
RANGE := (-1.000 .. 5.000);
|
|
TERM bad := (1,1)(2,0);
|
|
TERM avg := (1,0)(2,1)(3,1)(4,0);
|
|
TERM great := (3,0)(4,1);
|
|
END_FUZZIFY
|
|
|
|
FUZZIFY form2
|
|
RANGE := (-1.000 .. 5.000);
|
|
TERM bad := (1,1)(2,0);
|
|
TERM avg := (1,0)(2,1)(3,1)(4,0);
|
|
TERM great := (3,0)(4,1);
|
|
END_FUZZIFY
|
|
|
|
FUZZIFY points
|
|
RANGE := (-30.000 .. 30.000);
|
|
TERM low := (-25,1)(-10,0);
|
|
TERM avg := (-10,0)(-3,1)(3,1)(10,0);
|
|
TERM high := (10,0)(25,1);
|
|
END_FUZZIFY
|
|
|
|
FUZZIFY xGform1
|
|
RANGE := (-15.000 .. 15.000);
|
|
TERM luck := (-5,1)(-2,0);
|
|
TERM badluck := (2,0)(5,1);
|
|
END_FUZZIFY
|
|
|
|
FUZZIFY xGform2
|
|
RANGE := (-15.000 .. 15.000);
|
|
TERM luck := (-5,1)(-2,0);
|
|
TERM badluck := (2,0)(5,1);
|
|
END_FUZZIFY
|
|
|
|
DEFUZZIFY result
|
|
RANGE := (-1.000 .. 1.000);
|
|
TERM home := (-1,1) (0,0);
|
|
TERM draw := (-0.5,0) (0,1) (0.5,0);
|
|
TERM away := (0,0) (1,1);
|
|
METHOD : COG;
|
|
// ACCU : MAX;
|
|
DEFAULT := 0
|
|
END_DEFUZZIFY
|
|
|
|
RULEBLOCK
|
|
AND : MIN;
|
|
ACCU : MAX;
|
|
ACT : MIN;
|
|
|
|
|
|
RULE 0 : if form1 is great and form2 is bad then result is home
|
|
// rozbicie home
|
|
RULE 3 : if form1 is great and form2 is avg and points is low then result is draw
|
|
RULE 4 : if form1 is great and form2 is avg and points is avg then result is home
|
|
|
|
RULE 5 : if form1 is great and form2 is avg and points is high then result is home
|
|
//rozbicie
|
|
RULE 6 : if form1 is great and form2 is great and points is low then result is away
|
|
RULE 7 : if form1 is great and form2 is great and points is avg then result is home
|
|
RULE 8 : if form1 is great and form2 is great and points is high then result is home
|
|
|
|
//rozbicie home
|
|
RULE 31 : if form1 is avg and form2 is bad and points is low then result is draw
|
|
RULE 32 : if form1 is avg and form2 is bad and points is avg then result is home
|
|
RULE 33 : if form1 is avg and form2 is bad and points is high then result is home
|
|
//rozbicie
|
|
RULE 34 : if form1 is avg and form2 is avg and points is low then result is away
|
|
RULE 35 : if form1 is avg and form2 is avg and points is avg then result is home
|
|
RULE 36 : if form1 is avg and form2 is avg and points is high then result is home
|
|
|
|
// rozbicie away
|
|
RULE 37 : if form1 is avg and form2 is great and points is low then result is away
|
|
RULE 38 : if form1 is avg and form2 is great and points is avg then result is away
|
|
RULE 39 : if form1 is avg and form2 is great and points is high then result is home
|
|
RULE 40 : if form1 is avg and form2 is great and points is high and (xGform1 is badluck or xGform2 is luck) then result is home
|
|
// rozbicie
|
|
RULE 61 : if form1 is bad and form2 is bad and points is low then result is away
|
|
RULE 62 : if form1 is bad and form2 is bad and points is avg then result is draw
|
|
RULE 63 : if form1 is bad and form2 is bad and points is high then result is home
|
|
|
|
RULE 66 : if form1 is bad and form2 is avg then result is away
|
|
// rozbicie away
|
|
RULE 67 : if form1 is bad and form2 is great and points is low then result is away
|
|
RULE 68 : if form1 is bad and form2 is great and points is avg then result is away
|
|
RULE 69 : if form1 is bad and form2 is great and points is high then result is draw
|
|
|
|
|
|
END_RULEBLOCK
|
|
|
|
END_FUNCTION_BLOCK
|