Animals undergo major behavioral adjustments during ontogeny, but the cognitive and neural computations controlling these processes remain elusive. Here, we describe that zebrafish transition from light-seeking to dark-seeking, as they grow from larval to juvenile stage, within the first few weeks of their life. We apply a combination of complementary phototaxis assays in virtual reality and modeling to dissect the algorithmic basis of this transition. We identify three parallel pathways, one analyzing whole-field luminance levels, one comparing spatial light levels across eyes, and one computing eye-specific temporal derivatives. Larvae mostly use the latter two spatio-temporal computations for navigation, while juveniles largely employ the first one. We build a library of agent-based models to predict animal behavior across stimulation conditions and in more complex environments. Model-based extraction of latent cognitive variables points towards potential neural correlates of the observed behavioral inversion and illustrates a novel way to explore the mechanisms of vertebrate ontogeny. We suggest that zebrafish phototaxis is regulated via parallel processing streams, which could be a universal implementation to change strategies depending on developmental stage, context, or internal state, making behavior flexible and goal-oriented.