Prolog query exercise -


These are the sections given to me

  beats (rock, scissors). Beats (scissors, paper) beats (paper, rock) Better (war, scissors) Better (lights, warfare) Better (boulder, rock) Better (Adamantium, Boulder) Better (Plyaside, Paper) Better (Nanomes, Palsides) Uses (valvairin, adamantium) (wader, lightabre) use (conan, war) usage (Richard, Rock) Win (X, Y): - Beats (X, Y) Win (X, Y): - Better (X, Y) Win (X, Y): - Better (X, 'Undersco Year), beats ( "underscore" Here, y). Win (X, Y): - Better (X, A), Better (Y, B), Win (A, B) Win (X, Y): - Uses (X, Y), Uses (X, Y), Uses (Y, B),!, Win (A, B) Play (X, Y, X): - Win (X, Y) Play (X, Y, Y): - Win (Y, X).   

The question is asking what will I get from

  - win (x, nanomes).   

The answer should be X = lightsabre . But why do not I really get it?

Can anyone explain this?

There are several ways to try to understand this particular query. On one side, the goal in your program is to add false , as if you still get the same answer. The program is special by adding false . If it still gets the same answer, then we know that a responsible part is in the field of view.

  beats (rock, scissors):  false   . Beats (scissors, paper)  beats (paper, rock): -  false  . Better (war, scissors) better (light, war)  better (boulder, rock): -  false    Better (Adamantium, Boulder): -  False  . Better (Plysides, Papers) Better (Nanomes, Palsede) Wins (X, Y): - Beats (X, Y)  WIN (X, Y): -  False , Better (X, Y) .  WIN (X, Y): -  False , Better (X, 'underscores here'), beats ('underscores here,' y) . Win (X, Y): - Better (X, A), Better (Y, B), Win (A, B) ? - Wins (lights, nanomes)  

So you have two chains:

  Nanomash -> Polyness - & gt; Paper `lightsshrey - & gt; Battle - & gt; Scissors   

and finally scissors beet paper .

Of course I agree with this kind of argument, though.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -