9
Các bài toán: Water jug, 8 puzzle, 8 queen, missionary and cannibal, map, tic toe tic Các thuật toán: hill (simple chọn better, steepest chọn best, anneal chọn best với xác suất e^(-x/kT), x là current- parent), dfs, bfs, best fs(ucs g(n) từ đỉnh tới n, greedy h(n) gần đúng từ n tới goal, a star = g(n) + h(n)), minimax (tính value các node lá trước, sau đó tính ngược lên trên dựa trên minmax, nốt gốc là max), planning. Blockworld Actions STACK(x, y): P: CLEAR(y) HOLDING(x) D: CLEAR(y) HOLDING(x) A: ARMEMPTY ON(x, y) UNSTACK(x, y): P: ON(x, y) CLEAR(x) ARMEMPTY D: ON(x, y) ARMEMPTY A: HOLDING(x) CLEAR(y) PICKUP(x): P: CLEAR(x) ONTABLE(x) ARMEMPTY D: ONTABLE(x) ARMEMPTY A: HOLDING(x) PUTDOWN(x): P: HOLDING(x) D: HOLDING(x) A: ONTABLE(x) ARMEMPTY

Giua Ky Tri Tue Nhan Tao

Embed Size (px)

Citation preview

Page 1: Giua Ky Tri Tue Nhan Tao

Các bài toán: Water jug, 8 puzzle, 8 queen, missionary and cannibal, map, tic toe ticCác thuật toán: hill (simple chọn better, steepest chọn best, anneal chọn best với xác suất e^(-x/kT), x là current- parent), dfs, bfs, best fs(ucs g(n) từ đỉnh tới n, greedy h(n) gần đúng từ n tới goal, a star= g(n) + h(n)), minimax (tính value các node lá trước, sau đó tính ngược lên trên dựa trên minmax,

nốt gốc là max), planning.BlockworldActionsSTACK(x, y):P: CLEAR(y) HOLDING(x)D: CLEAR(y) HOLDING(x)A: ARMEMPTY ON(x, y)UNSTACK(x, y):P: ON(x, y) CLEAR(x) ARMEMPTY D: ON(x, y) ARMEMPTYA: HOLDING(x) CLEAR(y)PICKUP(x):P: CLEAR(x) ONTABLE(x) ARMEMPTY D: ONTABLE(x) ARMEMPTYA: HOLDING(x)PUTDOWN(x):P: HOLDING(x)D: HOLDING(x)A: ONTABLE(x) ARMEMPTY

Page 2: Giua Ky Tri Tue Nhan Tao

Stack = goal, database = start. Phân rã goal và start.Thay thế từng goal nếu nó không nằm trong database bằng precondition + action cho tới khi stack rỗng.

Plan1. UNSTACK(B, A) 2. STACK(B, D) 3. PICKUP(C)4. STACK(C, A)Ví dụ 2:

Plan1. UNSTACK(C, A) 2. PUTDOWN(C) //3. PICKUP(A)//4. STACK(A, B)//5. UNSTACK(A, B)//6. PUTDOWN(A)7. PICKUP(B)8. STACK(B, C)9. PICKUP(A)

Page 3: Giua Ky Tri Tue Nhan Tao

10. STACK(A, B)

DFS:,Bucharest -> Urzicenl -> Vasiul -> Iasi -> Neamt ,Bucharest -> Urzicenl -> Hirsova -> Eforie ,Bucharest -> Pitesti -> Rimnicu Vilcea -> Sibiu -> Oradea -> Zerind -> Arad -> Timisoara,BFS: ,Bucharest -> Urzicenl ,Bucharest -> Pitesti,Bucharest -> Glurgiu ,Bucharest -> Fagaras ,Bucharest -> Urzicenl -> Vasiul ,Bucharest -> Urzicenl -> Hirsova ,Bucharest -> Pitesti -> Rimnicu Vilcea ,Bucharest -> Pitesti -> Craiova ,Bucharest -> Fagaras -> Sibiu ,Bucharest -> Urzicenl -> Vasiul -> Iasi ,Bucharest -> Urzicenl -> Hirsova -> Eforie ,Bucharest -> Pitesti -> Rimnicu Vilcea -> Sibiu ,Bucharest -> Pitesti -> Rimnicu Vilcea -> Craiova ,Bucharest -> Pitesti -> Craiova -> Rimnicu Vilcea ,Bucharest -> Pitesti -> Craiova -> Dobreta ,Bucharest -> Fagaras -> Sibiu -> Rimnicu Vilcea ,Bucharest -> Fagaras -> Sibiu -> Oradea ,Bucharest -> Fagaras -> Sibiu -> Arad ,Bucharest -> Urzicenl -> Vasiul -> Iasi -> Neamt ,Bucharest -> Pitesti -> Rimnicu Vilcea -> Sibiu -> Oradea ,Bucharest -> Pitesti -> Rimnicu Vilcea -> Sibiu -> Fagaras ,Bucharest -> Pitesti-> Rimnicu Vilcea -> Sibiu -> Arad,Bucharest -> Pitesti -> Rimnicu Vilcea -> Craiova -> Dobreta ,Bucharest -> Pitesti -> Craiova -> Rimnicu Vilcea -> Sibiu ,Bucharest -> Pitesti -> Craiova -> Dobreta -> Mehadia ,Bucharest -> Fagaras -> Sibiu -> Rimnicu Vilcea -> Pitesti ,Bucharest -> Fagaras -> Sibiu -> Rimnicu Vilcea -> Craiova ,Bucharest -> Fagaras -> Sibiu -> Oradea -> Zerind ,Bucharest -> Fagaras -> Sibiu -> Arad -> Zerind ,Bucharest -> Fagaras -> Sibiu -> Arad -> Timisoara

Page 4: Giua Ky Tri Tue Nhan Tao

State representation: a 9-digit series corresponding to current configuration of the board in the left-toright and top-to-bottom manner, 0 represents the blank. For example, the setting in Figure 2 can be represented as 540618732. Start state: 540618732 Goal state: 123804765 Operators: - Move the tile up: 123804765 # 123864705 - Move the tile down: 123804765 # 103824765 - Move the tile left: 123804765 # 123840765 - Move the tile right: 123804765 # 123084765 540618732 # {504618732; 548610732} b.

State representation: a 2-D array representing an arrangement of 8 queens, onein each column. For example: (O for blank, X for queen) XOOOOOOO OOOOXOOO OXOOOOOO OOOOOXOO OOXOOOOO OOOXOOOO OOOOOOXO OOOOOOOX Start state: Any state satisfies the state representation above. Goal state: An arrangement of 8 queens such that none of them is ableto capture any others. Operator: move any attacked queen to another square in the same column. XOOOOOOO XOOOOOOO OOOOXOOO OOOOXOOO OXOOOOOO OXOOOOOO OOOOOXOO OOOOOXOO OOXOOOOO OOXOOOOO OOOOOOOO OOOOOOXO OOOXOOXO OOOXOOOO OOOOOOOX OOOOOOOXc. Three cannibals and three missionaries must cross a river from the bank to the right one.

Page 5: Giua Ky Tri Tue Nhan Tao

Their boat can only hold two people. If the cannibals outnumber the missionaries, on either sideof the river, the missionaries are in trouble. How can all six get across the river? State representation: a triple (x,y,z) where xand yare respectively the numbers of missionaries and cannibals remaining in the left bank (0 <= x, y <= 3; x, y N); z is 0 if the boat is currently at the ∈left bank, otherwise z is 1. Start state: (3,3,0) Goal state: (0,0,1) Operators: - Two missionaries cross the river: (3,1,0) # (1,1,1) - One missionary crosses the river: (0,1,1) (1,1,0) - Two cannibals cross the river: (3,3,0) # (3,1,1) - One cannibal crosses the river: (3,1,1) # (3,2,0) - One missionary and one cannibal cross the river: (2,2,1) # (3,3,0)d.

State representation: Each state contains two information, current city, and visited cities. Ex: {Cralova, [Pitestl, Glurglu]} Start state: {Bucharest,[]} Goal state: {Bucharest,[all other cities]} Operators: Move from city X to city Y – new state will have current city is Y and Y will be add to visited cityWater jugState: (x, y)x = 0, 1, 2, 3, or 4 y = 0, 1, 2, 3Start state: (0, 0).Goal state: (2, n) for any n. 1. (x, y) → (4, y)if x < 42. (x, y) → (x, 3)if y < 33. (x, y) → (x − d, y)if x > 04. (x, y) → (x, y − d)if y > 05. (x, y) → (0, y)

Page 6: Giua Ky Tri Tue Nhan Tao

if x > 06. (x, y) → (x, 0)if y > 07. (x, y) → (4, y − (4 − x))if x + y ≥ 4, y > 08. (x, y) → (x − (3 − y), 3)if x + y ≥ 3, x > 09. (x, y) → (x + y, 0)if x + y ≤ 4, y > 010. (x, y) → (0, x + y)if x + y ≤ 3, x > 011. (0, 2) → (2, 0)12. (2, y) → (0, y)Tic toe tic: X win mang 1 diem, O win mang -1 diem, khac thi 0 diem

Page 7: Giua Ky Tri Tue Nhan Tao

Block world: DFS, BFS, Steepest, Best FS, Astar.

Page 8: Giua Ky Tri Tue Nhan Tao

Bên trái: tính số vị trí đứng sai (A sai 3, D sai 1, C sai 1, B sai 1), bên phải tính vị trí đứng sai so với

Page 9: Giua Ky Tri Tue Nhan Tao

bên dưới (2 đúng 2 sai).a. The 8-puzzle problem: • Is the problem decomposable? No • Can solution steps be ignored or undone? Can be undone • Is the universe predictable? Yes • Is a good solution absolute or relative? Absolute • Is the solution a state or a path? A path • What is the role of knowledge? Very little• Does the task require human-interaction? Nob. The 8-queens problem: • Is the problem decomposable? No • Can solution steps be ignored or undone? Can be undone • Is the universe predictable? Yes • Is a good solution absolute or relative? Absolute • Is the solution a state or a path? A state • What is the role of knowledge? Very little • Does the task require human-interaction? Noc. The missionaries and cannibals problem: • Is the problem decomposable? No • Can solution steps be ignored or undone? Can be undone• Is the universe predictable? Yes• Is a good solution absolute or relative? Absolute• Is the solution a state or a path? A path• What is the role of knowledge? Very little (just the rules for determining legal moves, constrain the search and speed up the execution of the program)• Does the task require human-interaction? Nod. Touring problemIs the problem decomposable? No • Can solution steps be ignored or undone? Can be undone • Is the universe predictable? Yes • Is a good solution absolute or relative? Absolute • Is the solution a state or a path? A path • What is the role of knowledge? Very little • Does the task require human-interaction? No