DawnC commited on
Commit
a5a0a2f
1 Parent(s): 7a93615

Update scoring_calculation_system.py

Browse files
Files changed (1) hide show
  1. scoring_calculation_system.py +64 -29
scoring_calculation_system.py CHANGED
@@ -674,43 +674,78 @@ def calculate_compatibility_score(breed_info: dict, user_prefs: UserPreferences)
674
  temperament_adjustments -= 0.12 # 加重對特定類型品種的懲罰
675
 
676
  elif user_experience == "intermediate":
677
- # 中級玩家的調整更加平衡
678
- moderate_traits = {
679
- 'intelligent': 0.05, # 獎勵聰明
680
- 'athletic': 0.04, # 獎勵運動能力
681
- 'versatile': 0.04, # 獎勵多功能性
682
- 'stubborn': -0.06, # 輕微懲罰固執
683
- 'independent': -0.05, # 輕微懲罰獨立性
684
- 'protective': -0.04 # 輕微懲罰保護性
685
  }
 
686
 
687
- for trait, adjustment in moderate_traits.items():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
688
  if trait in temperament_lower:
689
- temperament_adjustments += adjustment
690
 
 
 
 
 
 
691
  else: # advanced
692
- # 資深玩家能夠應對挑戰性特徵
693
- advanced_traits = {
694
- 'stubborn': 0.02, # 降低加分幅度
695
- 'independent': 0.02,
696
- 'intelligent': 0.05,
697
- 'protective': 0.02,
698
- 'strong-willed': 0.02,
699
- 'aggressive': -0.04, # 新增負面特徵
700
- 'nervous': -0.03,
701
- 'dominant': -0.02
702
  }
 
703
 
704
- for trait, bonus in advanced_traits.items():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
705
  if trait in temperament_lower:
706
- # 加入條件評估
707
- if bonus > 0: # 正面特徵
708
- # 限制正面特徵的累積加分不超過0.15
709
- if temperament_adjustments + bonus <= 0.15:
710
- temperament_adjustments += bonus
711
- else: # 負面特徵
712
- # 負面特徵一定要計算
713
- temperament_adjustments += bonus
714
 
715
  # 確保最終分數在合理範圍內
716
  final_score = max(0.2, min(1.0, score + temperament_adjustments))
 
674
  temperament_adjustments -= 0.12 # 加重對特定類型品種的懲罰
675
 
676
  elif user_experience == "intermediate":
677
+ base_scores = {
678
+ "High": {"intermediate": 0.65},
679
+ "Moderate": {"intermediate": 0.75},
680
+ "Low": {"intermediate": 0.85}
 
 
 
 
681
  }
682
+ score = base_scores.get(care_level, base_scores["Moderate"])[user_experience]
683
 
684
+ # 中級玩家特徵評估 - 參考 beginner 的邏輯結構
685
+ challenging_traits = {
686
+ 'stubborn': -0.10, # 仍然需要扣分,但比 beginner 輕
687
+ 'independent': -0.08,
688
+ 'dominant': -0.08,
689
+ 'protective': -0.06,
690
+ 'aggressive': -0.12, # 仍然嚴重扣分
691
+ 'nervous': -0.08
692
+ }
693
+
694
+ positive_traits = {
695
+ 'intelligent': 0.06,
696
+ 'trainable': 0.06,
697
+ 'adaptable': 0.05,
698
+ 'calm': 0.04,
699
+ 'friendly': 0.04
700
+ }
701
+
702
+ # 計算特徵調整
703
+ for trait, penalty in challenging_traits.items():
704
  if trait in temperament_lower:
705
+ temperament_adjustments += penalty
706
 
707
+ for trait, bonus in positive_traits.items():
708
+ if trait in temperament_lower:
709
+ if temperament_adjustments + bonus <= 0.12: # 限制正面特徵累積
710
+ temperament_adjustments += bonus
711
+
712
  else: # advanced
713
+ base_scores = {
714
+ "High": {"advanced": 0.75}, # 降低基礎分數
715
+ "Moderate": {"advanced": 0.82},
716
+ "Low": {"advanced": 0.88}
 
 
 
 
 
 
717
  }
718
+ score = base_scores.get(care_level, base_scores["Moderate"])[user_experience]
719
 
720
+ # 即使是進階玩家也需要考慮的風險特徵
721
+ risk_traits = {
722
+ 'aggressive': -0.15, # 最嚴重的風險特徵
723
+ 'nervous': -0.12,
724
+ 'unpredictable': -0.12,
725
+ 'territorial': -0.10,
726
+ 'dominant': -0.08,
727
+ 'strong-willed': -0.06
728
+ }
729
+
730
+ # 進階玩家可以處理的特徵,但仍需謹慎
731
+ manageable_traits = {
732
+ 'intelligent': 0.05,
733
+ 'trainable': 0.04,
734
+ 'independent': 0.03,
735
+ 'protective': 0.02
736
+ }
737
+
738
+ # 先計算風險特徵
739
+ for trait, penalty in risk_traits.items():
740
  if trait in temperament_lower:
741
+ temperament_adjustments += penalty
742
+
743
+ # 再加上可控制特徵,但有限制
744
+ positive_adjustment = 0
745
+ for trait, bonus in manageable_traits.items():
746
+ if trait in temperament_lower:
747
+ positive_adjustment += bonus
748
+ temperament_adjustments += min(0.10, positive_adjustment) # 限制正面特徵的總影響
749
 
750
  # 確保最終分數在合理範圍內
751
  final_score = max(0.2, min(1.0, score + temperament_adjustments))