This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

Do I post too much? lol

1 post · 2758 views

The map that my project deals with

http://www-personal.engin.umd.umich.edu ... robbie.txt
My functions that deal with my problem
(defun look (direction loc)
(cdr (assoc direction (choices loc))))

(defun ValidMove(direction loc)
(cond
((eql nil (look direction loc))nil)
(t t)))

(defun move(direction)
(cond
((validmove direction loc)(setq loc (look direction loc)))
(t '(Ouch! Robbie hit a wall.))))

__________________________________________________________________________________________

So here is what's going on. I made a "validmove" function to determine whether or not moving a direction from a location will lead to nowhere. Based on that, I made a move function to move to that location if that move can happen.

My problem: The "move" only works once at a time. If I do 2 move commands in a row, it says "Ouch! Robbie hit a wall." for any case. I'm guessing it has to do with the "(setq loc (look direction loc))) " in my move function, which makes sense. Everytime I comple the move function I need to do a "setq loc" to a room then do a move again. However, I do need loc to change once a move has been made to another room. So how can I fix this?