Uploaded by omaralzoubi05

Assignments first half cp468 Winter 2023

advertisement
AI CP468 Assignments
1,2,3 and 4
Assignments 1 and 2 and 3 due date is Feb 20, 2023. at 11:00pm, details about the assignments will be
discussed during the lectures. Assignment 4 due date is Feb 27, 2023 at 11:00pm
Assignment 1 [10 marks] you should try to finish it by Jan 30, 2023. at 11:00 pm
As a wildfire rages through the grasslands, three lions and three wildebeest flee for their lives. To escape the
inferno, they must cross over to the left bank of a crocodile-infested river. The boat can carry up to two
animals at a time and it needs at least one lion or wildebeest on the boot to cross the river. lions can never
outnumber the wildebeest on either side of the river. If the lions ever outnumbered the wildebeest on either
side of the river, even for a moment, the lions would eat the wildebeest. Can you help them figure out how
to get across on the one raft available without losing any lives?
a) Define the States, Operators, Goal, and show all paths to the goal in the tree of search, (show all possible
solutions).
b) Solve the problem by writing a program in PROLOG.
c) Modify the problem assuming four lions and five wildebeest, is there a solution?
Assignment 2 [10 marks] try to finish it by Feb 6,2023 at 11:00pm
a) For the following 8-puzzle problem, define the state, Operators, Goal, Heuristic and show a path to
the goal in the tree of search after applying the Heuristic.
b) Write a program to solve the 8-puzzle problem:
3
8
1
assume that the initial state is:
2
7
4
5
6
3
2
1
and the goal stat is:
4
5
8
6
7
c) Come with a different initial state that has a solution and another initial state that does not have a
solution and explain your answer.
1
AI CP468 Assignments
1,2,3 and 4
Break Feb 20,21,22,23 and 24.
Assignment 3 [10 marks] try to finish it by Feb 20, 2023 at 11:00 pm
Write a program in PROLOG (you can use another language, however if you use Prolog you will get 1% bonus)
to solve the following maze problem.
Here is part of the file that you will consult:
mazeSize(5, 9).
barrier(1, 8).
barrier(2, 2).
which represents the following maze:
barrier(2, 4).
1
2 3 4
5
6
7
barrier(2, 5).
1
barrier(3, 4).
End1
2
1
1
1
barrier(3, 7).
barrier(3, 9).
3 begin
1
1
barrier(4, 4).
4
1
1
barrier(4, 7).
5
1
barrier(4, 9).
barrier(5, 2).
8
1
9
1
1
End2
Your task is to write a predicate solve (From, To, Path) which, given locations From and To, finds a Path going
from From to To. From and To are given as two element lists, and Path should be a list of two-element lists.
The first element of Path should be From, and the last element should be To. Moves can be made horizontally
or vertically, but not diagonally.
For example, solve([3,1], [2,6], [[3,1], [3,2], [3,3], [2,3], [1,3], [1,4], [1,5], [1,6], [2,6]]). This means; To move
from [3,1] to [2,6] a solution as a list is [[3,1], [3,2], [3,3], [2,3], [1,3], [1,4], [1,5], [1,6], [2,6]]).
There are many solutions, you do not have to come with the optimal solution.
Run your program for [3,1] to [2,6] and for [3,1] to [5,9] and include them in your report (take a screen shot).
Assignment 4 [20 marks] Will be posted and the due date is Feb 27, 2023 at 11:00 pm
2
Download