Look up "Skinner box." Basically codified the psychology behind a slot machine. A mouse hits a single lever that either releases or doesn't release food. When the lever is set to Always release food, the mouse soon gets bored and only eats when he's hungry. When the lever is set to Randomly release food, the mouse gets addicted, compulsively hitting the lever all day without concern for how fat he is getting.
To expand on this a bit, BF Skinner founded the behaviorist area of psychology (which is important in later fields like neuroscience for training animals on various experiments), he specifically investigated operant behavior (behavior where the organism does something to its environment) and various schedules of reinforcement. The schedule you're thinking of is one of the strongest schedules for inducing behavior, and that's the variable ratio schedule, where reinforcement occurs after a variable number of responses from the organism. Skinner was actually one of the first to try and bring more rigor to psychology.