Micropolis: Constructionist Educational Open Source SimCity

Don Hopkins
22 min readApr 22, 2018

--

Illustrated and edited transcript of the YouTube video playlist: HAR 2009: Lightning talks Friday. Videos of the talk at the end.

Don Hopkins with SimCity running on OLPC XO–1 at HAR 2009

I’m Don Hopkins, and this is the Micropolis Online project.

I’ll give you a quick history, and then try to get through the slides to the demo.

History

Porting SimCity to Unix

I started working on SimCity about 1992.

When I saw it at college before that, I just fell in love with it, and really wanted to figure out how it worked, and do stuff with the user interface and everything.

HyperLook SimCity for the NeWS (left) and X11 (right) window systems, on a Sun workstation.

So when I had the chance to port SimCity to the Sun Workstation, I jumped at that, and made a version of it using the NeWS window system, James Gosling’s PostScript based window system.

And then I developed an X11 version of SimCity, which was multi player. We sold that as a Unix product. Then the contract expired on that.

Demo of Pie Menus in SimCity for X11.

The NeWS and X11 version both supported advanced user interface features like multiple animated maps and editors, as well as pie menus. The X11 version supported multiple player collaboration, shared text chat and drawing, and voting dialogs. And Unix workstations could run the simulation orders of magnitude faster than home computers, which transformed SimCity into a fast action twitch game!

Will Wright Holding a Sim

Working with Will Wright at Maxis

Later on I went on to Maxis to work on The Sims with Will Wright.

I dredged up this SimCity code, and we talked Electronic Arts into making it open source under the GPLv3 a few years ago.

The argument — not the argument: actually they were very pleasant about it — the thing that convinced them that it was a good idea was the One Laptop Per Child project.

Freeing SimCity under GPLv3 for the OLPC

The OLPC project is focused on “Constructionist Education”, which is about children learning — anyone learning, by building things.

And SimCity is pretty much the quintessential constructionist education game.

But it needed to be opened up, so that it can be even better.

So we convinced Electronic Arts to open it up by relicensing the original Unix SimCity code under the GPLv3 free software license, so we could adapt it for the OLPC, and open it up even more! If you’re curious how we pulled that off, Chaim Gingold tells all in his dramatic behind-the-scenes story of Open Sourcing SimCity, in his PhD dissertation on Play Design.

The OLPC is About Constructionist Education

Seymour Papert and his Logo Turtle

This OLPC project is based on Seymour Papert’s ideas about teaching children to program, even when they’re very young, and Alan Kay’s ideas about the Dynabook and object oriented programming, and how kids learn.

A cartoon from Alan Kay’s original research paper on the DynaBook

One of the important things about constructionism is kids helping each other, communicating, and learning from each other.

I adapted the old X11/Unix version of SimCity to the OLPC XO-I Children’s Laptop. The original X11 version supported multi player mode, but I disabled that feature to simplify the game, because it didn’t scale well, was complex to configure, and not well designed. OLPC games for kids need to be very easy to use.

A demonstration of OLPC SimCity running on the One Laptop Per Child XO-1 laptop.

What we really needed to do was to make a new version that had a much better user interface designed to take advantage of the OLPC collaboration features and social networking platforms like Facebook. It needs to have meaningful, scalable, easy to use multi player interaction.

Fortunately, the OLPC project chose to use Python as the official scripting language. Python is a powerful, easy to learn language, that is widely used in education. It’s also very useful as a web programming language, for implementing a multi player game server.

But let me go on:

Micropolis Project Goals

  • Develop a fun web based educational game, based on the original SimCity source code.
  • Focused on constructionist education.
  • Built out of free open source software.
  • Runs on the server, plays in the browser.
  • Supports collaborative, democratic, multi-user play.

The goals: We want to make a fun game that’s based on the original source code.

“Constructionist Education” is a the overall theme, but it’s not obvious how that actually manifests itself in a game, and it takes a lot of experimentation, trial and error to figure out.

