Do I post too much? lol

You have problems, and we're glad to hear them. Explain the problem, what you have tried, and where you got stuck.
Feel free to share a little info on yourself and the course.
Forum rules
Please respect your teacher's guidelines. Homework is a learning tool. If we just post answers, we aren't actually helping. When you post questions, be sure to show what you have tried or what you don't understand.

Do I post too much? lol

Postby g0blu324 » Tue May 15, 2012 4:04 pm

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?
g0blu324
 
Posts: 6
Joined: Sat May 12, 2012 2:16 pm

Return to Homework

Who is online

Users browsing this forum: No registered users and 4 guests

cron