continual-foragax 0.24.1__py3-none-any.whl → 0.25.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.
- {continual_foragax-0.24.1.dist-info → continual_foragax-0.25.0.dist-info}/METADATA +1 -1
- {continual_foragax-0.24.1.dist-info → continual_foragax-0.25.0.dist-info}/RECORD +7 -7
- foragax/env.py +34 -3
- foragax/registry.py +19 -2
- {continual_foragax-0.24.1.dist-info → continual_foragax-0.25.0.dist-info}/WHEEL +0 -0
- {continual_foragax-0.24.1.dist-info → continual_foragax-0.25.0.dist-info}/entry_points.txt +0 -0
- {continual_foragax-0.24.1.dist-info → continual_foragax-0.25.0.dist-info}/top_level.txt +0 -0
@@ -1,8 +1,8 @@
|
|
1
1
|
foragax/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
foragax/colors.py,sha256=rqNPiywP4Nvr0POhsGpasRk-nMMTS3DOwFRUgperlUk,2065
|
3
|
-
foragax/env.py,sha256=
|
3
|
+
foragax/env.py,sha256=w9KDLRm0xvJjnRP0C4gynk1At6LVdrz5xBEtDC3ePvM,24958
|
4
4
|
foragax/objects.py,sha256=CblI0NI7PQzeKk3MZa8sbaa9wB4pc_8CyOGbJOFWytE,9391
|
5
|
-
foragax/registry.py,sha256=
|
5
|
+
foragax/registry.py,sha256=ExsKKatqsQBpEpgE-xUCFOHxuXoBVysJk5eR1OoI7kw,13456
|
6
6
|
foragax/rendering.py,sha256=bms7wvBZTofoR-K-2QD2Ggeed7Viw8uwAEiEpEM3eSo,2768
|
7
7
|
foragax/weather.py,sha256=KNAiwuFz8V__6G75vZIWQKPocLzXqxXn-Vt4TbHIpcA,1258
|
8
8
|
foragax/data/ECA_non-blended_custom/TG_SOUID100897.txt,sha256=N7URbX6VlCZvCboUogYjMzy1I-0cfNPOn0QTLSHHfQ0,1776751
|
@@ -128,8 +128,8 @@ foragax/data/ECA_non-blended_custom/TG_SOUID156887.txt,sha256=juzTPgJoJxfqmZkorL
|
|
128
128
|
foragax/data/ECA_non-blended_custom/elements.txt,sha256=OtcUBoDAHxuln79BPKGu0tsQxG_5G2BfAX3Ck130kEA,4507
|
129
129
|
foragax/data/ECA_non-blended_custom/metadata.txt,sha256=nudnmOCy5cPJfSXt_IjyX0S5-T7NkCZREICZSimqeqc,48260
|
130
130
|
foragax/data/ECA_non-blended_custom/sources.txt,sha256=1j3lSmINAoCMqPqFrHfZJriOz6sTYZNOhXzUwvTLas0,20857
|
131
|
-
continual_foragax-0.
|
132
|
-
continual_foragax-0.
|
133
|
-
continual_foragax-0.
|
134
|
-
continual_foragax-0.
|
135
|
-
continual_foragax-0.
|
131
|
+
continual_foragax-0.25.0.dist-info/METADATA,sha256=GXiKdIYRxCL0MgjTkPK1xWa-3bNh2rBvloPEnict1Rc,4897
|
132
|
+
continual_foragax-0.25.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
133
|
+
continual_foragax-0.25.0.dist-info/entry_points.txt,sha256=Qiu6iE_XudrDO_bVAMeA435h4PO9ourt8huvSHiuMPc,41
|
134
|
+
continual_foragax-0.25.0.dist-info/top_level.txt,sha256=-z3SDK6RfLIcLI24n8rdbeFzlVY3hunChzlu-v1Fncs,8
|
135
|
+
continual_foragax-0.25.0.dist-info/RECORD,,
|
foragax/env.py
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
"""JAX implementation of
|
1
|
+
"""JAX implementation of Forager environment.
|
2
2
|
|
3
|
-
Source: https://github.com/andnp/
|
3
|
+
Source: https://github.com/andnp/Forager
|
4
4
|
"""
|
5
5
|
|
6
6
|
from dataclasses import dataclass
|
7
7
|
from enum import IntEnum
|
8
8
|
from functools import partial
|
9
|
-
from typing import Any, Dict, Tuple, Union
|
9
|
+
from typing import Any, Dict, Optional, Tuple, Union
|
10
10
|
|
11
11
|
import jax
|
12
12
|
import jax.numpy as jnp
|
@@ -75,6 +75,7 @@ class ForagaxEnv(environment.Environment):
|
|
75
75
|
biomes: Tuple[Biome, ...] = (Biome(object_frequencies=()),),
|
76
76
|
nowrap: bool = False,
|
77
77
|
deterministic_spawn: bool = False,
|
78
|
+
teleport_interval: Optional[int] = None,
|
78
79
|
):
|
79
80
|
super().__init__()
|
80
81
|
self._name = name
|
@@ -87,6 +88,7 @@ class ForagaxEnv(environment.Environment):
|
|
87
88
|
self.aperture_size = aperture_size
|
88
89
|
self.nowrap = nowrap
|
89
90
|
self.deterministic_spawn = deterministic_spawn
|
91
|
+
self.teleport_interval = teleport_interval
|
90
92
|
objects = (EMPTY,) + objects
|
91
93
|
if self.nowrap:
|
92
94
|
objects = objects + (PADDING,)
|
@@ -117,6 +119,16 @@ class ForagaxEnv(environment.Environment):
|
|
117
119
|
[b.stop if b.stop is not None else (-1, -1) for b in biomes]
|
118
120
|
)
|
119
121
|
self.biome_sizes = np.prod(self.biome_stops - self.biome_starts, axis=1)
|
122
|
+
self.biome_starts_jax = jnp.array(self.biome_starts)
|
123
|
+
self.biome_stops_jax = jnp.array(self.biome_stops)
|
124
|
+
biome_centers = []
|
125
|
+
for i in range(len(self.biome_starts)):
|
126
|
+
start = self.biome_starts[i]
|
127
|
+
stop = self.biome_stops[i]
|
128
|
+
center_x = (start[0] + stop[0] - 1) // 2
|
129
|
+
center_y = (start[1] + stop[1] - 1) // 2
|
130
|
+
biome_centers.append((center_x, center_y))
|
131
|
+
self.biome_centers_jax = jnp.array(biome_centers)
|
120
132
|
self.biome_masks = []
|
121
133
|
for i in range(self.biome_object_frequencies.shape[0]):
|
122
134
|
# Create mask for the biome
|
@@ -174,6 +186,23 @@ class ForagaxEnv(environment.Environment):
|
|
174
186
|
is_blocking = self.object_blocking[obj_at_new_pos]
|
175
187
|
pos = jax.lax.select(is_blocking, state.pos, new_pos)
|
176
188
|
|
189
|
+
# Check for automatic teleport
|
190
|
+
if self.teleport_interval is not None:
|
191
|
+
should_teleport = jnp.mod(state.time + 1, self.teleport_interval) == 0
|
192
|
+
else:
|
193
|
+
should_teleport = False
|
194
|
+
|
195
|
+
def teleport_fn():
|
196
|
+
# Calculate squared distances from current position to each biome center
|
197
|
+
diffs = self.biome_centers_jax - pos
|
198
|
+
distances = jnp.sum(diffs**2, axis=1)
|
199
|
+
# Find the index of the furthest biome center
|
200
|
+
furthest_idx = jnp.argmax(distances)
|
201
|
+
new_pos = self.biome_centers_jax[furthest_idx]
|
202
|
+
return new_pos
|
203
|
+
|
204
|
+
pos = jax.lax.cond(should_teleport, teleport_fn, lambda: pos)
|
205
|
+
|
177
206
|
# 2. HANDLE COLLISIONS AND REWARDS
|
178
207
|
obj_at_pos = current_objects[pos[1], pos[0]]
|
179
208
|
key, subkey = jax.random.split(key)
|
@@ -503,6 +532,7 @@ class ForagaxObjectEnv(ForagaxEnv):
|
|
503
532
|
biomes: Tuple[Biome, ...] = (Biome(object_frequencies=()),),
|
504
533
|
nowrap: bool = False,
|
505
534
|
deterministic_spawn: bool = False,
|
535
|
+
teleport_interval: Optional[int] = None,
|
506
536
|
):
|
507
537
|
super().__init__(
|
508
538
|
name,
|
@@ -512,6 +542,7 @@ class ForagaxObjectEnv(ForagaxEnv):
|
|
512
542
|
biomes,
|
513
543
|
nowrap,
|
514
544
|
deterministic_spawn,
|
545
|
+
teleport_interval,
|
515
546
|
)
|
516
547
|
|
517
548
|
# Compute unique colors and mapping for partial observability
|
foragax/registry.py
CHANGED
@@ -220,7 +220,7 @@ ENV_CONFIGS: Dict[str, Dict[str, Any]] = {
|
|
220
220
|
"deterministic_spawn": True,
|
221
221
|
},
|
222
222
|
"ForagaxTwoBiome-v13": {
|
223
|
-
"size":
|
223
|
+
"size": (15, 15),
|
224
224
|
"aperture_size": None,
|
225
225
|
"objects": (
|
226
226
|
BROWN_MOREL_UNIFORM_RANDOM,
|
@@ -240,7 +240,7 @@ ENV_CONFIGS: Dict[str, Dict[str, Any]] = {
|
|
240
240
|
"deterministic_spawn": True,
|
241
241
|
},
|
242
242
|
"ForagaxTwoBiome-v14": {
|
243
|
-
"size":
|
243
|
+
"size": (15, 15),
|
244
244
|
"aperture_size": None,
|
245
245
|
"objects": (
|
246
246
|
BROWN_MOREL_UNIFORM,
|
@@ -272,6 +272,19 @@ ENV_CONFIGS: Dict[str, Dict[str, Any]] = {
|
|
272
272
|
"nowrap": True,
|
273
273
|
"deterministic_spawn": True,
|
274
274
|
},
|
275
|
+
"ForagaxTwoBiome-v16": {
|
276
|
+
"size": None,
|
277
|
+
"aperture_size": None,
|
278
|
+
"objects": (
|
279
|
+
BROWN_MOREL_UNIFORM_RANDOM,
|
280
|
+
BROWN_OYSTER_UNIFORM_RANDOM,
|
281
|
+
GREEN_DEATHCAP_UNIFORM_RANDOM,
|
282
|
+
GREEN_FAKE_UNIFORM_RANDOM,
|
283
|
+
),
|
284
|
+
"biomes": None,
|
285
|
+
"nowrap": True,
|
286
|
+
"deterministic_spawn": True,
|
287
|
+
},
|
275
288
|
"ForagaxTwoBiomeSmall-v1": {
|
276
289
|
"size": (16, 8),
|
277
290
|
"aperture_size": None,
|
@@ -348,6 +361,7 @@ def make(
|
|
348
361
|
"ForagaxTwoBiome-v9",
|
349
362
|
"ForagaxTwoBiome-v10",
|
350
363
|
"ForagaxTwoBiome-v15",
|
364
|
+
"ForagaxTwoBiome-v16",
|
351
365
|
):
|
352
366
|
margin = aperture_size[1] // 2 + 1
|
353
367
|
width = 2 * margin + 9
|
@@ -410,6 +424,9 @@ def make(
|
|
410
424
|
hot, cold = create_weather_objects(file_index=file_index, same_color=same_color)
|
411
425
|
config["objects"] = (hot, cold)
|
412
426
|
|
427
|
+
if env_id == "ForagaxTwoBiome-v16":
|
428
|
+
config["teleport_interval"] = 10000
|
429
|
+
|
413
430
|
env_class_map = {
|
414
431
|
"object": ForagaxObjectEnv,
|
415
432
|
"rgb": ForagaxRGBEnv,
|
File without changes
|
File without changes
|
File without changes
|