CPSC 625-600 Read-Only Bulletin Board

Last modified:

This page will have all relevant email transactions with the students regarding the AI course, so that everyone has equal information regarding the course material.

Newest transactions will be posted on the top. Regularly view this page to see what's going on between other students and the instructor.

All sensitive material such as your name, email address, etc. will be removed, and also any part of code that is not relevant to the discussion will not be uploaded here.

You may also take a peek at the Undergraduate AI board.


***************************************************************************
Wed Nov 13 11:42:32 CST 2002

[Q] I am still confused. What are the important rules?

[A]
	1. in a unifier {v/t} v should always be a variable, nothing
	   else. 

	2. in a unifier {v/t}, t should not contain the variable v.

	3. in summary, in a unifier (or substitution), every variable
	   should be able to be substituted with the given term 
	   simultaneously!

	4. See the unification algorithm slide (slide17)

	5. Try to follow through the unification algorithm one step at a
	   time.

****************************************************************************
Tue Nov 12 18:12:11 CST 2002

[Q] I am confused about substitution and unification. What do I need 
    to be careful about?

[A] There are several things. Let's say x, y, z are variables,
    a, b, c are constants, and f, g, h are functions.

	1. You can only replace a variable with a term (term can be
	   a constant, variable, or a function).
	   So, 
		{x/a} {x/f(y)} {x/f(g(a))} are valid substitutions, while
		{f(a)/x} {a/f(x)} {a/f(a)} are invalid.

	2. When unifying, you need to find a disagreement set
	   containing variable v and term t where t does not
	   contain the variable v!

	3. In a unifier, if you have 

		{v1/t1, v2/t2, v3/t3, ... }

	   all the v's should be different.
	   

****************************************************************************

Tue Nov 12 18:17:38 CST 2002

[Q] I got P(f(g(x))) and P(f(g(a))). Isn't the disagreement
    set { f(g(x)), f(g(a)) }?
	
