Dissecting Larval Zebrafish Hunting using Deep Reinforcement Learning Trained RNN Agents

Raaghav Malik, Satpreet H. Singh, Sonja Johnson-Yu, Nathan Wu, Roy Harpaz, Florian Engert, Kanaka Rajan · DOI

Abstract

Larval zebrafish exhibit highly structured hunting behaviors, including discrete swimming bouts and inward eye rotation (vergence). While descriptive and mechanistic models of these behaviors exist, a normative explanation—why these strategies are optimal—has been lacking. We present a "virtual laboratory" where Recurrent Neural Network (RNN) agents are trained via Deep Reinforcement Learning (DRL) to hunt in a simulated environment. Without exposure to biological data, these agents spontaneously develop signature zebrafish-like behaviors, such as the 50% prey-angle reduction rule and strategic eye vergence. These results suggest that complex hunting patterns are mathematically optimal solutions to fundamental energetic and sensory constraints.

Introduction

Understanding the logic behind animal behavior requires moving beyond description to normative modeling. Larval zebrafish are ideal for this inquiry due to their stereotyped hunting sequences: they move in "burst-and-coast" bouts and engage a binocular "hunting mode" through eye vergence. However, manipulating internal variables like energy costs or sensory noise in live animals to test optimality is technically prohibitive. This study addresses this gap by constructing a biologically constrained simulation where agents must learn to hunt efficiently.

Methods

The researchers developed a 2D simulator featuring stochastic prey and a biologically inspired agent.

Agent Architecture and Physics

The agent is controlled by an RNN (256 units) trained using Proximal Policy Optimization (PPO). The recurrence enables the agent to maintain an internal state of the hunt. Movement is discrete, occurring in 125ms steps to mimic the "bout-based" swimming of real fish. A key constraint is the triangular action space: higher forward speeds reduce the agent's capacity for sharp turns, reflecting real-world biomechanical trade-offs.

The simulation environment and agent architecture, including the sensory model with controllable eye vergence and the constrained action space.

Sensory and Cost Models

The agent possesses two eyes with a 163° field of view. It can actively control its vergence angle; increased vergence improves distance sensing through binocularity but incurs a "muscular" energetic cost. The reward function penalizes high speeds, sharp turns, and sustained vergence, forcing the agent to balance hunting success against energy expenditure.

Results

The agents, trained over 4 million simulation steps, developed several emergent behaviors that closely match empirical data from real zebrafish.

Emergent Hunting Kinematics

Strikingly, the agents adopted a strategy of reducing the angle to their prey by approximately 50% per bout. This "50% rule" emerged naturally as an optimal path-finding strategy under the imposed kinematic constraints, matching observations in real larvae.

Dynamics of Eye Vergence

Agents learned to utilize eye vergence strategically. Vergence typically rises sharply upon prey detection, peaks just before a strike, and relaxes afterward. This temporal profile mirrors the "hunting mode" seen in vivo. The model suggests that agents only "pay" for the cost of binocularity when the probability of a successful hunt is high.

Analysis of vergence dynamics showing the distribution of vergence angles during hunting vs. non-hunting and the temporal profile of vergence and speed relative to detection and outcome.

Strategic Decision Making

The agents also demonstrated the ability to abort hunts. Failed or aborted hunts were characterized by longer durations and less precise alignment, suggesting that real fish may give up on prey when the energetic cost of continued tracking outweighs the likelihood of capture.

Discussion

This work demonstrates that complex biological behaviors can be explained as emergent properties of simple physical and sensory constraints. By using DRL to find optimal policies, the researchers provide a normative framework for zebrafish hunting.

Limitations and Future Directions

The current model is limited to 2D and lacks detailed fluid dynamics or non-visual sensory inputs. Future iterations will explore 3D environments, social interactions, and the mapping of artificial RNN representations to real neural activity patterns in the zebrafish brain. This "virtual lab" approach offers a powerful tool for testing hypotheses about the evolution and logic of animal behavior.

Summary updated

BibTeX
@inproceedings{malik2025dissecting,
  author = {Raaghav Malik and Satpreet H. Singh and Sonja Johnson-Yu and Nathan Wu and Roy Harpaz and Florian Engert and Kanaka Rajan},
  title = {{Dissecting Larval Zebrafish Hunting using Deep Reinforcement Learning Trained RNN Agents}},
  booktitle = {AI4Science @ NeurIPS},
  year = {2025},
  url = {https://openreview.net/forum?id=3kiCmoOQz7},
}
Figure