Up: Blocks World API documentation

Package blocks-world

This package contains the source code of chapter 21, "The Blocks World with Classes and Methods" from Lisp (3rd edition) by Winston and Horn.

About This Package

A picture of the world
Example
The different kinds of blocks
Concrete block classes
The hand
Methods for the blocks world

A picture of the world

The block objects represent a world that "looks" like this:
/----\    ^    /---------\      ^
| b4 |   /  \  |         |     / \
\____/  /_w7_\ |         |     / \
/----\  /----\ |         |    /   \  /--------\        /^\
| b1 |  | b2 | | b3      |    /   \  | b6     |       (l8 )
\____/  \____/ \_________/   /_w5__\ \________/        \./
+-----------------------------------------------------------+
|                                                           |
+-----------------------------------------------------------+    

Example

In the initial configuration, where all blocks have been placed directly on the table (not shown), the blocks-world:put-on method will move the objects like this:
BLOCKS-WORLD> (put-on b1 b2)
Move hand to pick up B1 at location (1 2).
Grasp B1.
Removing support relations between B1 and TABLE.
Move B1 to top of B2 at location (2 2).
Adding support relations between B1 and B2.
Ungrasp B1.
T    

The different kinds of blocks

Movable blocks than can be moved onto load supporting blocks. Using multiple inheritance, there are also blocks that can do both.

The basic-block class

The superclass of all objects in the Blocks World (not including the hand). ...

Returns the name of the block. ...

Returns the position of the block. ...

Returns the width of the block. ...

Returns the height of the block. ...

Returns the block this instance has been placed onto. ...


The load-bearing-block class

The superclass of objects in the Blocks World that other blocks can be placed onto. ...

Returns the blocks that have been placed onto this instance. ...


The movable-block class

The superclass of objects in the Blocks World that can be moved by the hand. ...

Concrete block classes

These are the blocks found in our world.
The table supporting the rest of the world. ...

A useful movable building block with a flat top. ...

An interesting movable building block. ...

The block is a sphere. ...

The hand

The hand is movable. It can hold at most one block.
The hand that moves the world. ...

Returns the name of the hand. ...

Returns the position of the hand. ...

Returns the block the hand is currently holding. ...

Methods for the blocks world

Move block instance onto block support. ...

Find or make space on support for instance. ...

Make space on support for object. ...

Find space on support for instance. ...

Grasps the block using the hand. ...

Ungrasps the block if hand is holding it. ...

Moves instance onto the blocks-world:table instance. ...

Make space on top of this instance. ...

Note that instance has been put onto support. ...

Note that instance has been taken from support. ...

Move block instance onto block support. ...

Exported Symbol Index

add-support, Generic Function
ball, Class
basic-block, Class
block-height, Generic Function
block-name, Generic Function
block-position, Generic Function
block-support-for, Generic Function
block-supported-by, Generic Function
block-width, Generic Function
brick, Class
clear-top, Generic Function
find-space, Function
get-rid-of, Generic Function
get-space, Generic Function
grasp, Generic Function
hand, Class
hand-grasping, Generic Function
hand-name, Generic Function
hand-position, Generic Function
load-bearing-block, Class
make-space, Generic Function
movable-block, Class
move, Generic Function
put-on, Generic Function
remove-support, Generic Function
table, Class
ungrasp, Generic Function
wedge, Class