[sugar] Ideas about SimCity gui, turtle graphics,
and cellular automata
Don Hopkins
dhopkins at DonHopkins.com
Wed Mar 14 02:50:15 EDT 2007
SimCity in Python will be totally programmable in Python, so what should
we program it to do? And how can we refactor it into general purpose,
reusable components?
Here is an outline (at the end of this message) of some ideas I've had
about simplifying the SimCity user interface and making it more fun and
educational. It should be easy and fun for little kids to use, work well
in book mode with the game controller, support the mouse but not require
it, and enable collaboration over the network with other players.
Instead of (or in addition to) using the mouse to paint with a palette
of editing tools like Photoshop, the interface could be based on agents
like logo turtles that represent the user on the map, which carry around
SimCity editing tools that they can draw with. When you throw in a
visual programming language, it leads the way to a Robot-Odyssey-esque
version of SimCity!
This is one reason I want to have a nice plug-in visual programming
language!
Just for fun, and for the enjoyment of cellular automata freaks and von
Neumann fans, here is a nerd toy I wrote in OpenLaszlo (a von Neumann 29
State CA editor and simulator), with a cellular automata grid editing
tool that you can move around over the grid and edit the map like an
agent or logo turtle, using the keyboard or mouse. It's a half-baked
experimental user interface, so I'm not claiming that it isn't bizarre
or doesn't suck, but it does demonstrate some ideas that might be
applied to the SimCity user interface.
John von Neumann's 29 state Cellular Automata Implemented in OpenLaszlo
http://www.donhopkins.com/drupal/?q=node/41
Full window demo in Flash player:
http://www.donhopkins.com/lzxnet/my-apps/vonNeumann/vonNeumann.lzx?lzt=swf
Source code:
http://www.donhopkins.com/lzxnet/my-apps/vonNeumann/vonNeumann.lzx?lzt=source
The arrow keys move the tool, space clears the cell under the tool, the
letter diamonds "wasz"/"rdfc" make an unexcited ordinary/special
directional arrow cell in the corresponding direction, and "WASD"/"RDFC"
make excited versions of those arrow cells, other letters and numbers
are for miscellaneous states, and so on. The "." key advances the
current cell to the next logical state, so you can toggle the excited
state of any arrow cell in a standard way without changing its
direction, or cycle confluent cells through their four states. Clicking
the mouse on the tool pops of a pie menu with submenus of all possible
states organized by category (some of which arrange naturally into pie
menus, because they are directionally oriented). Clicking the mouse
anywhere else moves the tool to that cell. The goal is to be able to
quickly key in a cellular automata configuration, as well as randomly
accessing and editing it (even while it's running).
[I'm not going to attempt to explain how the CA itself works (just press
"Run" and enjoy the blinking lights), but it's based on one of my
favorite classics: John von Neumann's 29 state CA rule, which he
specifically designed (on paper!) to program self-reproducing machines.
The source code has some good references and obtuse comments! Sadly, the
Flash player is way too slow to run enough cells to actually house a
complete self-reproducing machine (and its offspring, and their
offspring...) in their full glory and splendor. Fortunately I do have an
efficient C++ implementation of that rule (and others), as a Python
extension! Once we have a good tile display/editing engine in Python, it
will be fun to hook that code up to drive it, and efficiently run huge
self-reproducing cellular automata!]
For hard core cellular automata freaks: Hit "Next" a few times till you
get to "Autoinitializing Exclusive Or", then hit "Load" then "Run", to
see a cool self modifying cellular automata bootstrap! A special signal
of 5 excited states in a row goes through first, which initializes the
circuit, ignites all the pilot lights and synchronizes all its internal
clocks at just the right time and phase, and then cuts off the ignition
circuit (blows the explosive bolts so to speak, with construction
commands) so the circuit is only initialized once, and subsequent
signals flow through the normal part of the circuit. In this case, the
circuit performs an exclusive-or (which is easier said than done in this
rule, requiring synchronized clocks), two of which are needed to cross
two signals without interfering. The point of all this, is that machines
in this CA rule can only construct other machines in the powered-off
state (or they might get electrocuted ;-), so there has to be a way to
turn a machine on and start all its clocks ticking by
"autoinitialization" -- self modifying CA code! The self-reproduction
process has two phases: first build a copy of yourself in the
powered-down ready-to-initialize state, by scanning back and forth with
the builder arm like an ink jet printer, programmed from a huge spiral
of memory (the machine's dna). Then once you're done, dock your
construction arm into the new machine's naval at the base of it's memory
loop (like an umbillical cord for data), then switch into playback mode
and loop all your memory back through, injecting a copy of it into the
duplicate's memory loop. Then send a start signal to initialize the copy
and start it reproducing itself. This stuff was described (and
illustrated ;-) in a paper by William R. Buckley and Amar Mukherjee. The
examples in this demo show different ways to effect a signal crossings
(with different advantages and disadvantages). Some (like the real time
crossing) are not "constructible", and some have interference problems
(like the coded channel crossing), and some are enormous (like two
autoinitializing exclusive or's). Of course people have come up with
much more efficient rules since then (and that is a fun game too), but
John von Neumann's 29 state rule is classic coke, the real thing.
-Don
Redesigning the SimCity user interface for the OLPC
Don Hopkins
Visual Programming
Simplify the SimCity interface and make it easier for kids to
use it with the game controller, in a way that will support
multi player interaction.
Collapse the separate concepts of game editing tool (bulldozer,
road, residential zone, etc) and agent (sprites like the
monster, tornado, helicopter, train, etc).
Agents with specialized tool represent different roles that kids
can play. A bunch of kids can join together and play different
roles at the same time in the same city. Instead of having a
bunch of editing tools to switch between, you have a bunch of
different agents you can drive around the map, like using a
monster to crush things instead of a bulldozer, or riding around
in a helicopter to scroll around and observe the map. Make a
meta-game like pokemon trading cards or magic the gathering,
about acquiring and deploying and using agents on the map. Give
agents different budgets and constraints.
Use an agent to represent a user in the world, and control an
editing tool. You see other users in the map driving around
their editing tool agents.
Each editing tool can be associated with a particular agent,
with a keyboard/game controller based user interface for moving
around, as well as a mouse based interface for picking it up and
dragging it around.
The road tool becomes a road building vehicle, that you can
easily move up/down/left/right/diagonally with the game
controller directional input. Requires much less coordination to
draw straight roads than with a mouse.
The bulldozer tool becomes an actual bulldozer that you can
drive around the map, crushing things in your wake.
This makes the game easily usable by little kids in book mode.
Also support small children using SimCity like a drawing tool or
etch-a-sketch, simply doodling with the editing tools for the
visceral pleasure of it, and setting fires and other disasters
to watch it burn and mutate.
Logo Turtles (as a generalization of the monster, tornado,
helicopter, etc)
Implement programmable logo turtles as agents that can move
around on the map, sense it, and edit it.
Like Robot Odyssey agents, so you can go "inside" an agent,
and travel around with it, operate its controls, read its
sensors, and automate its behavior by wiring up visual programs
with logic and math and nested "ic chip" components.
Plug in graphics to represent the agent: use classic logo
turtle and SimCity sprites, but also allow kids to plug in
their own.
SimCity sprites have 8 rotations.
SVG or Cairo drawings can be rotated continuously.
Re-implement the classic SimCity agents like the monster,
tornado, helicopter, train, etc in terms of logo turtles, that
kids can drive around, learn to use, open up and modify (by
turning internal tuning knobs, or even rewiring).
Let kids reprogram the agents to do all kinds of other stuff.
Mobile robots, that you can double click to open up into
Robot-Odyssey-esque visual program editors.
Agents have local cellular-automata-like sensors to read
information about the current and surrounding tiles.
KidSim / Cocoa / StageCraft Creator let kids define visual
cellular automata rules by example, based on tile patterns and
rules. Show it a pattern that you want to match by selecting
an instance of that pattern in the world, then abstract it
with wildcards if necessary, then demonstrate the result you
want it to change the cell to in the next generation.
Sense high level information about zones and overlays, so the
agents can base their behavior on any aspect of the world
model.
Support an extensible model by allowing users to add more
layers.
Add layers with arbitrary names and data types at
different resolutions:
byte, int, float, n-dimensional vector, color, boolean
mask, musical note, dict, parametric field (i.e. perlin
noise or other mathematical function) at each cell, etc.
Edit the world.
All SimCity editing tools (including colored pens that draw
on overlays) should be available to the agent.
Enable users to plug in their own editing tools, that they
can use themselves with the mouse, keyboard or game
controller, or program agents to use to edit the map under
program control.
Robot Odyssey
Build your own universal programmable editing tool.
Roll your own von Neuman Universal Constructor.
Smart robots you program to perform special purpose editing tasks.
The "Painter" picture editing program had a way of recording
and playing back high level editing commands, relative to the
current cursor position.
Remixing. Journaling. Programming by demonstration or example.
You could use a tape recorder to record a bunch of SimCity
editing commands that you act out (or you can just select them
from the journal), then you can play those tapes back with
relative coordinates, so they apply relative to where the
agent currently is on the map. You can copy and paste and cut
and splice any editing commands into tapes that you can use to
program the robot to play back in arbitrary sequences.
Program an urban sprawl development-bot to lay out entire
residential subdivisions, complete with zones, roads, parks and
wires. Then program a luddite roomba-bot that sucks them all
up and plants trees in their place.
This becomes really fun when we let players plug in their own
programmed zones for the robot to lay out, and layers of data
to control the robot's behavior, out of which they can program
their own cellular automata rules and games (like KidSim /
Cocoa / StageCraft Creator).
More information about the Sugar
mailing list