First time using m̶a̶c̶h̶i̶n̶e̶ program learning I recommend using turbo mode (that is shift+click on the flag) to see the improvement much quicker. Press [Z] to see the debug menu.
Every entity has 250 frames before its time stops. If it gets the most amount of apples out of any other entity then the future entities use what it does and modify it a little bit. The entity knows if the apple is left, right, above or below its current location, and it can either go closer to it or away and the speed varies.