Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
0c4db6a
initial commit using pong as template
BastiJilge Nov 6, 2025
16b723b
rough design of potential car movements
BastiJilge Nov 7, 2025
e657459
added basic interface template
shaik05 Nov 13, 2025
8df941a
add partial backrounds and car sprites
BastiJilge Nov 13, 2025
03be31f
create first running version doing nothing
BastiJilge Nov 14, 2025
eaa29de
use black backround and top and bottom wall sprites
BastiJilge Nov 16, 2025
e70d913
add first movment of player and map to game
BastiJilge Nov 16, 2025
2b9ea9f
add new parts of the map
BastiJilge Nov 16, 2025
958e021
changes to player movement and road selection
BastiJilge Nov 23, 2025
d4353cd
add logic for different speeds
BastiJilge Nov 29, 2025
d92272a
car now follows road with loop
BastiJilge Dec 2, 2025
8ddc028
remove offset, add moving backwards
BastiJilge Dec 2, 2025
1c1ce94
add second road
BastiJilge Dec 5, 2025
70226a2
add collectibles to the game
BastiJilge Dec 13, 2025
0cec9fb
add score and display and passive point gain
BastiJilge Dec 17, 2025
305b5a5
a
shaik05 Dec 21, 2025
55dd441
movement
shaik05 Dec 21, 2025
ba94abf
add enemy cars & enemy logic to game
BastiJilge Dec 18, 2025
f002190
add jumping, crossing roads to game
BastiJilge Dec 20, 2025
53e30a5
add missing live counter to game
BastiJilge Dec 20, 2025
c8ab54f
cleanup code
BastiJilge Dec 20, 2025
735e152
modified respawn
shaik05 Dec 21, 2025
a77c31c
Allow backward jumping and remove steep road mechanics in UpNDown
shaik05 Mar 6, 2026
369b19f
improve code quality
BastiJilge Dec 21, 2025
aa66641
improve enemy spawning
BastiJilge Dec 21, 2025
e5e3bc1
improve jumping on enemys
BastiJilge Dec 21, 2025
11433f4
reuse movement logic for enemys
BastiJilge Dec 21, 2025
af3ceab
reworked behaivor on step sections
BastiJilge Dec 21, 2025
1a0e4a8
move RNG key up and make functions jittable
BastiJilge Dec 21, 2025
e03013f
add confirmation logic to start a new round
BastiJilge Dec 21, 2025
867c805
fix observation logic for tests
BastiJilge Dec 21, 2025
4185e31
try to implement some of the feedback
BastiJilge Jan 31, 2026
3718ff1
add initial mod implementation
BastiJilge Mar 5, 2026
bb71eff
Allow backward jumping and remove steep road
shaik05 Mar 6, 2026
9a985bc
Revert "Allow backward jumping and remove steep road"
BastiJilge Mar 21, 2026
7e1c884
revert the in main game mod implementations
BastiJilge Mar 21, 2026
d767f4d
moved mod plugin file to new folder
BastiJilge Mar 21, 2026
e36af2a
initial commit using pong as template
BastiJilge Nov 6, 2025
38a3427
rough design of potential car movements
BastiJilge Nov 7, 2025
35a7dbc
added basic interface template
shaik05 Nov 13, 2025
9eb102d
add partial backrounds and car sprites
BastiJilge Nov 13, 2025
75efded
create first running version doing nothing
BastiJilge Nov 14, 2025
1656854
use black backround and top and bottom wall sprites
BastiJilge Nov 16, 2025
33414c8
add first movment of player and map to game
BastiJilge Nov 16, 2025
4aee843
add new parts of the map
BastiJilge Nov 16, 2025
5db04ae
changes to player movement and road selection
BastiJilge Nov 23, 2025
11dfddc
add logic for different speeds
BastiJilge Nov 29, 2025
927648d
car now follows road with loop
BastiJilge Dec 2, 2025
e74be01
remove offset, add moving backwards
BastiJilge Dec 2, 2025
2ee59e5
add second road
BastiJilge Dec 5, 2025
729185d
add collectibles to the game
BastiJilge Dec 13, 2025
301b96e
add score and display and passive point gain
BastiJilge Dec 17, 2025
5c792c9
a
shaik05 Dec 21, 2025
3f018d4
movement
shaik05 Dec 21, 2025
7053aeb
add enemy cars & enemy logic to game
BastiJilge Dec 18, 2025
c22cd68
add jumping, crossing roads to game
BastiJilge Dec 20, 2025
2cd73b0
add missing live counter to game
BastiJilge Dec 20, 2025
5afcd7f
cleanup code
BastiJilge Dec 20, 2025
c82b80e
modified respawn
shaik05 Dec 21, 2025
e49e74c
Allow backward jumping and remove steep road mechanics in UpNDown
shaik05 Mar 6, 2026
4780ff4
improve code quality
BastiJilge Dec 21, 2025
2fcf3de
improve enemy spawning
BastiJilge Dec 21, 2025
035d9a9
improve jumping on enemys
BastiJilge Dec 21, 2025
523b1d7
reuse movement logic for enemys
BastiJilge Dec 21, 2025
5b84dab
reworked behaivor on step sections
BastiJilge Dec 21, 2025
29936f9
move RNG key up and make functions jittable
BastiJilge Dec 21, 2025
835b362
add confirmation logic to start a new round
BastiJilge Dec 21, 2025
7add44e
fix observation logic for tests
BastiJilge Dec 21, 2025
a962b54
try to implement some of the feedback
BastiJilge Jan 31, 2026
2916b04
add initial mod implementation
BastiJilge Mar 5, 2026
68443a2
Allow backward jumping and remove steep road
shaik05 Mar 6, 2026
3e54604
go back to last running version
BastiJilge Mar 21, 2026
18cbb4d
fix some failing pipeline tests
BastiJilge Mar 22, 2026
89c68a3
add level 2 and 3
BastiJilge Mar 23, 2026
1fea134
small fix for training with mods
BastiJilge Mar 25, 2026
caa0fc7
fixes to improve training
BastiJilge Mar 28, 2026
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
2,954 changes: 2,954 additions & 0 deletions src/jaxatari/games/jax_upndown.py

Large diffs are not rendered by default.

83 changes: 83 additions & 0 deletions src/jaxatari/games/mods/upndown/upndown_mod_plugins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
from functools import partial
import chex
import jax
import jax.numpy as jnp

from jaxatari.games.jax_upndown import UpNDownState
from jaxatari.modification import JaxAtariInternalModPlugin


class RemoveStepRoadsMod(JaxAtariInternalModPlugin):
@partial(jax.jit, static_argnums=(0,))
def _is_steep_road_segment(
self,
current_road: chex.Array,
road_index_A: chex.Array,
road_index_B: chex.Array,
level: chex.Array,
) -> chex.Array:
return jnp.array(False)


class HigherPlayerSpeedMod(JaxAtariInternalModPlugin):
constants_overrides = {
"MAX_SPEED": 9,
}


class MoreCollectiblesMod(JaxAtariInternalModPlugin):
constants_overrides = {
"MAX_ACTIVE_COLLECTIBLES": 4,
"COLLECTIBLE_SPAWN_INTERVAL": 120,
}


class MinCarSpawnGapMod(JaxAtariInternalModPlugin):
conflicts_with = ["progressive_car_spawn_rate"]
constants_overrides = {
"ENEMY_SPAWN_INTERVAL_BASE": 50,
}


class AllowJumpBackwardsMod(JaxAtariInternalModPlugin):
@partial(jax.jit, static_argnums=(0,))
def _jump_speed_allows_start(self, player_speed: chex.Array) -> chex.Array:
return jnp.array(True)


class SingleLaneCarSpawnMod(JaxAtariInternalModPlugin):
@partial(jax.jit, static_argnums=(0,))
def _sample_enemy_spawn_road(self, rng_key: chex.PRNGKey) -> chex.Array:
return jnp.array(1, dtype=jnp.int32)


