TL;DR Ignore the hype, current systems (in 2018) are very far removed from human-like "thinking", despite interesting and useful results. State-of-the-art for "thinking and behaving like a creature in general" has not reached the sophistication level of insects, even though we have example narrow AIs that can beat the world's best at intellectual games.
There are some issues with the question as phrased, it is not a precise question, and includes some common wooly logic that many people have when discussing AI. However, I think these occur so often, that they are worth addressing here:
But are they really thinking.
Define "thinking". It is not easy.
Do they think like humans?
We don't fully know or understand how humans think.
Do they have consciousness?
We don't fully know or understand what consciousness is.
Or are they just obeying a bunch of codes?
Are you just obeying a "bunch of codes"? There is no reason to suspect that humans have a magic "something" that powers thought. All scientific evidence points to humans being sophisticated machines that follow the laws of physics and chemistry. However, the level of complexity is such that how brains, thinking and consciousness work is a very hard problem to solve. It is also possible that our lack of knowledge obscures some unknown property of the brain or "thinking" that means it is more than applied physics and chemistry - but there is zero evidence for such a thing.
For example, when an AI learns to play pacman, is it really learning that it should not touch the ghosts or are they just following a mechanical path which will make them win the game?
This is an interesting question, and there is more to it than a simple yes/no answer:
Learning is not the same as thinking. We expect an intelligent entity to be able to learn, when it receives new information. However, something that only learns - the only feature of it is that it gains some performance measure when fed experience - is only solving part of what it means to be intelligent or thinking.
A human player starts with assumptions. A game like Pacman presents a simplified world that obeys many rules that we are already familiar with. In the game there is a space (the screen), in which rules of distance apply. There are objects (the pacman, walls, pills, power pills, ghosts) that have coherent shapes, and persistent properties that are recognisable. Object persistence is a thing. The game play follows familiar concepts of time. All these things are at least initially meaningless to a neural network.
A neural network generalises. One of the reasons of the success of Deep Learning is that neural networks can, within limits, learn rules such as "avoid the ghosts" or in the case of a typical agent in DQN, that ghosts getting closer to the player is an indication that there is a low value in staying still or moving towards a ghost, and a high value in moving away towards an escape route. Not only that, but there is a good chance that a deep neural network will learn an internal representation that really does detect the ghosts and learn an association between them and the type of action, and this can be inspected by generating "heat maps" of neuron response to different areas of an image
Neural networks require far more experience than humans to learn to play well. This demonstrates that they are learning differently. Some of this may be due to human innate knowledge transferring to playing a game. However, a typical reinforcement-learning training scenario would need to demonstrate that ghosts are dangerous 100s of times before the neural network finally is able to generalise well. Whilst a human would learn that after only a few encounters, maybe only one. There is much research in this area, as making learning as efficient as possible is an important goal.
Neural networks are too direct and simple to possess internal world models. Raw generalisation is not the same as having the kind of rich internal model that you may be considering as "thinking". After training, the neural network is a function which maps a visual field of pixels into values and/or actions. There is no internal "narrative", even though the function is enough to behave correctly, it does not encode concepts such as space, object persistence, object traits etc, and it most definitely does not experience them.
In some ways, asking if an artificial neural network can think is like asking if a small slice of your retina, or a tiny cube (less than 1mm3) of brain tissue can think. Or perhaps if your walking reflex and innate sense of balance counts as thinking. Current state-of-the-art efforts are at that kind of scale both in terms of computer power and complexity.