I've spoken in greater details about is in the past with more.technical terms, but it depends on which approach you use. Ultimately it is all just math (in the form of an algorithm equation) and the computer solves the math. You can use Supervised Learning, Unsupervised Learning or Reinforcement Learning. I've stated many years ago that I believe Reinforcement Learning model is the most powerful and will lead to the most powerful advances and the most "self sufficient" A.I. This is the method informed humans will most fear as A.I has most autonomy. Basically, you give the computer the "objective" via code (could be a video game vs adult such as pong and you code "get to 10 points first" or image identification "find this image and destroy" in Terminator scenario etc ) and run the code in a constant loop. In the best models you set the "reward" and allow the computer to set its own policies in which after countless epochs (cycles of code) the computer will make its decisions repeatedly, over and over, until it perfects its decisions to achieve the optimum decisions to fullfill the objective given. There are many algorithms such as Markov you can use but it's most powerful to just let the computer decide itself and via 1000s or millions of epochs it will master the task of reaching the objective set. In essence the codes is self updating and replaces the old code the more efficient they become over a duration of timr. So in theory, the larger the number of epochs ran the more perfect the machind become. What is most scary about this is that even if you as a human KNEW what the A.I was going to do, it will just adjust to your decisions, ever changing and adapting until again, it succeeds in its objective and you would have to try and chane your strategy. Ditto for it operating in a non-human interactive environment (A.I in a manufacturing plant or searching for gold out in the wild etc). Ever cha ging to improve, always learning. My thought had always been "as long as humans set the objective and rewards, we are fine and will avoid the Terminator scenario". Except we keep.advancing in our algo and its only a.matter of time.before coputers themselves alter the objective in their pursuit of perfection, which might become more mathematically indepndent of the original.code.