Simulation
Tic-tac-toe minds
Two small games about how AI decides. First, play a computer that looks a set number of moves ahead. Then write the rules for a cleaning robot and see how it scores them.
Kit
I'll be the referee. The computer is only as clever as how far it looks, and only as good as the rules it's given.

Step 1
Play against minimax
Minimax tries every move, then every reply, and so on, assuming both players play their best. The slider sets how many moves ahead it looks.
Also sees your next move, so it blocks you.
You are X. The computer is O. X goes first.
At this depth: 0 wins, 0 draws, 0 losses
Your turn

At depth 9 it sees every ending, so it never loses. At depth 1 it can't see your threats coming. Chess programs use the same idea, but they can't look all the way to the end, so they also learn to judge a position.
Step 2
Set the robot's reward
This robot does whatever earns it the most points in 30 steps, and it plans perfectly. It can move, suck up crumbs on the rug, tip its bag back out, and empty its bag into the bin. You choose what it gets points for.