How should i guide a program to perform correct things?
The "Infinite Monkey Theorem" doesn't say that monkeys will learn.  On the contrary: it says that if monkeys keep typing random stuff long enough (i.e. not using any sort of learning), the works of Shakespeare will eventually come out purely by chance.  It is the Law of Truly Large Numbers.

So you're right: you need to build feedback into the system.  The program should change its behavior based on your feedback.  This is known as reinforcement learning and it is used a lot in AI.  An overarching term for this, I believe, is machine learning.