rayerlistic
Programmer
Write a Prolog program to drive a vehicle. You have the following facts to use as “data”
• F1: you are traveling below the speed limit. C1
• F2: you are traveling at the speed limit. C3
• F3: you are traveling above the speed limit C2
• F4: you are on a two-lane road C3
• F5: you are on a four-lane road C3
• F6: you see an intersection coming up C2
• F7: a car is less than 100 meters in front of you C2
• F8: the road changes from two-lane to four-lane shortly
• F9: the road will change from four-lane to two-lane shortly
• F10: the brake lights of the car in front of you are on C2
• F11: you are getting closer to the car in front of you C2
• F12: you are passing another car going in the same direction C4
Assume the only actions are
• C1: speed up p2
• C2: slow down P1
• C3: maintain speed
• C4: pass a car in front of you (or keep passing one you are passing)
Here are examples of what you want the program to do. (These would not make good rules – they are too specific)
• F2, F4, F6: slow down (C2)
• F2, F5, F8, F10: slow down (C2)
• F2, F5, F11: pass (C4)
• F1, F5: speed up (C1)
• F3, F4, F7: slow down (C4)
Write a Prolog program that can decide what to do for every possible combination of the facts. (Since there are 12 kinds of fact, you must handle 2^12 or 4096 different situations, but please note that some contradictory facts cannot all be true (or false) at the same time). Assume your program is called every second to decide what to do that second.
plz help me to fix it up~~
thanks~
• F1: you are traveling below the speed limit. C1
• F2: you are traveling at the speed limit. C3
• F3: you are traveling above the speed limit C2
• F4: you are on a two-lane road C3
• F5: you are on a four-lane road C3
• F6: you see an intersection coming up C2
• F7: a car is less than 100 meters in front of you C2
• F8: the road changes from two-lane to four-lane shortly
• F9: the road will change from four-lane to two-lane shortly
• F10: the brake lights of the car in front of you are on C2
• F11: you are getting closer to the car in front of you C2
• F12: you are passing another car going in the same direction C4
Assume the only actions are
• C1: speed up p2
• C2: slow down P1
• C3: maintain speed
• C4: pass a car in front of you (or keep passing one you are passing)
Here are examples of what you want the program to do. (These would not make good rules – they are too specific)
• F2, F4, F6: slow down (C2)
• F2, F5, F8, F10: slow down (C2)
• F2, F5, F11: pass (C4)
• F1, F5: speed up (C1)
• F3, F4, F7: slow down (C4)
Write a Prolog program that can decide what to do for every possible combination of the facts. (Since there are 12 kinds of fact, you must handle 2^12 or 4096 different situations, but please note that some contradictory facts cannot all be true (or false) at the same time). Assume your program is called every second to decide what to do that second.
plz help me to fix it up~~
thanks~