co2114 2026.0.2__py3-none-any.whl → 2026.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- co2114/agent/environment.py +13 -0
- co2114/search/graph.py +19 -5
- {co2114-2026.0.2.dist-info → co2114-2026.1.0.dist-info}/METADATA +1 -1
- {co2114-2026.0.2.dist-info → co2114-2026.1.0.dist-info}/RECORD +7 -7
- {co2114-2026.0.2.dist-info → co2114-2026.1.0.dist-info}/WHEEL +0 -0
- {co2114-2026.0.2.dist-info → co2114-2026.1.0.dist-info}/licenses/LICENSE +0 -0
- {co2114-2026.0.2.dist-info → co2114-2026.1.0.dist-info}/top_level.txt +0 -0
co2114/agent/environment.py
CHANGED
|
@@ -26,10 +26,21 @@ class BaseEnvironment:
|
|
|
26
26
|
""" Base Environment
|
|
27
27
|
Adapted from AIMI code
|
|
28
28
|
"""
|
|
29
|
+
def __init__(self):
|
|
30
|
+
""" Base constructor """
|
|
31
|
+
self.__counter: int = 0
|
|
32
|
+
|
|
29
33
|
def __repr__(self) -> str:
|
|
30
34
|
""" Base string representation """
|
|
31
35
|
return self.__class__.__name__
|
|
32
36
|
|
|
37
|
+
@property
|
|
38
|
+
def counter(self) -> int:
|
|
39
|
+
""" Tracker for number of iterations completed.
|
|
40
|
+
:return counter: Number of iterations in runtime simulation
|
|
41
|
+
"""
|
|
42
|
+
return self.__counter
|
|
43
|
+
|
|
33
44
|
@property
|
|
34
45
|
def is_done(self) -> bool:
|
|
35
46
|
""" Property indicating completion of simulation, needs overriding
|
|
@@ -54,6 +65,7 @@ class BaseEnvironment:
|
|
|
54
65
|
print(f"{self}: Running for {steps} iterations.")
|
|
55
66
|
|
|
56
67
|
for i in range(steps):
|
|
68
|
+
self.__counter += 1
|
|
57
69
|
if self.is_done: # print terination message and exit
|
|
58
70
|
print(f"{self}: Simulation complete after {i} of {steps} iterations.")
|
|
59
71
|
return
|
|
@@ -67,6 +79,7 @@ class Environment(BaseEnvironment):
|
|
|
67
79
|
"""
|
|
68
80
|
def __init__(self):
|
|
69
81
|
""" Initialises set of things and agents """
|
|
82
|
+
super().__init__()
|
|
70
83
|
self.things = set() # all things in environment
|
|
71
84
|
self.agents = set() # all agents in environment
|
|
72
85
|
|
co2114/search/graph.py
CHANGED
|
@@ -18,7 +18,7 @@ Label = str
|
|
|
18
18
|
# Weight = Numeric
|
|
19
19
|
|
|
20
20
|
# Example graph dictionary representing UK cities and distances between them
|
|
21
|
-
UK_CITIES_GRAPH:dict[str, Iterable[str | tuple[str,str] | int]] = {
|
|
21
|
+
UK_CITIES_GRAPH:dict[str, Iterable[str | tuple[str,str] | tuple[Numeric, Numeric] | int]] = {
|
|
22
22
|
"nodes": ["Edinburgh", "Glasgow", "Manchester", "Liverpool",
|
|
23
23
|
"Newcastle", "York", "Sheffield", "Leicester",
|
|
24
24
|
"London", "Bath", "Bristol", "Exeter", "Cardiff", "Birmingham"],
|
|
@@ -32,8 +32,13 @@ UK_CITIES_GRAPH:dict[str, Iterable[str | tuple[str,str] | int]] = {
|
|
|
32
32
|
("Birmingham", "Cardiff"), ("Leicester", "London"),
|
|
33
33
|
("Birmingham", "Leicester"),
|
|
34
34
|
("Birmingham", "London"), ("Birmingham", "Bristol"),
|
|
35
|
-
("London", "Bristol"), ("Cardiff", "Bristol")],
|
|
36
|
-
"weights": [2,4,1,1,4,1,1,2,1,3,3,2,1,2,5,1,2,2,3,2,1]
|
|
35
|
+
("London", "Bristol"), ("Cardiff", "Bristol"), ("Bristol", "Bath"), ("Exeter", "Bristol"), ("Exeter", "London")],
|
|
36
|
+
"weights": [2,4,1,1,4,1,1,2,1,3,3,2,1,2,5,1,2,2,3,2,1,1,2,5],
|
|
37
|
+
"locations": [(55.9533, -3.1883), (55.8617, -4.2583), (53.4808, -2.2426),
|
|
38
|
+
(53.4084, -2.9916), (54.9783, -1.6178), (53.9614, -1.0739),
|
|
39
|
+
(53.3811, -1.4701), (52.6369, -1.1398), (51.5072, -0.1276),
|
|
40
|
+
(51.3781, -2.3597), (51.4545, -2.5879), (50.7260, -3.5275),
|
|
41
|
+
(51.4837, -3.1681), (52.4823, -1.8900)]
|
|
37
42
|
}
|
|
38
43
|
|
|
39
44
|
|
|
@@ -188,13 +193,16 @@ class GraphEnvironment(Environment):
|
|
|
188
193
|
super().__init__(*args, **kwargs) # initialize base Environment
|
|
189
194
|
self.graph = graph if isinstance(graph, Graph) else Graph()
|
|
190
195
|
|
|
191
|
-
|
|
192
|
-
def add_node(self, node:Node) -> None:
|
|
196
|
+
|
|
197
|
+
def add_node(self, node:Node, location:None | tuple = None) -> None:
|
|
193
198
|
""" Add a node to the graph environment.
|
|
194
199
|
|
|
195
200
|
:param node: Node to be added to the graph.
|
|
201
|
+
:param location: Optional location information of node, default None
|
|
196
202
|
"""
|
|
197
203
|
self.graph.add_node(node)
|
|
204
|
+
if location is not None:
|
|
205
|
+
node.location = location
|
|
198
206
|
|
|
199
207
|
|
|
200
208
|
@override
|
|
@@ -286,6 +294,12 @@ class GraphEnvironment(Environment):
|
|
|
286
294
|
a, b = edge # type: ignore
|
|
287
295
|
nodes[a].add_neighbour(nodes[b], weight) # add edge with weight
|
|
288
296
|
|
|
297
|
+
if 'locations' in graph_dict:
|
|
298
|
+
locations = graph_dict['locations']
|
|
299
|
+
else:
|
|
300
|
+
locations = [(0,0)]*len(nodes)
|
|
301
|
+
for key, location in zip(nodes, locations):
|
|
302
|
+
nodes[key].location = location # type: ignore
|
|
289
303
|
|
|
290
304
|
# create environment and add nodes
|
|
291
305
|
environment = cls()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
co2114/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
co2114/engine.py,sha256=zN_jNil7xN52K9yJMTmEPARrL53kKwb_zg1BM6Cl6Jw,7043
|
|
3
3
|
co2114/agent/__init__.py,sha256=4dQXJw6n6SJk3YDVtuRYuZjZvOIFfk6BkXfBA6UXLZg,34
|
|
4
|
-
co2114/agent/environment.py,sha256=
|
|
4
|
+
co2114/agent/environment.py,sha256=f5m_xBd3AFK2gT1iFQBj52yWXibLSy4Tx4el5eN_aRM,18736
|
|
5
5
|
co2114/agent/things.py,sha256=UUzwozCwmvqMIPSI9V3Fx-FmcCGiybxRhM6Mb1TqZcs,2278
|
|
6
6
|
co2114/constraints/__init__.py,sha256=yDE8UZkEPk26YZRiBt-Rv3tZSfkoWo7T5zs2aTklyec,36
|
|
7
7
|
co2114/constraints/magic.py,sha256=63iueMhdZyxImTkJ7lAMPalnun0ZeG3XrpSY2vzLLmM,3225
|
|
@@ -17,15 +17,15 @@ co2114/reasoning/cluedo.py,sha256=rMqrI_BDDiO0fWgOkhFuOOcB4dCl3Pf9OZEsmJ8safs,14
|
|
|
17
17
|
co2114/reasoning/inference.py,sha256=j5NGkxdKS3jacBJUVxOnwquMY9Pm4nEt5JkxeyBV2CE,4625
|
|
18
18
|
co2114/reasoning/logic.py,sha256=tQ5gLsczU_j9ATanA7uHHLdfxmW--VUO7u-78LJAgmY,10531
|
|
19
19
|
co2114/search/__init__.py,sha256=UxLSQsWU2Q8WKBXb7cAqhR-NFRMf3_t7XPIO7oOGB8Y,45
|
|
20
|
-
co2114/search/graph.py,sha256=
|
|
20
|
+
co2114/search/graph.py,sha256=H3EM8tNWxejr0sD3c1qwpWcataHyl3jShvftWIGq0sw,18166
|
|
21
21
|
co2114/search/maze.py,sha256=yveUVwQNtV3v8EGlAilSepZKgVbcd2bYt3GcATqrOVA,9947
|
|
22
22
|
co2114/search/things.py,sha256=hdWq_2uTM1X603-QOcr5QEyo1CeEWbnOhILem0yd-Fg,1783
|
|
23
23
|
co2114/search/util.py,sha256=J2SHFn7NuSMIbepjnI6PkkOt03f9qxi50Pw5rnA42IU,532
|
|
24
24
|
co2114/util/__init__.py,sha256=5FC5sdGxQjrXI_tXBohVs2Vrsi-rP0sEz-ReGgf0tYw,1429
|
|
25
25
|
co2114/util/colours.py,sha256=ipS3jGhiomhyRdQcdGhywIhxRBRbBIx6QboqPcL3GMs,757
|
|
26
26
|
co2114/util/fonts.py,sha256=iL9al4B3F_w7EMG2lw7iLU4jA3uSqenMYY4zjhojtRk,504
|
|
27
|
-
co2114-2026.0.
|
|
28
|
-
co2114-2026.0.
|
|
29
|
-
co2114-2026.0.
|
|
30
|
-
co2114-2026.0.
|
|
31
|
-
co2114-2026.0.
|
|
27
|
+
co2114-2026.1.0.dist-info/licenses/LICENSE,sha256=9KBazlyiIjZEG_wmBd9vkJZ0K0G7lsEX874rHL89FVs,1090
|
|
28
|
+
co2114-2026.1.0.dist-info/METADATA,sha256=Xnq8VgTU1Zh66n9W6GVLKJ8eWxmzqdson27uR5dipIg,438
|
|
29
|
+
co2114-2026.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
30
|
+
co2114-2026.1.0.dist-info/top_level.txt,sha256=IrtPs7QmoV3CNxGgxSDrfx8VUgDdkbMaO6uVmutU9kg,7
|
|
31
|
+
co2114-2026.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|