Repository: ASPP/pelita

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


Discussion:

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