Dang, I've programmed NPCs that are smarter than that. You keep using your algorithm. As a game dev you might do better to build your own though.
forever {
get Input (I)
function; pickRandom <1-10> store (R)
I*R=T
print (T)
T+=globalStorageVar
}
(JK this code is totally useless, 98% comedy and 2% Python)