For more information, see Artificial intelligence on Wikipedia. Artificial Intelligence, commonly abbreviated as AI, has a popular connotation within Scratch relating to a computerized mind that consists entirely of programming code.

Its usage in Scratch, albeit somewhat misleading, is most common in projects in which a user can play a game against the computer.

## Tutorial

### Simple AIs

Most projects that use AI use special techniques, such as using variables to store different values. Those values may be previous locations, user input, and so on. They help to calculate different actions that allow the computer to make a good challenge to the player and succeed in its task.

### Perfect AIs

A practical and optimal AI system will use recursion[citation needed] to try to adapt to the circumstances itself. Given (for a game):

• What moves are possible
• An algorithm to tell if a given position is a win/loss for the computer, tie, or incomplete game

A recursive function to return the best move for a player given a board and which player can be written under the following logic:

• If the position is tied, won, or lost, return tied, won, or lost and the board
• Otherwise:
• Iterating through each continuation of the game for the player:
• If the best move for the other player results in a loss for him, return "Win" and the continued position
• If the best move for the other player results in a tie for him, return "Tie" and the continued position
• If the best move for the other player results in a win for him, return "Loss" and the continued position

See the article on game trees for more on recursive functions and their use in constructing AI.

### Common AIs

There is also another class of AI that depends solely upon only one of the factors. Such AI are a lot simpler and, in many cases, effective. However, they have not fulfilled the true requirements of an AI, because they are only programmed to respond to a limited input and are little more than basic algorithms.

### Learning AIs

AI which can take external stimulus and decide upon the best way to use it is called a learning AI. This type of computer intelligence is also commonly referred to as machine learning. A learning AI is able to learn off of its present and past experiences. One common way of making a learning AI is by using a neural network, which vaguely simulates an animal brain. Simple learning AI can be created on Scratch. However, more complex learning AI are extremely impractical to create on Scratch because of their complex code and data structure.

### Other AIs

Another type of AI is used in a remix of Agent White found here. In this remix, the AI picks a random path and follows it. It uses Math and future x and y positions based on the current position of a character which you control. Then it slowly moves toward that new position until it either reaches its destination or hits a wall. In this case, instead of Artificial Intelligence, it is more of Artificial Randomness because it never uses intelligence other than running into walls.

## Limitations of AI

One of the biggest limitations AI has been facing is speed. Scratch is a rather slow programming language; hence most AIs on Scratch are slow because their scripts are too long.

Complications also have been a major problem for AI as all AI programs are very large and complicated, thus the scripts may become long and too laggy to make without crashing Scratch. For example, a simple game of Tic-Tac-Toe with AI will have a script running into multiple pages due to many conditions in if blocks, and sometimes an attempt to speed it up will be made by making it Single Frame.

The complicated script also makes remixing a problem. Because of all this, most AI projects have no improvements, causing the AI to remain glitchy. AIs may make mistakes that are easily avoidable by users, and most mistakes like these are hilariously known as artificial stupidity.

## Common Uses

• 2 player (Computer vs Player) games
• Pathfinding
• Having a conversation with the user (commonly referred to as a chatbot)

## Example Projects

These projects have been using AI in the truest sense possible practically: