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
2 changes: 1 addition & 1 deletion apps/crazy_robotaxi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,6 @@ uv run --package crazy-robotaxi crazy-robotaxi-map preview-spawn \
path/to/city.robotaxi.yaml --spawn taxi_start --output taxi_start.png
```

Spawn variants can define both a full `prompt` for normal play and a shorter
Each spawn can define both a full `prompt` for normal play and a shorter
`prompt_context` base for `--live-edit-map-context`; dynamic road and motion
clauses are appended only to the latter.
25 changes: 2 additions & 23 deletions apps/crazy_robotaxi/crazy_robotaxi/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,6 @@ def init(self, commandline_args: Sequence[str]) -> None:
scene_request=SceneRequest(
map_path=map_path.expanduser(),
camera_name=engine_settings.map.camera,
variant=engine_settings.map.variant,
prompt=engine_settings.map.prompt,
use_prompt_context=game_settings.live_edit.map_context.enabled,
force_recompile=engine_settings.map.force_recompile,
),
Expand Down Expand Up @@ -306,10 +304,7 @@ def init(self, commandline_args: Sequence[str]) -> None:
live_edit=game_settings.live_edit,
visual_flare_enabled=game_settings.effects.visual_flare_enabled,
)
self._map_options = _discover_game_maps(
map_path,
requested_variant=engine_settings.map.variant,
)
self._map_options = _discover_game_maps(map_path)

def _resolve_engine_settings(self, args: argparse.Namespace) -> EngineSettings:
settings = EngineSettings(
Expand All @@ -326,8 +321,6 @@ def _resolve_engine_settings(self, args: argparse.Namespace) -> EngineSettings:
settings.map,
path=args.map,
camera=args.camera,
variant=args.variant,
prompt=args.prompt,
force_recompile=args.force_map_recompile,
),
rendering=replace(
Expand Down Expand Up @@ -466,11 +459,7 @@ def _build_pipeline(config: Any, device: str) -> Any:
return config.setup().to(device).eval()


def _discover_game_maps(
selected_path: Path,
*,
requested_variant: str,
) -> tuple[GameMapOption, ...]:
def _discover_game_maps(selected_path: Path) -> tuple[GameMapOption, ...]:
"""Read menu metadata for bundled maps and maps beside the CLI selection."""
selected = selected_path.expanduser().resolve()
paths = {selected}
Expand All @@ -483,19 +472,11 @@ def _discover_game_maps(
options: list[GameMapOption] = []
for path in paths:
header = load_game_map_header(path)
variants = tuple(item.name for item in header.variants)
preferred = requested_variant if path == selected else "default"
variant = (
preferred
if preferred in variants
else ("default" if "default" in variants else variants[0])
)
options.append(
GameMapOption(
map_id=header.map_id,
name=header.name,
path=header.source_path,
variant=variant,
race_course_ids=header.race_course_ids,
)
)
Expand Down Expand Up @@ -541,8 +522,6 @@ def _parser(
parser.add_argument("--width", type=int, default=defaults.width)
parser.add_argument("--height", type=int, default=defaults.height)
parser.add_argument("--camera", default="camera_front_wide_120fov")
parser.add_argument("--variant", default="default")
parser.add_argument("--prompt")
parser.add_argument("--force-map-recompile", action="store_true")
parser.add_argument("--device", default="cuda")
parser.add_argument("--total-blocks", type=int)
Expand Down
3 changes: 0 additions & 3 deletions apps/crazy_robotaxi/crazy_robotaxi/game_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ class GameMapOption:
path: Path
"""Resolved authored-map path loaded after selection."""

variant: str
"""Visual variant used when loading this map."""

race_course_ids: tuple[str, ...] = ()
"""Ordered race courses available on this map."""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,10 @@ spawns:
road: spawn_arterial
lane: 2
distance_m: 128
variants:
default:
image: package://omnidreams_game_engine/screenshot.jpg
prompt: >-
A forward-facing view from a taxi moving through a quiet suburban
district in daylight, with low commercial buildings, houses,
landscaping, and parked cars.
prompt_context: >-
A forward-facing view from a taxi on a road through a city in daylight.
image: package://omnidreams_game_engine/screenshot.jpg
prompt: >-
A forward-facing view from a taxi moving through a quiet suburban
district in daylight, with low commercial buildings, houses,
landscaping, and parked cars.
prompt_context: >-
A forward-facing view from a taxi on a road through a city in daylight.
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,12 @@ spawns:
road: start_finish_straight
lane: 2
distance_m: 220
variants:
default:
image: package://omnidreams_game_engine/screenshot.jpg
prompt: >-
A forward-facing view from a taxi on a wide closed Formula-style
road circuit in daylight, with varied-radius corners, technical
esses, hairpins, safety barriers, grandstands, sponsor banners,
and a clear start-finish straight.
prompt_context: >-
A forward-facing view from a taxi on a wide road racing circuit
through a city in daylight.
image: package://omnidreams_game_engine/screenshot.jpg
prompt: >-
A forward-facing view from a taxi on a wide closed Formula-style
road circuit in daylight, with varied-radius corners, technical
esses, hairpins, safety barriers, grandstands, sponsor banners,
and a clear start-finish straight.
prompt_context: >-
A forward-facing view from a taxi on a wide road racing circuit
through a city in daylight.
7 changes: 0 additions & 7 deletions apps/crazy_robotaxi/crazy_robotaxi/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,6 @@ def select_game(self, selection: GameSelection) -> None:
request = replace(
self.config.scene_request,
map_path=option.path,
variant=option.variant,
prompt=(
self.config.scene_request.prompt
if option.path
== self.config.scene_request.map_path.expanduser().resolve()
else None
),
)
scene = self.scene_factory(request, self.config.renderer.raster)
self.close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,5 @@ spawns:
road: west_road
lane: 2
distance_m: 30
variants:
default:
image: package://omnidreams_game_engine/screenshot.jpg
prompt: A skewed three-way city intersection.
image: package://omnidreams_game_engine/screenshot.jpg
prompt: A skewed three-way city intersection.
6 changes: 2 additions & 4 deletions apps/crazy_robotaxi/tests/maps/parking_driveway.robotaxi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,5 @@ spawns:
road: west_road
lane: 1
distance_m: 30
variants:
default:
image: package://omnidreams_game_engine/screenshot.jpg
prompt: A street beside a small parking lot.
image: package://omnidreams_game_engine/screenshot.jpg
prompt: A street beside a small parking lot.
7 changes: 3 additions & 4 deletions apps/crazy_robotaxi/tests/maps/race_course.robotaxi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ spawns:
road: south_west
lane: 1
distance_m: 30
variants:
default:
image: package://omnidreams_game_engine/screenshot.jpg
prompt: A car racing on a rectangular city loop.
image: package://omnidreams_game_engine/screenshot.jpg
prompt: A car racing on a rectangular city loop.
prompt_context: A forward-facing view from a car on a city road.
6 changes: 2 additions & 4 deletions apps/crazy_robotaxi/tests/maps/traffic_loop.robotaxi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,5 @@ spawns:
road: south_west
lane: 1
distance_m: 30
variants:
default:
image: package://omnidreams_game_engine/screenshot.jpg
prompt: A car on a rectangular city loop.
image: package://omnidreams_game_engine/screenshot.jpg
prompt: A car on a rectangular city loop.
48 changes: 36 additions & 12 deletions apps/crazy_robotaxi/tests/test_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@
"""CPU validation for shipped semantic maps."""

import math
import zipfile
from pathlib import Path

import numpy as np
import pytest
import yaml
from omnidreams_game_engine.config import RasterConfig
from omnidreams_game_engine.game_map import (
GameMapError,
compile_game_map,
load_game_map,
load_game_map_header,
)
from omnidreams_game_engine.game_map.types import (
game_map_from_dict,
game_map_to_dict,
)
from omnidreams_game_engine.scene import SceneRequest, load_scene

pytestmark = pytest.mark.ci_cpu

Expand All @@ -35,9 +39,8 @@ def test_shipped_map_is_valid(filename: str) -> None:
assert game_map.map_id.startswith("crazy-robotaxi-")
assert game_map.spawns
assert game_map.lanes
variant = game_map.default_spawn.variants[0]
assert variant.prompt_context
assert variant.prompt_context != variant.prompt
assert game_map.default_spawn.prompt_context
assert game_map.default_spawn.prompt_context != game_map.default_spawn.prompt


def test_prompt_context_is_trimmed_and_round_trips(tmp_path: Path) -> None:
Expand All @@ -46,9 +49,7 @@ def test_prompt_context_is_trimmed_and_round_trips(tmp_path: Path) -> None:
)
source["nodes"][0]["prompt_context"] = " A neighborhood landmark. "
source["roads"][0]["prompt_context"] = " Detached homes line the road. "
source["spawns"][0]["variants"]["default"]["prompt_context"] = (
" A forward-facing road view. "
)
source["spawns"][0]["prompt_context"] = " A forward-facing road view. "
path = tmp_path / "prompt-context.robotaxi.yaml"
path.write_text(yaml.safe_dump(source, sort_keys=False))

Expand All @@ -59,11 +60,8 @@ def test_prompt_context_is_trimmed_and_round_trips(tmp_path: Path) -> None:
assert original.topology.roads[0].prompt_context == (
"Detached homes line the road."
)
assert original.default_spawn.variants[0].prompt_context == (
"A forward-facing road view."
)
assert restored.default_spawn.variants == original.default_spawn.variants
assert restored.topology == original.topology
assert original.default_spawn.prompt_context == "A forward-facing road view."
assert game_map_to_dict(restored) == game_map_to_dict(original)


@pytest.mark.parametrize("value", ["", " ", 42, ["not", "text"]])
Expand All @@ -86,7 +84,7 @@ def test_spawn_prompt_context_requires_nonempty_text(
source = yaml.safe_load(
(_MAP_FIXTURES / "intersection_geometry.robotaxi.yaml").read_text()
)
source["spawns"][0]["variants"]["default"]["prompt_context"] = value
source["spawns"][0]["prompt_context"] = value
path = tmp_path / "invalid-spawn-prompt-context.robotaxi.yaml"
path.write_text(yaml.safe_dump(source, sort_keys=False))

Expand All @@ -113,6 +111,32 @@ def test_prompt_context_change_invalidates_compiler_cache(tmp_path: Path) -> Non
assert changed.archive_path != first.archive_path


def test_compiled_map_uses_canonical_spawn_conditioning(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
path = Path(__file__).parent / "maps" / "race_course.robotaxi.yaml"
monkeypatch.setenv("FLASHDREAMS_CACHE_DIR", str(tmp_path))
game_map = load_game_map(path)

scene = load_scene(
SceneRequest(map_path=path),
RasterConfig(width=64, height=32, compute_device="automatic"),
)
context_scene = load_scene(
SceneRequest(map_path=path, use_prompt_context=True),
RasterConfig(width=64, height=32, compute_device="automatic"),
)

assert scene.prompt == game_map.default_spawn.prompt
assert context_scene.prompt == game_map.default_spawn.prompt_context
assert context_scene.scene_path != scene.scene_path
assert scene.initial_rgb.shape == (32, 64, 3)
with zipfile.ZipFile(scene.scene_path) as archive:
names = set(archive.namelist())
assert {"prompt.txt", "first_image.png"} <= names
assert not any(name.startswith(("prompt_", "first_image_")) for name in names)


def test_boulevard_traffic_turns_are_continuous_and_physically_limited() -> None:
path = (
Path(__file__).parents[1]
Expand Down
5 changes: 0 additions & 5 deletions apps/crazy_robotaxi/tests/test_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,6 @@ def test_selection_menus_use_arcade_card_layout() -> None:
map_id="test-city",
name="Test City",
path=Path("test-city.robotaxi.yaml"),
variant="default",
race_course_ids=("downtown-sprint",),
)
state = TaxiHudState(640, 540, _calibration(), map_options=(option,))
Expand Down Expand Up @@ -944,7 +943,6 @@ def test_startup_menu_selects_taxi_mode_then_map_through_v2_message() -> None:
map_id="test-city",
name="Test City",
path=Path("test-city.robotaxi.yaml"),
variant="default",
race_course_ids=("downtown-sprint",),
)
state = TaxiHudState(640, 360, _calibration(), map_options=(option,))
Expand Down Expand Up @@ -978,7 +976,6 @@ def test_race_menu_selects_map_then_course() -> None:
map_id="test-city",
name="Test City",
path=Path("test-city.robotaxi.yaml"),
variant="default",
race_course_ids=("downtown-sprint",),
)
state = TaxiHudState(640, 360, _calibration(), map_options=(option,))
Expand Down Expand Up @@ -1016,7 +1013,6 @@ def test_complete_cli_selection_skips_all_selection_screens() -> None:
map_id="test-city",
name="Test City",
path=Path("test-city.robotaxi.yaml").resolve(),
variant="default",
race_course_ids=("downtown-sprint",),
)
state = TaxiHudState(
Expand Down Expand Up @@ -1055,7 +1051,6 @@ def test_explicit_race_mode_and_map_skip_to_course_screen() -> None:
map_id="test-city",
name="Test City",
path=Path("test-city.robotaxi.yaml").resolve(),
variant="default",
race_course_ids=("downtown-sprint",),
)
state = TaxiHudState(
Expand Down
25 changes: 11 additions & 14 deletions apps/omnidreams_game_engine/NODE_GRAPH_MAP_FORMAT.md
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ compiled cyclic route and defaults to zero. Vehicles are physical, collidable,
and maintain simple same-lane headway; traffic signals and right-of-way are not
currently modeled.

## Spawns and visual variants
## Spawns and visual conditioning

A spawn names an authored road lane and a distance along its directed
centerline. Lane indices follow the effective `lanes` order.
Expand All @@ -436,25 +436,22 @@ spawns:
road: oak_street
lane: 1
distance_m: 5
variants:
default:
image: seed.png
prompt: A forward-facing taxi view in a quiet neighborhood at daylight.
prompt_context: A forward-facing taxi view on a road at daylight.
image: seed.png
prompt: A forward-facing taxi view in a quiet neighborhood at daylight.
prompt_context: A forward-facing taxi view on a road at daylight.
```