We’re using free open source software, distributing it over the web, and running it on centralized servers. So it’s easy to make updates to the game as the design evolves.

We want to put in features to support collaboration, voting, teach democracy, and also teach language skills and interpersonal communication skills.

Accomplishments So Far

SimCity on the OLPC XO-1
  • Ported and shipped the TC L/Tk/X11 version of Micropolis on the One Laptop Per Child XO-I.
  • Developed a cross platform, desktop version of Micropolis, based on GTK/Python.
  • Developed an open source, internationalized, web based version of Micropolis.
  • Client based on OpenLaszlo/Flash.
  • Server based on TurboGears/Python/C++.
  • Renovated, re-factored and documented the code.
  • Established a solid groundwork and open framework for developing an educational, collaborative, multi-player game.

So far what’s been done: First, we took the old TCL/Tk/X11 version, cleaned it up, got it through EA’s Quality Assurance, and put it on the One Laptop Per Child.

Then we stripped down the code, translated it into C++, then cleaned it up, refactored it, and took out all the user interface. Then we started building a new user interface on top of that.

I had some really great help from some talented people. John Gilmore supported me for many years during the development of SimCity, and shepherded it through the complex legal process of relicensing it under GPLv3.

Albert Hofkamp is a software developer at the Eindhoven University of Technology. He helped me clean up this code, and put Doxygen documentation into it. Now the code is much sturdier and easier to do something with.

Tom Tjon A Loi is a an artist who’s also helping on the project. I’ll show you some ideas that we’ve put together about what direction it’s going to go in the future.

We’re also benefiting from Kennisnet and IBM Netherlands, who are helping us make an educational version of this game.

The OLPC has been something for people to focus on, and get a bunch of people on board to make this happen. But we want Micropolis to run on as many different platforms as possible.

What’s really wonderful is that I have had some really great conversations about this and encouragement from Alan Kay, who has been trying to do this stuff for years with kids.

Alan Kay’s criticism of SimCity is that you can’t see inside of it and understand what it’s doing, and you have to accept it as a black box. So now I’m trying to solve that problem.

Open Source Software

  • Micropolis is built with a carefully chosen, well proven, widely supported set of open source, cross platform tools and libraries.
  • Micropolis itself and its TileEngine module are open source (GPL3). The client runs on the proprietary Adobe Flash player. With a little more work, The client will also run in standard browsers, thanks to OpenLaszlo.
  • Linux. Apache. MySQL. Python. Cairo. Pango. GTK. GCC. SWIG. PyCairo. PyGTK. TurboGears. Genshi. SQLAlchemy. CherryPy. PyAMF. AMFast. Pie menus. OpenLaszlo. Red5. Java. Tomcat. MediaWiki. PHP. Subversion. Doxygen.

We’re using a whole bunch of Free and open source software, building on top of it, and then making new software that’s open source.

One of the things that the OLPC project wants game developers to do is to make games out of modular components that can be plugged together to make other games.

So I’ve been separating out the tile engine of SimCity, and the sprites, and the sound, and trying to make those work for other things.

Web Server and Client

  • Server: Linux, Apache, MySQL, Python, TurboGears, SWIG, C++
  • Portable, cross platform C++ and Python code.
  • Linux and Unix
  • Mac OS/X
  • Windows (not currently maintained but viable)
  • Deploys on standard Fedora Linux server, i.e. Amazon Elastic Computing Server, etc.
  • Client: OpenLaszlo, XML, JavaScript, AMF
  • Web based client runs in Adobe Flash player, widely supported on most web browsers and operating systems.

The architecture of the web version is that there’s a C++ core MicropolisEngine, which is plugged into the Python programming language as an extension module. Then Python is used to script the higher level parts of the game, graphics and web server. The user interface is implemented in the client, which is written in OpenLaszlo and runs on Flash in the web browser.

I’m using SWIG, a tool for making wrappers for libraries, and plugging them into extension language. And it lets you get your library to a whole bunch of different extension languages. So right now it’s Python, but it could be Lua or Java or whatever.

