Add retry to prep/cast cycle, check state every iteration and shuffle after each successful observation in "predict_script.rb"