📘 CodingMarble Learn

AI Skills: Computer Vision, Language, Reasoning and Game Playing

AI has four classic skills. Vision turns pixels into edges, shapes and labels. Language processing cuts text into tokens, tags words and finds meaning. Reasoning draws new facts from facts and rules, but only valid steps are safe. Game playing builds a tree of moves and scores it from the bottom up (minimax) to pick the best move.

🎬 Step-by-step story

  1. AI has four skills: seeing, reading, reasoning and playing. Each tower has its own input and output. Tap a tower to read them.
  2. Vision: the camera sees a tree, a house and a ball. The computer finds edges first, then names the shapes with a confidence score. Tap Photo, Edges, Labels.
  3. Language: a sentence is cut into words, each word gets a tag like noun or verb, then the meaning is found. Tap the three buttons in order.
  4. Reasoning: from a fact and a rule the computer draws a new fact. One case is safe. The other case looks the same but is not safe.
  5. Games: take 1 or 2 sticks and the last stick wins. The tree lists every move for 4 sticks. Score it from the bottom up to find the best move.
  6. Your turn. 7 sticks, you go first. The computer plays perfectly. Find the winning first move.

Tip: drag the 3D scene to turn it. Use two fingers to zoom.

🤔 Common doubts, cleared

Does the computer know it is a tree?

It matches shapes and edges to patterns it learned from many labelled pictures and gives a confidence score, such as 97%.

Why is language harder than vision?

One word can have many meanings and the same idea can be said in many ways. Context decides.

Why can't we run the rule backwards?

Because other things can also wet the road. The rule goes only from rain to wet. Try the second case in the 3D: it says NOT SURE.

Why are multiples of 3 losing positions?

From a multiple of 3, any move (1 or 2) leaves a number that is not a multiple of 3, and the other player can bring it back to a multiple of 3.

Can I beat the computer in the stick game?

Yes, if you take 1 on your first move so that 6 are left. Then always leave a multiple of 3. If you slip once, the computer takes over.

How do real chess programs cope with so many moves?

They look only a few moves ahead, score the board, and skip hopeless branches. The stick tree is small, so we could draw all of it.

Computer vision

Computer vision helps a computer understand pictures and video. A picture is a grid of pixel numbers (full details in the lesson on computer vision). The usual chain is:

  1. Pixels: numbers for brightness or colour.
  2. Edges and features: places where the numbers jump, such as the outline of a tree.
  3. Shapes and objects: a model matches patterns and decides "tree" or "house".
  4. Labels: the answer with a confidence score, such as "tree 97%".

Main jobs: classification (what is it?), detection (where is it?) and segmentation (which pixels?). Uses: face unlock, number-plate reading, medical scans, crop checks, self-driving cars. Modern systems learn the patterns from many labelled photos using neural networks.

Language processing (NLP)

Natural language processing (NLP) lets a computer work with human language. People say the same thing in many ways, so this is hard. The steps are:

  1. Tokenisation: cut the sentence into pieces called tokens. "I like cold tea" becomes 4 tokens.
  2. Tagging (parts of speech): mark each word as noun, verb, adjective and so on.
  3. Parsing: find how the words connect (who does what).
  4. Meaning: find what the sentence says, its feeling (sentiment, here positive) or its answer.

Uses: translation, search, voice assistants, spelling and grammar help, spam filters, chatbots. Hard parts: one word can have many meanings ("bank"), sarcasm, and mixing languages like Hinglish. Modern systems learn language patterns from huge amounts of text.

Reasoning

Reasoning means drawing a new fact that must follow from known facts and rules. This is deduction.

Rule: IF it rains THEN the road is wet. Fact: it rains. Conclusion: the road is wet. This is valid: it cannot fail.

Now the other way. Rule: IF it rains THEN the road is wet. Fact: the road is wet. Can we say it rained? No. A water tanker could have wet the road. This mistake is called affirming the consequent. A reasoning system must tell valid steps from risky ones.

Other ideas: planning (choose a list of steps to reach a goal), reasoning under uncertainty (using probability, as in Bayes) and common-sense reasoning, which is still hard for computers. Uses: rule-based helpers, schedule makers, puzzle solvers, checking that a design follows rules.

Game playing AI

Games are clear tests for AI because the rules are fixed and the winner is known. A program draws a game tree: each ball is a position, each arrow is a move.

Stick game: take 1 or 2 sticks; whoever takes the last stick wins. Look at the positions from the bottom:

This bottom-up scoring is minimax: you pick the move that is best for you, assuming the other player also picks the move that is best for them. With 1 stick you win, with 2 you win (take 2), with 3 you lose (leave 1 or 2), with 4 you win (leave 3). Every multiple of 3 is a losing position, so the winner always leaves a multiple of 3.

Big games like chess have too many moves to draw the whole tree. So programs look only a few moves ahead, use a score for the board (a heuristic), and skip hopeless branches (pruning). Modern programs also learn from millions of practice games. Deep Blue beat the chess champion Garry Kasparov in 1997, and AlphaGo beat the Go champion Lee Sedol in 2016.

Try it

Play the stick game with a friend using 7 coins. Take turns taking 1 or 2 coins; whoever takes the last coin wins. Can you always leave your friend a multiple of 3? Then play against the computer in step 6 of the 3D. Next, test the rain rule: write one more rule of your own, such as "IF I eat sweets THEN I feel happy", and check which two conclusions are valid and which are risky.

Key formulas and definitions

Worked examples

1. List the four NLP steps for "I like cold tea" and say what each gives.

Tokenise: I | like | cold | tea (4 tokens). Tag: pronoun, verb, adjective, noun. Parse: "I" does "like" to "cold tea". Meaning: the speaker enjoys tea, a positive feeling.

2. Rule: IF the battery is flat THEN the torch is off. Fact: the torch is off. Is it certain that the battery is flat?

No. The bulb could be broken or the switch off. This is a risky step. Only "battery flat, so torch off" is valid.

3. Stick game (take 1 or 2, last stick wins). Is 5 sticks winning or losing for the player to move?

Take 2 to leave 3, a multiple of 3. The other player is now in a losing position. So 5 is winning.

4. Stick game with 9 sticks, you move first. Who wins with best play?

9 is a multiple of 3, so it is a losing position for the mover. The second player wins by always leaving a multiple of 3 (if you take 1, they take 2; if you take 2, they take 1).

5. A vision system outputs "ball 91%". What do the three words tell you?

The label (ball), the confidence (91%) and that this is classification. It is 91% sure, not 100% sure.

Common mistakes

Practice quiz

1. The usual first step in NLP is:
2. Which gives "where is the object" in an image?
3. IF rain THEN wet road. The road is wet. What is certain?
4. In the take-1-or-2 game, a losing position for the mover has sticks equal to:
5. Minimax scores a game tree from:

Practice: answer these yourself

Type or choose your answer, then press Check. Use a hint if you are stuck; the full solution appears after you answer.

Frequently asked questions

What is the difference between computer vision and NLP?

Vision works on pictures and video (pixels). NLP works on human language (words and sentences).

What is minimax in simple words?

A way to pick a move by looking at all replies. You choose the best move for you, assuming the other player chooses the best reply for them.

Where is this topic taught?

It appears in the introduction to artificial intelligence in senior-secondary information technology and computer science courses in several countries.

Where this is taught

China高三Sel.4 Introduction to AI

Learn first

Learn next

Related lessons

All Computer Science lessons