|
← Back to home
A local vision-language loop that drives a browser-based car simulator using screen capture and keyboard control. The ideaThis project explores whether a locally hosted vision-language model (VLM) can close the loop from pixels to physical actions — without cloud APIs, without a dedicated game SDK, and without any task-specific training data. The setup is deliberately minimal: capture the game window, send the frame to a VLM running on Ollama, parse a JSON action, and execute it as a macOS keystroke.
The target environment is City Car Driving running in a browser. Controls are limited to ArchitectureThe agent follows a standard vision-language-action (VLA) pattern:
I iterated through three agent variants, each building on the last:
Evaluating out-of-the-box VLMsBefore any fine-tuning, I wanted to understand what these models can do as-is on a continuous control task they were never trained for. The results were mixed but informative. The full Qwen2.5-VL model could identify the road and generally chose to accelerate, but its ~15 s inference time made real-time control impossible — by the time an action executed, the scene had already changed. The 3B variant was fast enough to be usable (~7–9 s), and with chain-of-thought prompting it could reason about lane curvature and nearby barriers. However, it still struggled with sustained lane-keeping: it would drift, over-correct, and occasionally time out on longer reasoning chains. The hybrid OpenCV + VLM agent was the most promising zero-shot configuration. By giving the model explicit lane telemetry rather than asking it to infer everything from raw pixels, steering corrections became more consistent. The model could focus on higher-level decisions (when to brake, when to steer hard) while the classical CV layer handled low-level alignment. Key takeaways from the evaluation:
Timing and model variantsI tracked end-to-end loop latency across configurations. Approximate numbers from my MacBook:
Several engineering choices helped reduce latency: JPEG compression at quality 75, aggressive image downsizing, hard output token limits, and low temperature (0.1–0.2) for deterministic driving decisions. Action durations are clamped to 0.1–0.5 s bursts to prevent over-steering during slow inference gaps. Tuning with reinforcement learningThe zero-shot agents can keep the car on the road for short stretches, but they lack the consistency needed for longer drives or complex intersections. The next step is to fine-tune the policy with reinforcement learning — using the VLM as a starting policy and improving it through reward signals from the game environment (staying centered, avoiding collisions, maintaining speed). I have two early RL-tuned runs recorded below. These represent initial experiments where the agent learns from driving outcomes rather than relying purely on pre-trained VLM behavior. RL run A — lane keeping with corrections RL run B — extended driving session What's next
|