improved fuzzy logic

This commit is contained in:
s452662 2024-01-29 16:24:58 +01:00
parent fdfb807430
commit 5b4baf4202

View File

@ -17,15 +17,15 @@ def categorize_fuzzy_passes(passes,possession):
FS.set_crisp_output_value("average", 0.5)
FS.set_crisp_output_value("high", 1.0)
Pass1 = TriangleFuzzySet(300,300,500, term="low")
Pass2 = TriangleFuzzySet(300,450,600, term="average")
Pass3 = TriangleFuzzySet(400,600,600, term="high")
Pass1 = TriangleFuzzySet(300,300,600, term="low")
Pass2 = TriangleFuzzySet(110,440,770, term="average")
Pass3 = TriangleFuzzySet(200,600,600, term="high")
FS.add_linguistic_variable("passes", LinguisticVariable([Pass1, Pass2, Pass3], universe_of_discourse=[0,1000]))
Poss1 = TriangleFuzzySet(30,30,45, term="low")
Poss2 = TriangleFuzzySet(40,50,60, term="average")
Poss3 = TriangleFuzzySet(55,70,70, term="high")
Poss1 = TriangleFuzzySet(30,30,50, term="low")
Poss2 = TriangleFuzzySet(35,50,65, term="average")
Poss3 = TriangleFuzzySet(50,70,70, term="high")
FS.add_linguistic_variable("possession", LinguisticVariable([Poss1, Poss2, Poss3], universe_of_discourse=[0,100]))
@ -74,17 +74,17 @@ def categorize_fuzzy_defence(tackles,clearances):
FS.set_crisp_output_value("average", 0.5)
FS.set_crisp_output_value("high", 1.0)
Tackle1 = TriangleFuzzySet(12,12,20, term="low")
Tackle2 = TriangleFuzzySet(12,18,24, term="average")
Tackle3 = TriangleFuzzySet(16,24,24, term="high")
Tackle1 = TriangleFuzzySet(12,12,24, term="low")
Tackle2 = TriangleFuzzySet(6,18,30, term="average")
Tackle3 = TriangleFuzzySet(12,24,24, term="high")
FS.add_linguistic_variable("tackles", LinguisticVariable([Tackle1, Tackle2, Tackle3], universe_of_discourse=[0,100]))
FS.add_linguistic_variable("tackles", LinguisticVariable([Tackle1, Tackle2, Tackle3], universe_of_discourse=[0,80]))
Clear1 = TriangleFuzzySet(12,12,30, term="low")
Clear2 = TriangleFuzzySet(12,27,42, term="average")
Clear3 = TriangleFuzzySet(24,42,42, term="high")
Clear1 = TriangleFuzzySet(12,12,36, term="low")
Clear2 = TriangleFuzzySet(9,27,45, term="average")
Clear3 = TriangleFuzzySet(18,42,42, term="high")
FS.add_linguistic_variable("clearances", LinguisticVariable([Clear1, Clear2, Clear3], universe_of_discourse=[0,100]))
FS.add_linguistic_variable("clearances", LinguisticVariable([Clear1, Clear2, Clear3], universe_of_discourse=[0,80]))
FS.add_rules([
@ -121,15 +121,15 @@ def categorize_fuzzy_shots(shots_overall, shots_on_target):
FS.set_crisp_output_value("average", 0.5)
FS.set_crisp_output_value("high", 1.0)
Shot_ov1 = TriangleFuzzySet(0,0,6, term="low") #pozmieniać przedziały (nakładają się)
Shot_ov2 = TriangleFuzzySet(5,10,15, term="average")
Shot_ov3 = TriangleFuzzySet(14,25,25, term="high")
Shot_ov1 = TriangleFuzzySet(3,3,12, term="low") #pozmieniać przedziały (nakładają się)
Shot_ov2 = TriangleFuzzySet(2,12,22, term="average")
Shot_ov3 = TriangleFuzzySet(6,25,25, term="high")
FS.add_linguistic_variable("shots_overall", LinguisticVariable([Shot_ov1, Shot_ov2, Shot_ov3], universe_of_discourse=[0,35]))
Shot_ont1 = TriangleFuzzySet(0,0,3, term="low")
Shot_ont2 = TriangleFuzzySet(2,4,6, term="average")
Shot_ont3 = TriangleFuzzySet(5,10,10, term="high")
Shot_ont1 = TriangleFuzzySet(1,1,6, term="low")
Shot_ont2 = TriangleFuzzySet(2,5,8, term="average")
Shot_ont3 = TriangleFuzzySet(3,10,10, term="high")
FS.add_linguistic_variable("shots_on_target", LinguisticVariable([Shot_ont1, Shot_ont2, Shot_ont3], universe_of_discourse=[0,15]))
@ -149,7 +149,7 @@ def categorize_fuzzy_shots(shots_overall, shots_on_target):
"IF (shots_overall IS average) AND (shots_on_target IS average) THEN (quality_of_shots IS average)",
"IF (shots_overall IS low) AND (shots_on_target IS high) THEN (quality_of_shots IS high)",
"IF (shots_overall IS low) AND (shots_on_target IS high) THEN (quality_of_shots IS average)",
"IF (shots_overall IS high ) AND (shots_on_target IS low) THEN (quality_of_shots IS low)",
@ -176,9 +176,9 @@ def calculateFuzzyAggression(yellow_cards, red_cards):
FS.set_crisp_output_value("average", 0.5)
FS.set_crisp_output_value("high", 1.0)
Yellow_cards1 = TriangleFuzzySet(0, 2, 3, term="low")
Yellow_cards2 = TriangleFuzzySet(2, 3, 4, term="average")
Yellow_cards3 = TriangleFuzzySet(3, 4, 4, term="high")
Yellow_cards1 = TriangleFuzzySet(0, 2, 4, term="low")
Yellow_cards2 = TriangleFuzzySet(1, 3, 5, term="average")
Yellow_cards3 = TriangleFuzzySet(2, 4, 4, term="high")
FS.add_linguistic_variable("yellow_cards", LinguisticVariable([Yellow_cards1, Yellow_cards2, Yellow_cards3], universe_of_discourse=[0, 10]))
@ -210,7 +210,7 @@ def calculateFuzzyAggression(yellow_cards, red_cards):
"IF (yellow_cards IS high) AND (red_cards IS average) THEN (aggression IS high)",
"IF (yellow_cards IS low) AND (red_cards IS average) THEN (aggression IS low)",
"IF (yellow_cards IS low) AND (red_cards IS average) THEN (aggression IS average)",
"IF (yellow_cards IS average) AND (red_cards IS low) THEN (aggression IS average)"
])