added script with functions to get node states and to select Q using an expected number of substitutins