I think the following has better mathematical properties, but obviously it's all heuristics.

31 * (31 * ( 31 * (31 * (17 + startLevel) + depth) + nextLevel) + nextState);

This is just going off of some old readings of Josh Bloch et al