trí tuệ nhân tạo cao hoàng trứ lab2 state space search sinhvienzone com

2 37 0
trí tuệ nhân tạo cao hoàng trứ lab2 state space search sinhvienzone com

Đang tải... (xem toàn văn)

Thông tin tài liệu

Artificial Intelligence (2014-2015) Lab STATE SPACE SEARCH OBJECTIVE The objectives of Lab are (1) to introduce the Prolog’s powerful concept of compound term; and (2) to the complete solution of state search space illustrated by the means of the 8-puzzle problem (3) and to practice your java programming skills om EXPERIMENT ne C 2.1 Compound terms Compound term is a Prolog concept used to describe combined and structured concepts In Listing 1, what we want to imply in the first fact is “MU is a football club whose jersey color is red” and the second “Chelsea is yet another football club whose jersey color is blue.” red(club(mu)) blue(club(chelsea)) nh Who is the best player? Vi bestplayer(mu,ronaldo) bestplayer(chelsea,terry) en Zo Here we have club(mu) and club(chelsea) are some compound terms used by the predicates red and blue respectively Unification and resolution, the two great things coining the power of Prolog, can be applied on the compound terms as well as if on atoms Listing introduces some attempts to find the best player in red and blue jerseys Si bestredplayer(X):-red(club(Y)),bestplayer(Y,X) bestblueplayer(X):-blue(club(Y)),bestplayer(Y,X) Try the following queries and observe the results bestredplayer(X) bestblueplayer(X) 2.2 Search solution for the 8-puzzle problem OK, now we try to solve the first basic toy AI problem, the 8-puzzle one No, “we” does not include you, but… we only Your job is to take into consideration the search.pl and setting.pl files All are done in there The principle is to use two stacks (or queues, it depends) named open and closed in the working memory of Prolog Then, in search.pl, we have implemented the following things: - path: it retracts one state out of open, put all of children of the state into closed If open is empty but the goal is still not reached, it will display the failure message Otherwise, the goal is displayed SinhVienZone.com https://fb.com/sinhvienzonevn - checkgoal: It checks if the first state in open is the goal or not - get_children: It generates all of children of the parameter in order to put them into open - addToOpen: It put a state to the open Depending on the algorithm used, the corresponding predicate is invoked - move: It moves from the current state to another, provided that neither open and closed are not empty - go: the first predicate to be run In file setting.pl, we define problem-specified features, which include the following: C om - The KB of possible legal moves For example: move(state([X1,X2,X3,X4,0,X6,X7,X8,X9]), state([X1,0,X3,X4,X2,X6,X7,X8,X9])) means that we can move the blank up in the current state (0 represents the blank tile) - algorithm(dfs): It indicates the search algorithm One may want replace dfs by brfs - mywrite: Write out a state - go_p and isGoal: They define the initial state and the goal respectively Zo ne EXERCISES 3.1 Try to run the 8-puzzle program successfully Change the first initial and goal and observe the results 3.2 Modify the file setting.pl to solve the water-jug problem (you should not touch the search.pl file) 3.3 Use Java to solve the water-jug problem End Si nh Vi en SUBMISSIONS There is no writing submission required Students run their solutions at their workstations and answer questions from instructors to get marked SinhVienZone.com https://fb.com/sinhvienzonevn ... possible legal moves For example: move (state( [X1,X2,X3,X4,0,X6,X7,X8,X9]), state( [X1,0,X3,X4,X2,X6,X7,X8,X9])) means that we can move the blank up in the current state (0 represents the blank tile)... - algorithm(dfs): It indicates the search algorithm One may want replace dfs by brfs - mywrite: Write out a state - go_p and isGoal: They define the initial state and the goal respectively Zo... It checks if the first state in open is the goal or not - get_children: It generates all of children of the parameter in order to put them into open - addToOpen: It put a state to the open Depending

Ngày đăng: 30/01/2020, 23:11

Tài liệu cùng người dùng

Tài liệu liên quan