Every spawn requires a `default` variant. `image` is optional; when omitted (or
set to `null`), the compiler generates a deterministic synthetic first-person
view by projecting the semantic map from that spawn through the runtime front
camera. This fallback shows aligned road surfaces, boundaries, curbs, and
markings, but does not synthesize scenery. Use it as a robust placeholder, not
as a photorealistic authoring result.
Every spawn requires a non-empty `prompt`. `image` is optional; when omitted
(or set to `null`), the compiler generates a deterministic synthetic
first-person view by projecting the semantic map from that spawn through the
runtime front camera. This fallback shows aligned road surfaces, boundaries,
curbs, and markings, but does not synthesize scenery. Use it as a robust
placeholder, not as a photorealistic authoring result.

`prompt` is the complete standalone scene description. `prompt_context` is an
optional shorter base prompt for applications that append live road, topology,
and motion context. When that mode is selected, `prompt_context` is used if
present and otherwise falls back to `prompt`. An explicit runtime prompt
override remains authoritative in either mode.
present and otherwise falls back to `prompt`.

Authored images may be map-relative paths or `package://package/resource`
references. Resolved geometry, compiler and fallback-renderer code, seed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ class MapLaunchSettings:
camera: str = "camera_front_wide_120fov"
"""Camera identifier selected from the map's available views."""

variant: str = "default"
"""Visual variant selected from the map."""

prompt: str | None = None
"""Base prompt override; ``None`` uses the map variant's prompt."""

force_recompile: bool = False
"""Whether to rebuild the selected map's compiled cache once."""

Expand Down
Loading
Loading