简体   繁体   English

PROLOG 自行车旅行任务,创建规则和查询

[英]PROLOG bike touring task, create rules and queries

I was given this task but I am struggling to formulate the appropriate rules in the correct format.我被赋予了这项任务,但我正在努力以正确的格式制定适当的规则。 I don't know the exact ways to use the less than/more than signs for this task (>, <, <= etc.)我不知道在此任务中使用小于/大于符号的确切方法(>、<、<= 等)

These are the facts and rules given:这些是给出的事实和规则:

tour(france, 49, 770).
tour(spain, 20, 150).
tour(germany, 26, 370).
tour(italy, 42, 330).
tour(belgium, 46, 540).

medium(germany).
medium(italy).

fitnesslevel(untrained).
fitnesslevel(good).
fitnesslevel(perfect).

fitness_higher(good, untrained).
fitness_higher(perfect, good).

more_fit(F1, F2) :- fitness_higher(F1, F2).
more_fit(F1, F2) :- fitness_higher(F1, F), more_fit(F, F2).

fitness(max, untrained).
fitness(lucy, perfect).

The following are the tasks I was given以下是我被分配的任务

1) Add rules for the following predicates: 1)为以下谓词添加规则:

  • easy(T): A tour T is easy, if it is shorter than 30 km and its maximum height is 150m. easy(T):一个旅游T很容易,如果它小于30公里,最大高度是150m。
  • hard(T): A tour T is hard, if its maximum height is above 450m. hard(T):如果T的最大高度在450m以上,则T是hard。

2) Add rules for this following predicate: suitable(T, P). 2)为以下谓词添加规则:适合(T,P)。

  • Easy Tours are suitable for all persons regardless of their fitnesslevel. Easy Tours 适合所有人,无论他们的健身水平如何。
  • Average Tours are suitable for all persons who are above an untrained fitnesslevel.平均旅游适合所有未经训练的健身水平以上的人。
  • Hard Tours are suitable only for persons with a perfect fitnesslevel. Hard Tours 仅适合具有完美健身水平的人。

3) Which is the correct query to find out which tours are suitable for Max and Lucy? 3) 找出适合 Max 和 Lucy 的旅行的正确查询是什么?

You write:你写:

I was given this task but I am struggling to formulate the appropriate rules in the correct format.我被赋予了这项任务,但我正在努力以正确的格式制定适当的规则。 I don't know the exact ways to use the less than/more than signs for this task (>, <, <= etc.)我不知道在此任务中使用小于/大于符号的确切方法(>、<、<= 等)

You should maybe start smaller.你也许应该从小一点开始。 Try to read the docs and understand how to use the comparisons for this task.尝试阅读文档并了解如何使用此任务的比较。 If there is something you don't understand, write a minimal code sample that we can also run.如果您有不明白的地方,请编写一个我们也可以运行的最小代码示例。 Show what you expect and what you get instead.展示你的期望和你得到的。 You could than ask how to fix it.你可以问如何解决它。

As it stands, your question is equivalent of posting your homework assignment and asking someone to work out a solution for you and post it here.就目前而言,您的问题相当于发布您的家庭作业并要求某人为您制定解决方案并将其发布在此处。 It works, sometimes.它有时会起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM