summaryrefslogtreecommitdiff
path: root/robots/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'robots/utils.py')
-rw-r--r--robots/utils.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/robots/utils.py b/robots/utils.py
index e269a02..5793a00 100644
--- a/robots/utils.py
+++ b/robots/utils.py
@@ -10,6 +10,19 @@ def ceil_div(a, b):
def ilen(items):
return sum(1 for _ in items)
+def immutable(value):
+ if isinstance(value, str):
+ return value
+ try:
+ return immutable(list(sorted(value.items())))
+ except AttributeError:
+ pass
+ try:
+ return tuple(immutable(v) for v in value)
+ except TypeError:
+ pass
+ return value
+
def add_spawns(map_, n_spawns, city=None):
available = []
for x, y, cell in iter_board(map_):