mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-05-23 07:16:44 +02:00
added regex search for bound entitiy search
This commit is contained in:
parent
00391d2bec
commit
ea6634b187
@ -239,7 +239,7 @@ def add_bound_name(name_str, bound_e):
|
|||||||
|
|
||||||
|
|
||||||
def add_pos_name(name_str, bound_e):
|
def add_pos_name(name_str, bound_e):
|
||||||
if bound_e.var_has_pos:
|
if bound_e.var_has_position:
|
||||||
return f'{name_str}({bound_e.pos})'
|
return f'{name_str}({bound_e.pos})'
|
||||||
return name_str
|
return name_str
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import math
|
import math
|
||||||
|
import re
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from itertools import product
|
from itertools import product
|
||||||
from typing import Dict, List
|
from typing import Dict, List
|
||||||
@ -120,10 +121,13 @@ class OBSBuilder(object):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
try:
|
try:
|
||||||
# Look for bound entity names!
|
# Look for bound entity names!
|
||||||
e = self.all_obs[h.add_bound_name(l_name, agent)]
|
pattern = re.compile(f'{re.escape(l_name)}(.*){re.escape(agent.name)}')
|
||||||
|
print(pattern)
|
||||||
|
name = next((x for x in self.all_obs if pattern.search(x)), None)
|
||||||
|
e = self.all_obs[name]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
try:
|
try:
|
||||||
e = next(x for x in self.all_obs if l_name in x and agent.name in x)
|
e = next(v for k in self.all_obs.items() if l_name in k and agent.name in k)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
raise KeyError(
|
raise KeyError(
|
||||||
f'Check for spelling errors! \n '
|
f'Check for spelling errors! \n '
|
||||||
@ -146,8 +150,6 @@ class OBSBuilder(object):
|
|||||||
try:
|
try:
|
||||||
v = e.encoding
|
v = e.encoding
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
print(e)
|
|
||||||
print(e.var_has_position)
|
|
||||||
raise AttributeError(f'This env. expects Entity-Clases to report their "encoding"')
|
raise AttributeError(f'This env. expects Entity-Clases to report their "encoding"')
|
||||||
try:
|
try:
|
||||||
np.put(obs[idx], range(len(v)), v, mode='raise')
|
np.put(obs[idx], range(len(v)), v, mode='raise')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user