Author: Daniël Veldman, FAU DCN-AvH

A sheep herding game in MATLAB developed for the Long Night of Science #NdW22 (Lange Nacht der Wissenschaft) Erlangen-Furth-Nuernberg 2022.

Main rules

• The dog should drive sheep to the target (red).
• You can steer the dog with the arrow keys.
• The sheep are afraid of the dog and of the fences.
• The farther the sheep are from the target, the faster the cost increases.
• The level is completed when all sheep stand still near the target.


1- Download the file SheepHerdingGame.mlappinstall.
2- Double click to open it with MATLAB.
3- Click ‘Install’ in the dialogue box that opens.
4- You can now find the sheep herding game under the Apps tab in MATLAB. Click it to play.

Optimal control of sheep flocks
Controlling a large flock of sheep is an example of the complex dynamic optimization problems that we study at the Chair for Dynamics, Control, and Numerics – Alexander von Humboldt Professorship at Friedrich-Alexander-Universität, Erlangen-Nürnberg (Germany).

You are invited to test the difficulties in an interactive computer game!

Can you beat our algorithm?

Check the poster:

© 2019-2022 FAU DCN-AvH Chair for Dynamics, Control and Numerics - Alexander von Humboldt Professorship at Friedrich-Alexander-Universität Erlangen-Nürnberg, Germany | Imprint | Contact