Skip to content

Decode hex-encoded float32 observations - #268

Open
kodexArg wants to merge 1 commit into
edbeeching:mainfrom
kodexArg:obs-binary-encoding
Open

kodexArg wants to merge 1 commit into
edbeeching:mainfrom
kodexArg:obs-binary-encoding

Conversation

@kodexArg

@kodexArg kodexArg commented Nov 25, 2026 •

Copy link
Copy Markdown

Part of #267: decodes the binary observations that the companion plugin PR can send.

What changes

GodotEnv._process_obs now decodes a non-2d observation key whose value is a string as hex-encoded float32 bytes:

np.frombuffer(bytes.fromhex(hex_string), dtype="<f4").reshape(shape)

Keys containing 2d and plain JSON lists are handled exactly as before, so older plugins keep working.

Why

With 100 agents sending 69 floats each, a step takes 5,435 µs with JSON number lists and 2,355 µs with hex float32, measured end to end with the real Sync node and GodotEnv. The observations match bit for bit. Full numbers are in #267.

Tests

  • New tests/test_obs_encoding.py: exact float32 round trip, plain lists left untouched, and mixed 2d, hex and list keys in one observation. These tests need no Godot binary.
  • black, isort and flake8 pass with the settings in the Makefile.

Companion plugin PR: edbeeching/godot_rl_agents_plugin#72

🤖 Generated with Claude Code

When the plugin's Sync node sends an observation as a hex string of its
float32 bytes (keys without "2d"), decode it with np.frombuffer instead of
receiving a JSON list of numbers. Plain lists and "2d" keys are unchanged,
so older plugins keep working.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant