prolog中角色的分离度

prolog中角色的分离度,prolog,Prolog,我有一个巨大的prolog演员数据库,例如 actor('adam_zweibel','the_story_of_us',1999,20). actor('alan_zweibel','north',1994,10). actor('alan_zweibel','the_story_of_us',1999,21). actor('darrell_zwerling','...and_justice_for_all',1979,32). actor('darrell_zwerling','capri

我有一个巨大的prolog演员数据库,例如

actor('adam_zweibel','the_story_of_us',1999,20).
actor('alan_zweibel','north',1994,10).
actor('alan_zweibel','the_story_of_us',1999,21).
actor('darrell_zwerling','...and_justice_for_all',1979,32).
actor('darrell_zwerling','capricorn_one',1978,21).
actor('darrell_zwerling','chinatown',1974,6).
actor('darrell_zwerling','doc_savage:_the_man_of_bronze',1975,6).
actor('darrell_zwerling','high_anxiety',1978,15).
actor('darrell_zwerling','joe_versus_the_volcano',1990,15).
actor('darrell_zwerling','the_main_event',1979,45).
actor('darrell_zwerling','la_mortadella',1971,0).
actor('darrell_zwerling','the_secret_life_of_an_american_wife',1968,0).
actor('darrell_zwerling','wild_at_heart',1990,40).
actor('michael_zwiener','big_bully',1996,15).
我需要实现这样的东西

?- within_degree('johnny_winter', 'matthew_witherly', 3, X).
X = [sgt_peppers_lonely_hearts_club_band, keith_carradine, crisscross, paul_calderon, bait] ;
X = [sgt_peppers_lonely_hearts_club_band, morgan_farley, heaven_can_wait, larry_block, bait] ;
X = [sgt_peppers_lonely_hearts_club_band, 'steve_martin_(i)', bowfinger, jamie_kennedy, bait] ;
X = [sgt_peppers_lonely_hearts_club_band, 'steve_martin_(i)', my_blue_heaven, larry_block, bait].
类似于构建一个演员树,它有两个结尾Actor1,Actor2。
我不知道如何开始,请有人帮我或抛出一个如何处理这项任务的想法。谢谢

这里有一个完成任务的想法

首先,只需检测它们是否连接:

  • 如果Actor1和Actor2在同一部电影中,则它们以度1连接
  • 或者,如果Actor1通过阶数N-1连接到Actor3,Actor3通过阶数1连接到Actor2,则它们通过阶数N连接
尝试编写一个连接到(+Actor1,+Actor2,+Degree)的谓词来实现它。如果两个参与者通过度连接,则该谓词将返回true;如果没有连接,则返回false

下一步是添加您想要的结果列表,即

  • Actor1和Actor2通过[M]列表以度1连接
  • Actor1和Actor2通过附加的列表以度N连接:Actor1到Actor3的步骤列表、Actor3和Actor3到Actor2的步骤列表

如果您使用
代替空格,则无需使用引号!两个演员不应该有必然的联系。例如,
?-withindegree('jack_palance','mos_def',1,X)。错误。
?-在度内('jack\u palance','mos\u def',2,X)。X=[che,‘benjamin_bratt_(i)’,樵夫];X=[“城市滑头”ii:“柯利的传奇”,比尔·麦金尼,马洛在哪里];X=[太阳危机,'彼得·博伊尔(我)'怪兽球]。
我不确定我是否理解你。如果他们没有联系,我上面的回答会给你错误的答案。你能澄清一下吗?