On the Mechanical Simulation of Habit-Forming and Learning