Requirements Engineering .NET issues with local machine and network share drives
Oct 08

We received our first task to be submitted till the 11th January 2008, please read it below:

Task: to develop a computer game called Wumpu’s world using Prolog. An hunter walks into the Wumpu’s world where there are a monster called Wumpu who can eat the hunter, pits that can trapped the hunter, and a heap of gold. By carefully playing this game, the hunter should avoid to be eaten by the Wumpu, avoid to fall into pits, try to pick up gold and try to explore the entire Wumpu’s world.

Now putting together the “world” is really straightforward:

1
2
3
4
5
6
7
8
9
10
11
location(hunter, r11). %start position, first row
location(breeze, r12).
location(hole, r13).
% second row
location(stench, r21).
location(glitter, r22).
location(breeze, r23).
% third row
location(wumpu, r31).
location(gold, r32).
location(hole, r33).

If we have all the fields, we can now establish the map:

1
2
nextto(r11, r12).
nextto(r11, r21).

where r11 is the start position and we have a 3×3 square so the fieldnames are r[row number][coloumn number].

Now we need to set the start position of the hunter which is:

1
here(r11).

I would like to mention one important thing. As we will move within our map we need to constantly update there here() function. As we declare here to have the value r11 it is a static declaration, therefore it cannot be updated. For example examine the following set of rules for the movement:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
% set up the movement between the locations
connect(X, Y) :- nextto(X, Y).
connect(X, Y) :- nextto(Y, X).
 
goto(Place) :-
can_go(Place),
move(Place),
look.
 
can_go(Place) :-
here(X),
connect(X, Place).
can_go(Place) :-
write('You can''t get there from here'),
nl,
fail.
 
move(Place) :-
retract(here(X)),
asserta(here(Place)).

Now if you’d try and run the following giving it the command goto(r12). would result in an error (No permission to modify static_procedure [procedure name]).

To avoid this the here procedure should be declared dynamic:

1
2
:- dynamic here/1.
here(r11).

Problem solved.

I will continue to post my updates on this assignment.

One Response to “Concepts of AI [Assignment 1]”

  1. Jean-Claude Says:

    just wanted to try and give your wumpus world a go and see how it works .. just started with prolog and im not sure about the queries for your version. if you could send me the queries to move about and shoot and so on, i would very much be grateful. thanks

Leave a Reply

Powered by WP Hashcash