class ProgressiveCarSpawnRateMod(JaxAtariInternalModPlugin):
conflicts_with = ["minimum_car_spawn_gap"]

@partial(jax.jit, static_argnums=(0,))
def _adjust_enemy_spawn_timer(self, state: UpNDownState, spawn_timer: chex.Array) -> chex.Array:
start_interval = jnp.int32(self._env.consts.ENEMY_SPAWN_INTERVAL_BASE)
min_interval = jnp.int32(8)
horizon = jnp.float32(1800.0)

in_reset_phase = jnp.logical_or(state.awaiting_round_start, state.awaiting_respawn)
effective_steps = jnp.where(in_reset_phase, jnp.int32(0), state.movement_steps)

progress = jnp.clip(effective_steps.astype(jnp.float32) / horizon, 0.0, 1.0)
decayed_interval = jnp.round(
start_interval.astype(jnp.float32) - progress * (start_interval.astype(jnp.float32) - min_interval.astype(jnp.float32))
).astype(jnp.int32)

target_interval = jnp.maximum(min_interval, decayed_interval)
return jnp.minimum(spawn_timer, target_interval)


class TimeDecayCollectibleValueMod(JaxAtariInternalModPlugin):
@partial(jax.jit, static_argnums=(0,))
def _collectible_score_values(self, state: UpNDownState, collectible_type_ids: chex.Array) -> chex.Array:
base_scores = self._env.consts.COLLECTIBLE_SCORES[collectible_type_ids]
in_reset_phase = jnp.logical_or(state.awaiting_round_start, state.awaiting_respawn)
effective_steps = jnp.where(in_reset_phase, jnp.int32(0), state.movement_steps)
elapsed_decay = jnp.floor(effective_steps.astype(jnp.float32) / 200.0).astype(jnp.int32)
min_scores = jnp.maximum(jnp.int32(10), base_scores // 3)
return jnp.maximum(base_scores - elapsed_decay, min_scores)
83 changes: 83 additions & 0 deletions src/jaxatari/games/mods/upndown_mod_plugins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
from functools import partial
import chex
import jax
import jax.numpy as jnp

from jaxatari.games.jax_upndown import UpNDownState
from jaxatari.modification import JaxAtariInternalModPlugin


class RemoveStepRoadsMod(JaxAtariInternalModPlugin):
@partial(jax.jit, static_argnums=(0,))
def _is_steep_road_segment(self, current_road: chex.Array, road_index_A: chex.Array, road_index_B: chex.Array) -> chex.Array:
return jnp.array(False)


class HigherPlayerSpeedMod(JaxAtariInternalModPlugin):
constants_overrides = {
"MAX_SPEED": 9,
}


class MoreCollectiblesMod(JaxAtariInternalModPlugin):
constants_overrides = {
"MAX_ACTIVE_COLLECTIBLES": 4,
"COLLECTIBLE_SPAWN_INTERVAL": 120,
}


class MinCarSpawnGapMod(JaxAtariInternalModPlugin):
conflicts_with = ["progressive_car_spawn_rate"]
constants_overrides = {
"ENEMY_SPAWN_INTERVAL_BASE": 50,
}


class AllowJumpBackwardsMod(JaxAtariInternalModPlugin):
@partial(jax.jit, static_argnums=(0,))
def _jump_speed_allows_start(self, player_speed: chex.Array) -> chex.Array:
return jnp.array(True)


class SingleLaneCarSpawnMod(JaxAtariInternalModPlugin):
@partial(jax.jit, static_argnums=(0,))
def _sample_enemy_spawn_road(self, rng_key: chex.PRNGKey) -> chex.Array:
return jnp.array(1, dtype=jnp.int32)


class ProgressiveCarSpawnRateMod(JaxAtariInternalModPlugin):
conflicts_with = ["minimum_car_spawn_gap"]

@partial(jax.jit, static_argnums=(0,))
def _adjust_enemy_spawn_timer(self, state: UpNDownState, spawn_timer: chex.Array) -> chex.Array:
start_interval = jnp.int32(self._env.consts.ENEMY_SPAWN_INTERVAL_BASE)
min_interval = jnp.int32(8)
horizon = jnp.float32(1800.0)

progress = jnp.clip(state.movement_steps.astype(jnp.float32) / horizon, 0.0, 1.0)
decayed_interval = jnp.round(
start_interval.astype(jnp.float32) - progress * (start_interval.astype(jnp.float32) - min_interval.astype(jnp.float32))
).astype(jnp.int32)

target_interval = jnp.maximum(min_interval, decayed_interval)
return jnp.minimum(spawn_timer, target_interval)

@partial(jax.jit, static_argnums=(0,))
def _on_level_completed(self, state: UpNDownState) -> UpNDownState:
return state._replace(
movement_steps=jnp.array(0, dtype=jnp.int32),
enemy_spawn_timer=jnp.array(self._env.consts.ENEMY_SPAWN_INTERVAL_BASE, dtype=jnp.int32),
)


class TimeDecayCollectibleValueMod(JaxAtariInternalModPlugin):
@partial(jax.jit, static_argnums=(0,))
def _on_level_completed(self, state: UpNDownState) -> UpNDownState:
return state._replace(movement_steps=jnp.array(0, dtype=jnp.int32))

@partial(jax.jit, static_argnums=(0,))
def _collectible_score_values(self, state: UpNDownState, collectible_type_ids: chex.Array) -> chex.Array:
base_scores = self._env.consts.COLLECTIBLE_SCORES[collectible_type_ids]
elapsed_decay = jnp.floor(state.movement_steps.astype(jnp.float32) / 200.0).astype(jnp.int32)
min_scores = jnp.maximum(jnp.int32(10), base_scores // 3)
return jnp.maximum(base_scores - elapsed_decay, min_scores)
40 changes: 40 additions & 0 deletions src/jaxatari/games/mods/upndown_mods.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from jaxatari.modification import JaxAtariModController
from jaxatari.games.mods.upndown.upndown_mod_plugins import (
AllowJumpBackwardsMod,
RemoveStepRoadsMod,
HigherPlayerSpeedMod,
MoreCollectiblesMod,
MinCarSpawnGapMod,
SingleLaneCarSpawnMod,
ProgressiveCarSpawnRateMod,
TimeDecayCollectibleValueMod,
)


UPNDOWN_MOD_REGISTRY = {
"allow_jump_backwards": AllowJumpBackwardsMod,
"remove_step_roads": RemoveStepRoadsMod,
"higher_player_speed": HigherPlayerSpeedMod,
"spawn_more_collectibles": MoreCollectiblesMod,
"minimum_car_spawn_gap": MinCarSpawnGapMod,
"single_lane_car_spawn": SingleLaneCarSpawnMod,
"progressive_car_spawn_rate": ProgressiveCarSpawnRateMod,
"collectible_value_time_decay": TimeDecayCollectibleValueMod,
}


class UpNDownEnvMod(JaxAtariModController):
REGISTRY = UPNDOWN_MOD_REGISTRY

def __init__(
self,
env,
mods_config: list = [],
allow_conflicts: bool = False,
):
super().__init__(
env=env,
mods_config=mods_config,
allow_conflicts=allow_conflicts,
registry=self.REGISTRY,
)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added src/jaxatari/games/sprites/up_n_down/balloon.npy
Binary file not shown.
Binary file not shown.
Binary file added src/jaxatari/games/sprites/up_n_down/cherry.npy
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added src/jaxatari/games/sprites/up_n_down/flag_pole.npy
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added src/jaxatari/games/sprites/up_n_down/lollypop.npy
Binary file not shown.
Binary file not shown.
Binary file added src/jaxatari/games/sprites/up_n_down/pink_flag.npy
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading