بحث
مُقدَّم
6:33
الذكاء الاصطناعي والتعلم الآلي
This course covers the classical core of artificial intelligence, honestly measured. The first three units are the spine: search, logical reasoning and…
سرد باللغة الإنجليزية · ترجمة نصية بالإنجليزية و中文 يمكنك التبديل بينهما
في هذا الدرس
| English | المعنى |
|---|---|
| search tree/sɜːtʃ triː/ | شجرة البحث |
| Uninformed search/ˌʌnɪnˈfɔːmd sɜːtʃ/ | search that uses no information about how close a state is to the goal |
| Informed search/ɪnˈfɔːmd sɜːtʃ/ | search that uses a heuristic estimate of the distance to the goal |
| heuristic/hjuːˈrɪstɪk/ | الدالة التقريبية |
| A-star search/ə stɑː sɜːtʃ/ | best-first search on f = g + h: the cost so far plus the estimated cost to the goal |
| admissible/ədˈmɪsɪbl/ | (of a heuristic) never overestimating the true cost to the goal |
| frontier/ˈfrʌntɪə/ | |
| Manhattan distance/mænˈhætn ˈdɪstəns/ | the distance on a grid moving only horizontally and vertically: |Δx| + |Δy| |
| consistent/kənˈsɪstənt/ | (of a heuristic) never decreasing by more than the step cost along any edge |
| Iterative deepening/ˈɪtərətɪv ˈdiːpənɪŋ/ | repeated depth-limited search with a growing limit |
| minimax/ˈmɪnɪmæks/ | A game-search method that chooses the move with the best worst-case score, assuming an opponent who tries to minimise that score. |
| alpha–beta pruning/ˈælfə ˈbiːtə ˈpruːnɪŋ/ | skipping game-tree branches that cannot change the minimax result |
The tree and the estimate
- In a search tree 搜索树, nodes are states and edges are moves. Uninformed search 无信息搜索 expands nodes without any hint: breadth-first search (BFS) finds the shortest path when all steps cost the same; depth-first search (DFS) saves memory.
- Informed search 有信息搜索 uses a heuristic 启发函数 $h(n)$, an estimate of the cost still to go. A-star search A星搜索 (A*) always expands the node with the smallest $f = g + h$, where $g$ is the cost so far.

A* chooses the node minimising —
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Cost so far plus admissible estimate to go.
The course route, exactly
- Course graph: D→A (4), D→B (2), A→C (3), B→C (1), C→G (5), B→G (9), with $h = \{A{:}8, B{:}6, C{:}5, G{:}0\}$. A* takes D (0), B (8), C (8), G (8) off the queue: the best cost is 8, by D→B→C→G, after four expansions. BFS would visit every node.
- The key condition is that $h$ is admissible 可采纳的: $h(n) \le h^*(n)$, the true remaining cost. Then the first time the goal comes off the queue it is optimal, because its $f$ is a lower bound that no open node can beat.
On the course graph, A* expands — nodes before the goal
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Pops D, B, C, then G at cost 8 - four expansions.
On the course graph, put A* pops from D in order until it stops.
الصعوبة 3/5 · 200 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
C is reached through B at cost $3$, so it is discovered only after B pops; G through C costs $8$ and pops before A ($f = 4 + 8 = 12$) or G through B ($11$).
When the heuristic lies
- Overestimate $h(C) = 12$: C now has $f = 3 + 12 = 15$, while the goal reached through B has $11$. A* takes the goal at cost 11 and stops: not optimal ($11 > 8$).
- Complete (it finds a solution) is not the same as optimal (it finds the best one). BFS's frontier 搜索前沿 needs $O(b^d)$ memory.
Overestimating h(C) to 12 makes A* return cost —
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
C carries f=15 vs Goal 11: pops Goal early - trusts a lie.
Where good heuristics come from
- Relax the problem: drop a rule and solve the easier version exactly. On a grid with walls, ignore the walls, and the Manhattan distance 曼哈顿距离 $|\Delta x| + |\Delta y|$ is admissible.
- In the 8-puzzle, "misplaced tiles" and "total Manhattan distance" are both admissible, and Manhattan dominates: it is never smaller, so A* expands fewer nodes.
- A consistent 一致的 heuristic obeys $h(n) \le c(n, n') + h(n')$ on every edge. The course values pass: $h(B) = 6 \le 1 + h(C) = 6$ and $h(A) = 8 \le 3 + 5$. With a consistent heuristic, A* never has to reopen a node it has already expanded.
On an open grid, what is the Manhattan distance from (1, 1) to (4, 5)?
الصعوبة 2/5 · 140 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
|4 - 1| + |5 - 1| = 3 + 4 = 7.
Two admissible heuristics, h1 and h2, with h2(n) >= h1(n) everywhere. A* with h2 —
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
A larger admissible estimate is closer to the truth, so fewer nodes look promising.
Iterative deepening
- Iterative deepening 迭代加深 runs depth-first search to depth 1, then 2, then 3, until it finds the goal. Like BFS it finds the shallowest goal, but like DFS it needs only $O(bd)$ memory.
- The repeated work is cheap, because most nodes are on the deepest level. With branching factor $b = 10$ the extra work is about $b/(b - 1) - 1 \approx \mathbf{11\%}$.
Alpha–beta pruning can change the value minimax returns.
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
It skips only branches that cannot affect the result.
Worked example: minimax with pruning
- In a game tree, minimax 极小化极大 assumes both players play their best. MAX chooses between two MIN nodes. The first has leaves 3, 12 and 8, so MIN gives it 3. The second's first leaf is 2, so MIN will give it at most 2.
- MAX already has 3, so the second node's other leaves cannot matter: alpha–beta pruning 阿尔法贝塔剪枝 skips them. The root value is $\mathbf{3}$, exactly what full minimax gives, found by reading fewer leaves.
MAX over two MIN nodes with leaves (3, 12, 8) and (2, 15, 1): root value?
الصعوبة 2/5 · 140 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
MIN gives 3 and 1; MAX picks 3.
In that tree, searched left to right, how many leaves does alpha–beta skip?
الصعوبة 2/5 · 140 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
After the leaf 2, the second MIN node is at most 2 < 3, so 15 and 1 are skipped.
Marks that slip away
- An overestimating heuristic 启发函数. With $h(C) = 12$, A* stops at the goal through B at cost $11$ and misses the cost-$8$ route.
- Complete as optimal. Finding a solution is not finding the best one.
- Forgetting BFS's memory. Its frontier grows as $O(b^d)$, so it runs out of memory long before it runs out of time.
Recap
| Search | Takes next | Best route? |
|---|---|---|
| BFS | the shallowest node (queue) | yes, if every step costs the same |
| DFS | the deepest node (stack) | no, but it uses little memory |
| A* | the lowest $f = g + h$ | yes, if $h$ is admissible 可采纳的 |
- Course route: cost $8$ via D, B, C, G in four expansions.
- An admissible heuristic ($h \le h^*$) keeps A* optimal; an overestimate returned $11$.
ما المشكلة؟ لا يرى ذلك سوى فريق الموقع.