Take on a juggling challenge created by Diffblue's AI for Code

Diffblue Playground is our free-to-use tool that demonstrates the AI behind Diffblue Cover by automatically creating unit tests for any Java code entered into it. A little known capability of this tool is that it can do more than help you juggle writing tests and developing new code—my colleague Jamie Munro and I have discovered that it can also be used to create brand new juggling tricks. 

The Math of Juggling 

It might not be obvious that juggling tricks can be described mathematically, but that’s exactly what the siteswap notation does. Siteswap is a way of writing down juggling tricks as a sequence of numbers, like 531 or 552. Different numbers correspond to throwing the juggling balls to different heights: higher numbers represent higher throws. The number of balls needed for the trick is the average of the numbers, so 531 is a 3-ball trick and 552 is a 4-ball trick. 

A fun aspect of this method is that it can also be used to invent new tricks: come up with a sequence of numbers and then try to juggle it. This always works as long as the numbers satisfy the condition "two balls don't land in the same hand at the same time." Lots of new juggling tricks that are now totally standard were originally invented by coming up with a valid siteswap and trying to juggle it.

Can AI generate valid siteswaps?

As it turns out, Diffblue Playground can come up with new tricks using a Java function that takes an array of integers, checks that they aren't negative, and asserts that they satisfy the condition for a valid trick. This generates a unit test that involves feeding a valid siteswap into the function:

The first time it came up with 31411. An attempt at this with juggling balls showed that it’s a nice little two-ball trick. In fact, it was a much nicer trick than someone might typically make up. Here is a visualization courtesy of this siteswap animator, which illustrates any trick you enter:

A siteswap animation of the trick “31411.”

A siteswap animation of the trick “31411.”

By slightly changing the input for the Java function to make Diffblue Playground choose different random guesses, it produced more juggling tricks: 124245 (3 balls, a trick I’d never seen before) and 51 (a 3-ball shower, one of the oldest juggling tricks around). The difficulty varies, but all of the tricks produced are physically possible to do.

Come up with new tricks yourself and use the above animator to see how they look, and consider giving it a go with a few juggling balls! You can share your favorite discoveries with us on Twitter: @DiffblueHQ