Java port of core functionality of John Magliacane's Predict C program