Up: Blocks World API reference

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
Block properties
Concrete block classes
The hand

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), put-on 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 superclass of all objects in the Blocks World (not including the hand). ...

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

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

Block properties

Slot readers:

Returns the block's name, a symbol. ...

Returns the block's position. ...

Returns the block's width. ...

Returns the block's height. ...

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

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

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 hand's name, a symbol. ...

Returns the hand's position. ...

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

Exported Symbol Index

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