The SWIG wrapper layer around the C++ game engine is glue that binds the game’s C++ classes into Python. So C++ can call Python, and Python can call C++, and they can access and modify each other’s data structures. One nice thing about SWIG is that you can subclass your C++ classes in Python, and then just script everything in a nice language.

It’s all open source stuff.

The web server does HTTP and it does Adobe AMF, which is kind of like binary JSON for Flash.

Now I’m doing the client in another open source scripting language called OpenLaszlo. It’s like JavaScript and XML that gets compiled into Flash. But it will also compile into generic DHTML.

Micropolis on OpenLaszlo/Flash Web Client and Python/C++ Web Server

Micropolis (SimCity) Web Demo

Demo of Micropolis (SimCity) running on a Python web server back-end, with an OpenLaszlo/Flash client, including pie menus, and PacMan robots who eat traffic.

Micropolis (SimCity) Web Demo

Right now I’m concentrating on just getting the Flash interface working, and once the paint’s dry on that, I can then do the parts that were Flash specific using the Canvas and DHTML and nice open standards like that.

The intention is to get it independent of Flash, but Flash is the fastest way to get it working first.

The other thing I have is a Python scripted GTK based user interface, for the desktop.

Micropolis on Python/GTK/Cairo/Pango

Internationalization

  • All text comes from Unicode XML localization files, so the text can be translated to support different languages and countries.
  • Currently supports English and Dutch, but other languages are easy to add, given translation resources.
  • Web based tools for conveniently reviewing and editing translations.
  • This is a very important feature, since we’re initially delivering to the Dutch educational system, and we intend to support many other languages in the future.

Another important thing is internationalizing it and taking all the strings out. I would love to have volunteers to help translate it to other languages. I made a little web based tool to do that. We’re doing this for the Dutch educational system, with Kennisnet’s support.

Multi Player Collaboration

  • Designed, developed and shipped a multi-player X11 version of SimCity in 1993 for DUX Software, demonstrated in Amsterdam at INTERCHI ‘93.
  • Micropolis has been systematically redesigned with multi-player collaboration and constructionist education in mind.
  • Currently laying the groundwork for multi player and online community support, while getting the single player game up and running first.
  • User accounts. Saved cities. Shared cities. Chat. Robots and Avatars. Basic MediaWiki integration. Client/server session, messaging and simulation engine plumbing.
Multi Player TCL/Tk SimCity for the X11 Window System on a Sun Workstation, SGI Workstation, and NCD X Terminal

Previously I made a multi player version of this for X11. But X11 doesn’t scale very well, and it was kind of an experiment.

But it did test out some ideas of making it a collaborative, cooperative game, instead of a competitive game.

I didn’t want to mess up the game, but I wanted to layer another social game on top of it.

We’re all sharing the same money, we’re trying to achieve the same goals, so if somebody does something that pisses you off, you’re going to be mad at them, and won’t play with them. That will play out at a higher level than the game.

It’s got voting for expensive things, like making a nuclear power plant, or changing the taxes. And the non-expensive things are just a free-for-all.

I want to re-visit the multi player game, but first get a really solid base to build it on top of. Doing a web based game is the best way to do that.

Multi Player SimCityNet for X11 on Linux

Constructionist Education

  • The original SimCity game was an exemplary constructionist educational game, which has been successfully used in many classrooms, but it was a closed commercial product, not specifically designed to support education.
  • Since Micropolis is open source SimCity, we can open up, renovate, visualize, document and extend it in wonderful ways, to specifically support constructionist education, social networking and collaborative democratic play.
MediaWiki Logo

I’m adding stuff, like integrating it with MediaWiki.

One of the important things about Constructionist Education is getting people to help each other out, and chat.

I want to teach language skills with this. Not just how to be a good mayor. That’s not the goal. It’s how to write about what you want to do, and convince other people to vote for it.

I think it’s going to be nice to embed this in things like Facebook and MediaWiki, because what you’re doing is writing stories and newspapers, and blogging.

The Sims Box

