Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions jumanji/environments/logic/game_2048/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from functools import cached_property
from functools import cached_property, partial
from typing import Optional, Sequence, Tuple

import chex
Expand Down Expand Up @@ -217,16 +217,10 @@ def step(self, state: State, action: chex.Array) -> Tuple[State, TimeStep[Observ
extras = {"highest_tile": highest_tile}
timestep = jax.lax.cond(
done,
lambda: termination(
reward=reward,
observation=observation,
extras=extras,
),
lambda: transition(
reward=reward,
observation=observation,
extras=extras,
),
partial(termination, extras=extras),
partial(transition, extras=extras),
reward,
observation,
)

return state, timestep
Expand Down
16 changes: 5 additions & 11 deletions jumanji/environments/logic/sliding_tile_puzzle/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from functools import cached_property
from functools import cached_property, partial
from typing import Dict, Optional, Sequence, Tuple

import chex
Expand Down Expand Up @@ -144,16 +144,10 @@ def step(self, state: State, action: chex.Array) -> Tuple[State, TimeStep[Observ

timestep = jax.lax.cond(
done | (next_state.step_count >= self.time_limit),
lambda: termination(
reward=reward,
observation=obs,
extras=extras,
),
lambda: transition(
reward=reward,
observation=obs,
extras=extras,
),
partial(termination, extras=extras),
partial(transition, extras=extras),
reward,
obs,
)

return next_state, timestep
Expand Down
16 changes: 5 additions & 11 deletions jumanji/environments/packing/bin_pack/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

import itertools
from functools import cached_property
from functools import cached_property, partial
from typing import Dict, Optional, Sequence, Tuple

import chex
Expand Down Expand Up @@ -334,16 +334,10 @@ def step(self, state: State, action: chex.Array) -> Tuple[State, TimeStep[Observ

timestep = jax.lax.cond(
done,
lambda: termination(
reward=reward,
observation=observation,
extras=extras,
),
lambda: transition(
reward=reward,
observation=observation,
extras=extras,
),
partial(termination, extras=extras),
partial(transition, extras=extras),
reward,
observation,
)

return next_state, timestep
Expand Down
16 changes: 5 additions & 11 deletions jumanji/environments/routing/sokoban/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from functools import cached_property
from functools import cached_property, partial
from typing import Dict, Optional, Sequence, Tuple

import chex
Expand Down Expand Up @@ -243,16 +243,10 @@ def step(self, state: State, action: chex.Array) -> Tuple[State, TimeStep[Observ

timestep = jax.lax.cond(
done,
lambda: termination(
reward=reward,
observation=observation,
extras=extras,
),
lambda: transition(
reward=reward,
observation=observation,
extras=extras,
),
partial(termination, extras=extras),
partial(transition, extras=extras),
reward,
observation,
)

return next_state, timestep
Expand Down
Loading