Showing posts with label example. Show all posts
Showing posts with label example. Show all posts

Sunday, 18 January 2009

First Program

Rules:
In order to work, people must be full and delighted.
work(X) :- delighted(X), full(X).
In order to be full, people must eat something.
full(X) :- ate(X).
In order to be delighted, people must sleep and have fun.
delighted(X) :- slept(X), fun(X).
Facts:
Mustafa ate.
ate(mustafa).
Mustafa slept.
slept(mustafa).
Mustafa had fun.
fun(mustafa).
Query:
Can Mustafa work?




Facts:
eats(fred,oranges).
eats(tony,apple).
eats(john,apple).
Queries:
?- eats(fred,oranges). /* yes
?- eats(john,apple). /*yes
?- eats(mike,apple). /*no

Example 3 : 8-Tiles Puzzle

States? - Description which specifies the location of each of 8 tiles (simple 3x3 array). For efficiency, it is useful to include the location of the blank
Initial state? - Any state can be initial
Moves?
move the blank up
move the blank down
move the blank left
move the blank right
Final state? - Any state can be final
Arc costs? – 1
16! possible states