Princess Nell spent some time studying the problem and eventually noticed 
that the system of gates was actually a very sophisticated version of one of 
the Duke of Turing's machines.
Once she understood that the behavior of the water-gates was orderly and 
predictable, it was not long before she was able to program their behavior and 
locate the bugs that the dark knight had introduced into the system. Soon water 
was flowing through the irrigation system again, and the famine was 
relieved.