[sugar] Ideas about SimCity gui, turtle graphics, and cellular automata
Don Hopkins
dhopkins
Wed Mar 14 16:21:50 EDT 2007
> Don Hopkins wrote:
>
>> 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?
>>
>
> Will SimCity itself be implemented in Python, or will there just be some
> kind of scripting interface to SimCity?
>
The idea is to preserve the original SimCity code (written in C) so it
you can still play the original game, and expose it to Python through
functions, variables, hooks and callbacks.
I might have to wrap the C code in a C++ class, so it's encapsulated and
possible to have any number of the simulators running independently in
memory at the same time, without using any global variables. (As
distasteful as C++ is, it's good for a few things like encapsulating old
C code!)
I'm planning on using SWIG to expose the SimCity interface to Python, so
it will be possible to plug the same code into other scripting languages
that SWIG supports as well (given some work with language-specific
typemaps and convenience functions, etc).
> btw, Develop (or pieces of it) might provide the code editing
> functionality. In fact, Develop (possibly not until gen2) might also
> provide a visual code editor (flow chart-ish, or similar)
>
>
Over time, I'd like to document how the code works, and factor out parts
of SimCity into modular functions that you can call from Python, which
you can override in Python to do your own stuff before, after, or
instead of the original C code. Then you can replace and instrument
parts of the simulator in Python (like the traffic simulation, or the
economic simulation), and plug in new features (like your own scripted
disasters), but still have the original simulator there if you want to
run the classic SimCity. Parts of it can be rewritten in Python so they
act the same but they're general purpose and easy to reprogram by
subclassing, like the monster, tornado, helicopter, etc. Then you could
use a visual programming language to subclass them and customize their
behavior.
> That is pretty cool! However, it might be desirable to leave in classic
> SimCity mouse-based editing as an option, in case someone wants to build
> a large map by hand with the mouse.
>
Absolutely: it's important to always support the original SimCity user
interface and behavior!
I want to enable extensions through optional plug-ins, hooks (extension
points, like "aspect oriented programming") and subclassing, and
preserve the original behavior and interface, while cleaning up and
modularizing the code.
-Don
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.laptop.org/pipermail/sugar/attachments/20070314/1c180b8b/attachment.html
More information about the Sugar-devel
mailing list