nebius/SWE-bench-extra huggingface dataset:
Repository: ASPP/pelita

Issue:
Give a warning, when a layout without food is defined?

Comments:

Patch:
diff --git a/pelita/game_master.py b/pelita/game_master.py
index 42490344..e73049f5 100644
--- a/pelita/game_master.py
+++ b/pelita/game_master.py
@@ -4,6 +4,7 @@ import abc
 import random
 import sys
 import time
+from warnings import warn
 
 from . import datamodel
 from .datamodel import Bot, CTFUniverse
@@ -19,6 +20,10 @@ class PlayerTimeout(Exception):
 class PlayerDisconnected(Exception):
     pass
 
+class NoFoodWarning(Warning):
+    """ Warning about a layout with no food. """
+    pass
+
 class GameMaster:
     """ Controller of player moves and universe updates.
 
@@ -158,6 +163,12 @@ class GameMaster:
             "noise_sight_distance": self.noiser and self.noiser.sight_distance
         }
 
+        # Check that both teams have food, and raise a warning otherwise
+        for (team_id, food_count) in enumerate(self.game_state["food_to_eat"]):
+            if food_count == 0:
+                warn("Layout contains no food for team {}.".format(team_id),
+                     NoFoodWarning)
+
     @property
     def game_time(self):
         return self.game_state["game_time"]


Test patch:
diff --git a/test/test_game_master.py b/test/test_game_master.py
index e943d70b..69277e31 100644
--- a/test/test_game_master.py
+++ b/test/test_game_master.py
@@ -4,7 +4,7 @@ import unittest
 import collections
 
 from pelita.datamodel import CTFUniverse
-from pelita.game_master import GameMaster, ManhattanNoiser, PlayerTimeout
+from pelita.game_master import GameMaster, ManhattanNoiser, PlayerTimeout, NoFoodWarning
 from pelita.player import AbstractPlayer, SimpleTeam, StoppingPlayer, SteppingPlayer
 from pelita.viewer import AbstractViewer
 
@@ -83,6 +83,26 @@ class TestGameMaster:
         with pytest.raises(ValueError):
             GameMaster(test_layout_4, [team_1, team_2, team_3], 4, 200)
 
+    def test_no_food(self):
+        team_1 = SimpleTeam(SteppingPlayer([]), SteppingPlayer([]))
+        team_2 = SimpleTeam(SteppingPlayer([]), SteppingPlayer([]))
+
+        both_starving_layout = (
+            """ ######
+                #0   #
+                #   1#
+                ###### """)
+        with pytest.warns(NoFoodWarning):
+            GameMaster(both_starving_layout, [team_1, team_2], 2, 1)
+
+        one_side_starving_layout = (
+            """ ######
+                #0  .#
+                #   1#
+                ###### """)
+        with pytest.warns(NoFoodWarning):
+            GameMaster(one_side_starving_layout, [team_1, team_2], 2, 1)
+
 class TestUniverseNoiser:
     def test_uniform_noise_manhattan(self):
         test_layout = (
@@ -106,7 +126,7 @@ class TestUniverseNoiser:
                      (4, 3), (5, 3), (6, 3), (7, 3), (7, 2),
                      (6, 1), (5, 1), (4, 1), (3, 1) ]
         unittest.TestCase().assertCountEqual(position_bucket, expected, position_bucket)
-    
+
 
     def test_uniform_noise_4_bots_manhattan(self):
         test_layout = (
Repository: ASPP/pelita

Issue:
layout_agnostic needs tests and fixes
Currently broken. https://github.com/ASPP/pelita/blob/2f17db5355b4dffae8a130ede549ab869b2f1ce2/pelita/layout.py#L548-L566


Comments:

Patch:
diff --git a/pelita/layout.py b/pelita/layout.py
index e5797adc..66fa2ebd 100644
--- a/pelita/layout.py
+++ b/pelita/layout.py
@@ -545,9 +545,9 @@ def layout_for_team(layout, is_blue=True, is_noisy=(False, False)):
         'is_noisy' : is_noisy,
     }
 
-def layout_agnostic(layout_for_team, is_blue=True):
-    """ Converts a layout dict with 2 bots and enemies to a layout
-    with 4 bots.
+def layout_agnostic(layout, is_blue=True):
+    """ Converts a layout dict with 2 bots and enemies (team-style)
+    to a layout with 4 bots (server-style).
     """
     if "enemy" not in layout:
         raise ValueError("Layout is already in server-style.")


Test patch:
diff --git a/test/test_layout.py b/test/test_layout.py
index ff30905a..4d3d8638 100644
--- a/test/test_layout.py
+++ b/test/test_layout.py
@@ -454,3 +454,38 @@ def test_layout_for_team():
 
     with pytest.raises(ValueError):
         layout_for_team(parse_layout(red1))
+
+def test_layout_agnostic():
+    """
+    Test if team-style layout can be converted to server-style layout.
+    
+    Uses this layout:
+
+    ####
+    #01#
+    #EE#
+    #..#
+    ####
+    """
+
+    l = {
+        'walls': [(0,0),(0,1),(0,2),(0,3),(1,0),(1,3),(2,0),(2,3),(3,0),(3,3),(4,0),(4,1),(4,2),(4,3)],
+        'food': [(3,1),(3,2)],
+        'bots': [(1,1),(1,2)],
+        'enemy': [(2,1),(2,2)]
+        }
+
+
+    l_expected_blue = {
+        'walls': [(0,0),(0,1),(0,2),(0,3),(1,0),(1,3),(2,0),(2,3),(3,0),(3,3),(4,0),(4,1),(4,2),(4,3)],
+        'food': [(3,1),(3,2)],
+        'bots': [(1,1),(2,1),(1,2),(2,2)]
+        }
+    l_expected_red = {
+        'walls': [(0,0),(0,1),(0,2),(0,3),(1,0),(1,3),(2,0),(2,3),(3,0),(3,3),(4,0),(4,1),(4,2),(4,3)],
+        'food': [(3,1),(3,2)],
+        'bots': [(2,1),(1,1),(2,2),(1,2)]
+        }
+
+    assert layout_agnostic(l, is_blue=True) == l_expected_blue
+    assert layout_agnostic(l, is_blue=False) == l_expected_red