The Math Behind Successful Agents