Q as in maximum expected utility for a given move, Pig as in the dice game of Pig.
https://web.archive.org/web/20140122073352/https://www.udaci...
Yes, I know that you can get the Q value via RL with Bellman equation or non-parametric evo learning, but at the time I didn't know that and I'm glad I didn't.
Depending on how you count, this code features either 2 or 4 mutually recursive functions, something that is quite rare in Python (esp outside the context of an FSM) but is a signature of PN code.
I had to learn so much about so many things to untangle it.