[A] No. Since it is the same up to P(f(g(, your disagreement set is 
	{x, a}. Since you have a variable and a term, you can make
	a substitition {x/a} out of it.




****************************************************************************
Sun Oct 13 22:12:49 CDT 2002

[Q] What is Manhattan distance?

[A] Think of the tiles being on a Cartesian coordinate. 

    Let's say tile i's current location is (x_i,y_i), and 
    the target location is (x_i',y_i'). The manhattan distance 
    for this tile is:

	MD_i = abs(x_i-x_i')+abs(y_i-y_i').

    The total manhattan distance is:

	_8_
	\
	/__  MD_i
        i=0
 
     where 0 is the blank tile. See the lecture slide.

****************************************************************************
Sun Oct 13 22:10:56 CDT 2002

[Q] I know how to calculate h(n), but how do I calculate g(n)?

[A] Basically, g(n) is the same as the "depth" field in the current
    node n:

	((1 2 3 ...)
		5
		10		; this is your g(n)
		(UP LEFT ...)
	)

****************************************************************************
Sun Oct 13 22:02:52 CDT 2002

[Q] DFS and BFS easily cause stack-overflow. Is this normal, or is it
    a bug in my code?

[A] DFS may cause stack overflow for even the simplest problem. BFS
    may also stack overflow easily, so, yes, it is normal.
    Try the simplest possible problems (1 place moved from the goal,
    2 place moved from the goal, etc.) on your basic search methods.
    If they work, you're good. If they don't, you need to debug your code.

****************************************************************************
Sun Oct  6 14:32:17 CDT 2002

[Q]
> I have a question on how to pass the Queueing Function to the General
> Search algorithm, e.g. (defun genSearch (problem qFn)
>                                       ...
>                        (setf node-list (qFn (expand node) node-list))
>                      )

[A] Look at this example and try modifying it:

>(defun applyfun (x fn)
    (funcall fn x))
APPLYFUN

>(applyfun '10 '-)
-10

>



Yoonsuck Choe
choe@tamu.edu


****************************************************************************
Sun Oct  6 00:01:31 CDT 2002

[Q] What is (myappend ... ) for?

[A] Some functions in the skeleton files are extras. You may or may not
    use these functions, i.e. they are not madatory.

****************************************************************************
Sat Oct  5 23:46:23 CDT 2002

[Q] The use of DUPE
	I am a student from CPSC625. I would like to know in what condition will
	duplicated states occur? Because I don't quite understand the function
	DUPE you wrote, and when to use it. Thanks for your help!

[A]
	Suppose you are in state s1. When you move up, you get to state s2.
	Now when you move down again, you will go back to state s1, which is
	a duplicate state.

	The function dupe supposes that you are keeping track of all unique
	nodes generated so far.

	node-list

		( ((1 2 3 ...) 10 2 (UP LEFT))
		  ((2 4 2 ...) 9 3 (LEFT DOWN UP))
		  ...
		  ((2 4 2 ...) 9 3 (LEFT)) )

	state

		(2 4 2 ...)

	Run dupe like this:

		(dupe '(2 4 2 ...) expanded-node-list)

	It will return T if it exists in the expanded-node-list.
  	Note that the expanded-node-list is different from the
	familiar node-list in your search function.


****************************************************************************

Sat Oct  5 15:24:00 CDT 2002

[Q] Why does the following code cause an error? It says "(setq x y)" is
    not a function.

	(
		(setq x y)
		(setq z (* x y))
	)

[A] In Lisp, '(' and ')' CANNOT be used to define a block as in C/C++, 
    although the above may look like the one below:

	{
		x = y;
		z = x * y;
	}

    The way Lisp interprets the original code is

	((setq x y)      (setq z (* x y))
         ----------      ---------------
         funciton name   argument(s)

    and that's why it gave you the error.

    To achieve what was intended, you should use (progn ...):


	(progn
		(setq x y)
		(setq z (* x y))
	)

    The function (progn arg1 arg2 .... argn) evaluates arg1, arg2, in
    sequence, and finally returns the result returned when evaluating argn.

    For example, the above example can be used in the following way:


	(if (> x y)

	    	; true case
		(progn
			(setq x y)
			(setq z (* x y))
		)

		; false case
		(progn
			(setq x y)
			(setq z (+ x y))
		)

	)
	

****************************************************************************
Thu Sep 19 16:06:08 CDT 2002

[Q] Can I use eval without recursion to write (deriv-val ...)?

[A] No. You need to use recursion. Otherwise, it is trivial: for example,

	(setq expr '(* x 10))
	(setq x 10)
	(eval expr)

    However, this does not cover all the cases: it would not work 
    because you don't know which variable was used in the initial expression.
    For example, the above code will not be able to deal with the following
    case, where the variable is 'y.

	(deriv-val '(* (* y y) 10) 'y 5)

    There is a way out, but you are NOT allowed to do this.
    For example, consider the following sequence of expressions:

>(setq var 'x)			

X

>(setq val 10)

10

>(setq expr '(* x 10))

(* X 10)

>(eval (list 'setq var val))

10

>(eval expr)

100

>

****************************************************************************
Wed Sep 18 18:22:43 CDT 2002

[Q] How do I detect the parenthesis character '(' or ')'? I want to
    parse the expression and replace the variable with a number.
    This is about (deriv-val ...). 

[A] You don't want to do that, i.e. parse the expression as a string.
    What you want to do is, instead, check whether some component of
    the expression is a list or an atom.

    Suppose your (deriv ....) returned (+ x (* x x)).
    The returned list contains an atom '+, another atom 'x, and
    a list '(* x x). So, you can check how to treat the subexpressions
    by checking if they are an (atom ...) or a (listp ....).

    A very simple recursion will do the job.

****************************************************************************
Wed Sep 18 14:32:52 CDT 2002

[Q] Why does my (ZEROP ...) result in an error like "X is not a NUMBER"?

[A] It's because ZEROP assumes that the argument is a number. If you want
    to check if an unknown argument is zero, do

	(setq x 10)

	...

	(and (numberp x) (zerop x))

    For example, 

	(setq x 'y)

	...

	(zerop x)
 
    will cause an error, but

	(and (numberp x) (zerop x)) 

    will accomplish the task.

****************************************************************************

Date: Thu, 12 Sep 2002 13:02:58 -0500 (CDT)

> Dr. Choe, I actually have a couple of questions to ask you regarding the
> homework:
>
> 1. What do you mean by "deriv (with basic simplification)" in the grading
> criteria section? Do we have to simplify the DERIV and DERIVPLUS
> funtions on the lecture notes even further? It's 40% of the total grade,
> so I want to be sure what you mean by that.

	You're good if you get splus, sminus, smult, etc. to work
	in the simplest cases.

	Deriv with simplification does not mean that you have to
	write shorter code. It just means that you have to incorporate
	splus, etc. into deriv (and derivplus, etc.).

> 2. For this homework, do we assume that we are dealing only with first
> level polynomial? (So the code can only handle x to the power 1, and
> not x to the power ) Or you want the code to be able to
> handle x to the power of  fractions>?

	You can go arbitrarily high:

	(* (* x x) x)		: x^3

	(* (* x (* x x)) x)	: x^4

	No, you don't have to deal with fractional powers.