# Can you provide some pseudocode examples of what constitutes an AI?

After years of learning, I still can't understand what is considered to be an AI. What are the requirements for an algorithm to constitute Artificial Intelligence? Can you provide pseudocode examples of what constitutes an AI?

AI is not a simple term. There are different types, ranging from the most simplistic rule-based AI to black-box AI's so complicated it's unreasonable for a human to understand exactly what they're doing.

There's no pseudocode that if used in a program automatically constitutes it as an AI. It's not that black and white. But I can give examples:

Here's a rule-based chess AI that forfeits if it's too far behind, and plays aggressively if it's far enough ahead.

if player.score - my.score > 10:
forfeit
elif my.score - player.score > 10:
agressive = True

for each piece of my.pieces:
for each square of board.squares:
if noThreats(square) and agressive is True:
move(piece, square)
return


This is considered an "AI" because it feigns intelligence - appearing to have a true understanding of chess while simply following a set of rules, making it an "Artificial" Intelligence.

Here's another more complicated AI:

decisionNet = NeuralNetwork(64 inputs, 2 outputs)

choice = decisionNet(board.squares) // Returns a chess square with one of my pieces and desitnation
move(choice)


This uses a neural network to make the decision, which could have been trained on a bunch of example games or against itself. Due to this "training phase", humans can't understand precisely what the network is doing without extensive effort, so it's an even gives an even more convincing understanding of chess. But if we want, we could still understand the nuances of this network, and show it doesn't possess an intelligence, it again only feigns it.

I should mention that virtually any code that has an if statement can be considered AI. The examples I provided are just easier to pass off as understanding a very complicated concept (chess), as opposed to, say, verifying a user login. They both have the same fundamentals, it's just one appears more complicated on the surface than the other.

• Do all AIs include the if statement or it depends on the type of AI? Mar 6, 2020 at 8:44

Philosophically, my own research has led me to understand AI as any artifact that makes a decision. This is because the etymology of "intelligence" strongly implies "selecting between alternatives", and these meanings are baked in all the way back to the proto-Indo-European.

(Degree of intelligence, or "strength" is merely a measure of utility, typically versus other decision making mechanisms, or, "fitness in an environment", where an environment is any action space.)

Therefore, the most basic form of automated (artificial) intelligence is:

if [some condition]
then [some action]


It is worth noting that narrow AI which matches or exceeds human capability, in the popular sense, manifested only recently when we had sufficient processing and memory to derive sufficient utility from statistical decision making algorithms. But Nimatron constitutes perhaps the first functional strong-narrow AI in a modern computing context, and the first automated intelligence are simple traps and snares, which have been with us almost as long as we've used tools.

I will leave it to others to break down all the various forms of modern AI.

• The expression strong-narrow AI is not a standard one and may be misleading or confusing. You're talking about narrow AIs that are really good, such as AlphaGo, but maybe you could use another adjective other than "strong". Btw, I think that "strong AI" is really a bad expression. AGI is definitely a better expression.
– nbro
Mar 5, 2020 at 23:40
• @nbro I noticed that certain scholars started using "strong narrow" after the advent of AlphaGo. I think you're technically correct that "strong" is not strictly required, since it references degree of intelligence, as opposed to the nature of intelligence. Here though, I am using it to connote intelligence that matches or exceeds human intelligence. Perhaps I need to define that? (PS—I agree fully that the traditional use of "strong AI" is archaic, and that AGI should be used, because it is more explicit—general intelligence is only implied in the former term.)
– DukeZhou
Mar 6, 2020 at 0:21