Carnell, James E wrote:
>
I am thinking about purchasing a book, but wanted to make sure I could
get through the code that implements what the book is about (Artificial
Intelligence a Modern Approach). Anyway, I'm not a very good programmer
and OOP is still sinking in, so please don't answer my questions like I
really know anything.
MY QUESTION:
What is a slot? In class Object below the __init__ has a slot. Note:
The slot makes use of a data object called 'percept' that is used in the
TableDrivenAgent(Agent) at the bottom of this post. I am guessing this
is a type of Finite State Machine (I haven't bought the book yet so I am
guessing).
I really have a hard time grasping what it is you don't understand (the
annoying thing about not understanding stuff is that you usually lack
the proper terms to explain what you don't understand, precisely
_because_ you don't understand it ;)).
At first I thought you were talking about __slots__, as explained in the
docs <URL:http://docs.python.org/ref/slots.html>.
[but some snipped code later you say:]
##################### HERE IS THE SLOT #######################
def __init__(self):
def program(percept):
return raw_input('Percept=%s; action? ' % percept)
self.program = program
self.alive = True
That is "simply" a special method (namely the one that is called after
instance creation so you can set up the instance variables).
<nagging>You should really know that.<\nagging>
Lookie here: <URL:http://docs.python.org/ref/customization.html>
Did that do it? Sorry, I have big trouble looking at long listings and
figuring out their meaning. If that didn't help, try reformulating your
question (please).
/W