Couldn't an AI cheat when trying to follow its goal?
These are two good questions. To address the first, this is a known problem in AI safety and is called "Wireheading". There is currently no known solution other than to somehow prevent an AI agent from being able to alter its internal state in this fashion.
If you are interested in this area in general then I recommend this paper as an entry point into the literature.