Wednesday, November 07, 2007

visually manipulating collections in etoys' Playfields


Markus Gaelli has a 15 Puzzle etoys demo program at his emergent site (excellent site for etoys projects)

Before getting onto coding the puzzle I became quite absorbed about the potential of etoy Playfields. The puzzle consists of 16 little Playfields (which in turn are containers for their own "text" numbers) inside a big Playfield.

What I see in Playfields is the opportunity to manipulate collections visually which I haven't seen in any other program. eg. Game Maker doesn't represent for loops visually and it is hard to teach them to students, in my experience.

I was also intrigued by the notion that Smalltalk adopted "collection based programming as a central tenet" and "that modern functional programming languages such as ML and Haskell have followed this lead". The whole approach is not based on looping constructs but on creating a new collection containing the desired elements (Squeak by Example, p. 195). I'm unsure about how much of this approach can be demonstrated in etoys - but it does suggest a different sort of way of teaching collection manipulation that may be more accessible to many learners

This post is just getting started with how to work with collections in Playfields.

The screenshot above is a collection of Playfields (which contain text numbers) contained within a larger Playfield. The resultant collections category in the larger Playfield's Viewer looks like this:


This opens the door to visually manipulate quite a few things:

count: number of objects that the Playfield contains
cursor: the currently selected object, in this case 9 (the cursor can be visible or invisible)
firstElement: I have auto-line-layout switched on so the objects are layed out neatly with the first object in the top left hand corner
include at cursor | dot: This adds a new object to the Playfield at the cursor. You need to replace the default dot with the object you want to add.
include: dot: Adds a new object at the end of the other objects (replace dot with the object you want to add)
numberAtCursor: ?? not sure what this is for
playerAtCursor: The object currently at the cursor
removeAll: remove all objects from the Playfield
shuffleContents: shuffle the objects in the Playfield
stringContents: displays a linear text representation of the Playfield contents

I've written a program which automatically populates a Playfield with the elements of the 15 Puzzle. I'll blog about that separately.

No comments: