Artificial
Intelligence

Fall 2015
course
navigation

Tue Sep 8

chapter 2 & 3 : agents, search, and the vacuum world

Terminology from chap 2
Ideas from chap 3
Questions / discussion ?

OK, now for the code ...

Consider a 2D vacuum world, which is part of your homework due Thursday.
Go over the AIMA code and my examples in code/aima
In class we discussed what a "closure" (google it) looks like in python :
def make_func(data): def func(x): return data + x return func f1 = make_func(1) f7 = make_func(7) print "f1(3) is ", f1(3) print "f7(3) is ", f7(3) # The question is: where are the 1 and 7 being stored? # Once make_func finishes, isn't 'data' out of scope?? # Answer: normally it would be, but since func references it, # a copy of data is kept around in func's "closure" # (i.e. environment) ... and there's one of these # for each of f1 and f7.

python notes

Do read the readme's. Do install, stare at, and play with their and my source code.
The AIMA files for the vacuum world are utils.py and agents.py .
The python coding in these libraries is more sophisticated than we've done in the "intro programming" and "algorithms" courses - now's your chance to learn some new tricks. Note especially how the code
What would a good ("intelligent" ?) agent for the 2D vacuum world be? Can you implement one as a finite state machine (their "model based reflex") within their API? A good homework problem ... maybe we'll start in class ...

lisp notes

I haven't coded much lisp lately, so I'm rusty. My code here is from 2011 - if there's interest I'll brush up on syntax and specifics and discuss Thursday.
Again, look at the readme's for installation notes.
Their two sample agents are defined in agents/agents/vacuum.lisp.
Note that this file shows the glory and pain of lisp; the (defstructure ...) format won't be found in any lisp manual, because it's a macro defined by these particular authors, based on common lisps (defstruct ...) object system, named after C's structs.
A typical thing to do here is to write your own agent, following the pattern of theirs ... which means you'll start by looking at their source code.
The resources page now has lisp links for those interested in exploring this language. I particularly recommend Graham's "ANSI Common Lisp".
I have put lisp notes of my own here, at jims lisp notes.txt . But they weren't written as a teaching tool, more of a "remind me how it works" summary.

for Thursday

So ... see how much you can sink your teeth into this by Thursday, and come to class ready to share and discuss.
I promise to be more friendly about going over everyone's code than I was last time. :) (I think I was just short on sleep.)
http://cs.marlboro.edu/ courses/ fall2015/ai/ notes/ Sep_8
last modified Tuesday September 8 2015 2:34 pm EDT