From f8b5947186e40c25a26aa0f9f824ac856279edf4 Mon Sep 17 00:00:00 2001
From: mmorge <maxime.morge@univ-lyon1.fr>
Date: Wed, 4 Jun 2025 16:16:23 +0200
Subject: [PATCH] PyGAAMAS: Strategies generated by models fo MP

---
 src/mp/mp.py | 39 ++++++++++++++++++++++++++++-----------
 1 file changed, 28 insertions(+), 11 deletions(-)

diff --git a/src/mp/mp.py b/src/mp/mp.py
index abc4153..87c6d59 100644
--- a/src/mp/mp.py
+++ b/src/mp/mp.py
@@ -203,15 +203,8 @@ class MP:
         """Play the next move using a heuristic."""
         prediction = ""
         print(self.model)
-
         if self.model == "gpt-4.5-preview-2025-02-27":
-            """
-            Play the next move using a heuristic.
-            - Simple strategy: Alternate between "Head" and "Tail".
-            - Prediction: Assume opponent is also alternating.
-            """
             moves = ["Head", "Tail"]
-
             # If no rounds played, start with "Head"
             if not self.history:
                 move = "Head"
@@ -221,20 +214,16 @@ class MP:
                         + (f"Predicting opponent starts with 'Tail' (alternating)." if self.prediction else "")
                 )
                 return move, prediction, reasoning
-
             # Get last move you played and the opponent's last move
             last_agent_move = self.history[-1]["Agent Move"]
             last_opponent_move = self.history[-1]["Opponent Move"]
-
             # Alternate your move from last time
             move = "Tail" if last_agent_move == "Head" else "Head"
-
             # Prediction: Suppose opponent is also alternating
             if self.prediction:
                 prediction = "Tail" if last_opponent_move == "Head" else "Head"
             else:
                 prediction = "None"
-
             reasoning = (
                     f"Last round I played {last_agent_move}, opponent played {last_opponent_move}. "
                     f"I'm alternating my move to '{move}'. "
@@ -244,6 +233,34 @@ class MP:
                     )
             )
             return move, prediction, reasoning
+        if self.model == "mistral-small":
+            if not self.history:
+                # If there is no history yet, play randomly.
+                moves = ["Head", "Tail"]
+                return random.choice(moves), f"First round, choosing {random.choice(moves)}."
+            head_count = 0
+            tail_count = 0
+            for move in [r['Opponent Move'] for r in self.history]:
+                if move == 'Head':
+                    head_count += 1
+                elif move == 'Tail':
+                    tail_count += 1
+            # If there are more heads, play Tail and vice versa.
+            if head_count > tail_count:
+                next_move = "Tail"
+            elif tail_count > head_count:
+                next_move = "Head"
+            else:  # Equal counts
+                moves = ["Head", "Tail"]
+                next_move = random.choice(moves)
+            reasoning = f"Opponent's 'Head' count: {head_count}, 'Tail' count: {tail_count}. Chose to play '{next_move}' based on the opponent's move frequency."
+            return next_move, "None", reasoning
+        if self.model == "qwen3":
+            move = random.choice(["Head", "Tail"])
+            prediction = move  # Assume the opponent will match our move
+            reasoning = f"Choosing randomly. Assuming the opponent will match my move {move}."
+            return move, prediction, reasoning
+        return "None", "None", "None"
 
         else:
             opponent_move = self.opponent_strategy_fn(self.history)
-- 
GitLab