The Sims 1 (and later versions) had something called The Sims Exchange, where when you save your game file, it also writes out a bunch of web files, that describe your house, your family, the story you’ve told about them with pictures. And then it uploads that to the web.

So really, the game is a web publishing tool. I want to apply those ideas to SimCity, and that would be in the form of a newspaper. So you could act as a journalist when something happened.

These events in the game are generating opportunities for you to click on it, open it up, and write about what your interpretation of it is. And then automatically push it into a wiki page or a blog.

Don Hopkins

So the result of playing a game will be this rich save file that has points of interest with stories attached to them. You could look at it geographically as a map, to see all the points of interest. You could look at it as a calendar, like a blog. And then all these things that happened with the story can link to a save file, so you can then jump back into the game at that point.

The eventual goal is to make it sort of like TiVo for SimCity. You have all these save file snapshots, and then you can fast forward and reverse by replaying the edits that you did.

And you will have branching. You can imagine that when you play game, at any point, if you decide “let’s raise taxes”, you could make a checkpoint there. And then you could revisit that decision, and then branch reality out to another thing, if you didn’t raise taxes.

I want players to be able to make a tree of possibilities, and then share all these save files, and then comment on them, and write about them.

That’s where the educational stuff comes in. The teacher should be able to write scenarios that plug into the game, that generate events, and give people things to discuss.

Alan Kay

Alan Kay said some really wonderful things about the project to bring open source SimCity to the OLPC:

“One of the most wonderful possibilities about this venture is that it will bring together very fluent designers from many worlds of computing (more worlds than usually combine to make a game) in the service of the children. We should really try to pull this off!” -Alan Kay

I’m looking for volunteers. I never thought I’d be working directly or indirectly with Alan Kay, so it just blew my mind that he was interested in it. And he’s very supportive.

Here’s the long term goal: There’s a game, and there’s a robot or a monster. You double click on a monster, and it should open up a window that has a visual program that controls how it behaves.

This has already been done in the 80’s on the Apple ][, and it was a game called Robot Odyssey, by Warren Robinett, who made Atari Adventure. And it was so before its time. It turns out that it is one of Alan Kay’s favorite games, and that he’s waiting for the other shoe to drop.

Robot Odyssey

Robot Odyssey taught visual programming and logic to kids. You go inside a robot, and it’s a room, with plugs and sensors, and you have logic parts that you can bring out, and make a circuit inside that robot.

What I’m trying to do — oh I’d better get to the demo — is do this within SimCity. And with a visual programming language that’s just a layer on top of Python. We already have Python. I like Python. It’s well designed. I’m not going to try to invent something different, I just want to give you a visual way to get to everything Python can do, which is anything.

Educational Applications

  • Encourage creative writing by blogging, twittering, chatting, debating, writing and publishing newspaper articles about events and issues in the city.
  • Teach democratic processes. Writing proposals. Campaigning for support. Discussing and debating issues. Voting on bills.
Logo Turtle
  • Publish wiki pages with interactive annotated maps, timelines of events and creative writing about the cities.
  • Open up the simulator to enable plug-in programmable zones, tools, robots, avatars, events, policies, courseware, etc.
  • Teach older kids to program Python and C++. Implement a visual behavior programming language (like Robot Odyssey and SimAntics). Teach younger kids to think logically and program robots (like Logo turtles and Lego Robotics).

How does Constructionist Education manifest itself in something like SimCity?

Creative writing, blogging, twittering and chatting: and all this social stuff that people do.

Democracy. Writing proposals. Trying to get somebody to support your proposal. Publishing things into wikis.

Schoolhouse Rock

The teachers should be able to write courseware, scenarios, teaching events and educational content that plugs into the game, without any programming.

Opening it up to enable plugin programming. The first step is to look at the code to see how it works. And then tweak it and change it, and then make your whole new thing.

The older kids and adults can use existing examples to learn Python and C++ programming.

And younger kids plus everyone else will have an easier, higher level visual programming language in which to discover and customize the system.

That is version three. I’m only at version one right now.

Next Steps

  • Shared city library. Ratings. Tagging. Journals. Discussions. Linking. History browsing. Sharing. Voting. Profiles. Friends.
  • Text, voice and video chat. In-game chat with avatars on the map. Integrated video player for help, tutorials and lessons. Integrated html frame for synchronized web browsing.
  • MediaWiki integration, to support creative writing by students and courseware development by teachers.
  • PayPal integrations. Donations, subscriptions and micro-payments, for virtual money, cheats, high speed simulation, extra storage, fund raising, etc.

I have the web server and browser client running. I want to put in sharing cities, tagging, journals, discussions — you know, the whole social net thing. It occurs to me that maybe I should just let Facebook handle a lot of that stuff. I’ll just make a Facebook application.

Slow the game down a lot, so your Facebook wall will let your friends vote on things. I’m getting ahead of myself.

MediaWiki integration. Take well known things that solve a problem well, and piggy back on top of them, instead of trying to invent your own things.

PayPay, so we can pay for all the CPU time it takes.

Social Networking

Tom Tjon A Loi made these mock-ups of what SimCity might look like inside a social network like Facebook.

Identity

The important thing is that you have to have an identity. It knows about you. You’re part of a community of real people.

Voting

You’ve got friends, and this could be a Facebook app. If you add the app, you can do all this stuff and play it yourself. But even if you don’t add the app, you can still see and interact with what other people are doing.

Citizen

It’s all about showing other people what you’re doing, explaining it to them, discussing the issues, and getting their feedback.

Journal

You can have these links into the save files, and people saying things. I want to make it so one game might last a week, and take many little steps.

Community

What I have already made to prove the concept of plugins, is plugin zones. The first plugin zone I made was a plugin church, because that’s controversial and will upset people.

The idea is that I want to be able to script churches and other zones in Python. And create new zones and content for them without even programming. The other plugin is a plugin character, or agent. Like the monster or helicopter, with programmable behavior.

Chat

In a multiplayer game, there could be several people in the same game, and you’re all on the same map in one place, and you can chat embedded in the game, with collaborative editing.

If you put something down, it would open up an interface that says: “Hey, Don wants to make this. Do you vote for it? Yes or no.” And then have a chat associated with that, where you can discuss the issue.

Squatters

And then imagine other people could come into you game, and they find: “Hey this zone is not developed. We’re going to put a coffeeshop here!”

I want it eventually to be open enough that other people can come in and affect your game. And of course you always have a save file.

Micropolis Demo

(This is a transcript of the videos you can watch below…)

There’s a tool for doing translations.

The source code, designs and documentation are all in Google Code.

Ah, that’s the robot! I wanted to show some code. This is how PacMan works. He follows the road.

So I wrote a plugin robot that you can put into the city.

I’d better get to the actual code that’s running.

These are the different scenarios, we could load, or generate something randomly. Here, we’ll do one of my favorite cities here. I made this city.

This is a neat kind of a lazy tile view. There are 120 by 100 tiles on the server, and we’re telling the server where we’re looking at. And it’s sending just the tiles that we need to see.

Things that happen in the city get logged, and there’s a chat.

This will help you figure out what you need to do to improve you city.

This is a history.

Here’s the nice one here: we can raise taxes a lot. It was so funny because the taxes in the Netherlands are so much more than 20%.

We can look at the population density map overlay.

Ok, now here’s a meltdown. And when you get a meltdown, the notice window says “Hey there’s a meltdown!”, and has a live view showing it, that you can click on to go there.

Now this little window up here, when something interesting happens in the game, will show you a live view, and tell you something. But we can also have a link to Wikipedia or whatever.

I want to put in more educational stuff. Like the church says “Hey, did you know that Scientologists believe this?” and “Click here for more!”. We can think of the churches as in-game advertising.

And then if you have too many churches, you use the bulldozer to get rid of them.

There’s a speed control. I can make it go super-duper fast. And everybody just left. This is more like a twitch game.

Let me do the cheat. Ok, what is it? I just added this, so I’m not quite sure. You go “!faith 1000”. That makes them want a lot more churches. Woah! Ok, so I’m getting many churches. There goes the tax base.

I’ve programmed a plug-in church with a plug-in agent: the Church of Pacmania, and the PacBot. The church spawn PacBots on the road next to it, which eat the traffic on the roads (lowering the pollution and raising their score, of course). So naturally the Church of Pacmania generate a lot of traffic, to attract and feed the PacBots. I’m going to have a “Tax the Churches” option, too. If I lower the taxes, then more people will come in, and the churches will recruit them, and they’ll all drive to church. So then there will be a lot more traffic for the PacBots to eat.

Oh, I ran out of money. Let me do the robots real quick. So this is PacBot. You can put him down. Oh, I’m out of money! The fastest way is to just refresh the screen, and start fresh.

We’ll go straight in, we’ll get rid of this. Oh, pie menus, right! If you click… (Dutch “Taartmenu” cursor pops up!) I’ve got to have a talk with my translator.

You click, and you get a pie menu, which has items around the cursor in different directions. So if you click and go right, you get a road. And then you can do a little road. And if you click and go up and right, you get a bulldozer.

And then there are submenus for zoning parks, and stuff like that. This gives you a nice quick gesture interface.

The one I wanted was PacBot. So if you click him, that’s running Python code that is looking at the map, and is looks for the traffic, and it goes up, up, up, up, up. See?

Wait, you haven’t — hang on, wait: you can have lots of them. And then they compete. You get this wonderful emergent behavior of PacBot looking for traffic, and then the other PacBot eats it. You really need to zoom this up a little bit.

The great thing about this: this is another game layered on top. You can make your PacBot maze, and then you can torture them. They’ll go crazy, it’s like a lion in his cage here. Ah, caught one! Ah! He’s blue. Let’s get him here. He’s not going to be happy about this. Where’d he go? Oh oh, there’s a menu to get rid of him, so I think I deleted him. Here, we’ll put one there. He’s just going nuts there.

Wait, where were we? Real quick. Where’s my iPhone? Did I leave the phone down here? You can’t see it so you’ll have to believe me.

The first multi-player interface I’m making is an iPhone app, so it loads the city, and it lets you zoom and run over it. And I’m just about to hook it up to the server, so you can come into the game as a helicopter, and just tilt to run around, and then just chat.

Eventually I want to do the whole game on the iPhone, Andriod and whatever else. The first step is to just get presence and chatting in there.

One interesting thing: Micropolis is GPLv3. So you can’t put it on the iPhone, because of the anti-TiVoization clause, which prohibits using hardware restrictions to prevent users from running modified versions of the software on that hardware.

But it’s possible to have the simulation running on the server and a client displaying and interacting on the iPhone. I think it’s more interesting to have the simulation running on the server, in order to enable social interactions; and anyway there’s already an authentic single player SimCity that runs on the iPhone.

Any questions?

Q: What’s the cheat code to get money?

Mike: War!

Don: That’s what churches are for.

I encourage you to script your own church and plug it in. I’m totally going to have the Flying Spaghetti Monster, and he’s going to actually convert all the other churches to Flying Spaghetti Monster churches, so it will be a moot point, and there will be no war.

Announcer: Please thank Mr. Hopkins for his nice solution to the traffic problem.

Original Source Video of HAR 2009: Lightning talks Friday: Micropolis Online: Constructionist Educational Open Source SimCity

The talk starts at 7:20 in the following video, and continues in the following three videos:

HAR 2009: Lightning talks Friday 9/14, starting at 7:20
HAR 2009: Lightning talks Friday 10/14

The demo starts in the following video at 6:05, and continues in the final video.

HAR 2009: Lightning talks Friday 11/14
HAR 2009: Lightning talks Friday 12/14

--

--

Don Hopkins

User interface flower child. Pie menus, PizzaTool, SimCity, The Sims, Visual Programming, VR, AR, Unity3D / JavaScript bridge.