SimCity Source Code Released to the Wild! Let the ports begin...

This past holiday (I've been bugging him since November about it) my good friend Don Hopkins got a lot of work done on the finishing touches on releasing the original SimCity source code under the GNU General Public Library (GPL). The code won't have reference to any SimCity name as that has all be renamed to Micropolis. Micropolis was the original working title of the game and since EA requires that the GPL open source version not use the same name as SimCity (to protect their trademark) a little work had to be done to the code.

There's been changes to the original system like a new splash screen, some UI feedback from QA, etc. The plane crash disaster has been removed as a result of 9/11. What is initially released under GPL is the Linux version based on TCL/Tk, adapted for the OLPC (but not yet natively ported to the Sugar user interface and Python), which will also run on any Linux/X11 platform. The OLPC has an officially sanctioned and QA'ed version of SimCity that is actually called SimCity. EA wanted to have the right to approve and QA anything that was shipped with the trademarked name SimCity. But the GPL version will have a different name than SimCity, so people will be allowed to modify and distribute that without having EA QA and approve it. Future versions of SimCity that are included with the OLPC and called SimCity will go through EA for approval, but versions based on the open source Micropolis source code can be distributed anywhere, including the OLPC, under the name Micropolis (or any other name than SimCity).

The "MicropolisCore" project includes the latest Micropolis (SimCity) source code, cleaned up and recast into C++ classes, integrated into Python, using the wonderful SWIG interface generator tool. It also includes a Cairo based TileEngine, and a cellular automata machine CellEngine, which are independent but can be plugged together, so the tile engine can display cellular automata cells as well as SimCity tiles, or any other application's tiles.

The key thing here is to peek inside the mind of the original Maxis programmers when they built it. Remember, this was back in the day when games had to fit inside of 640k so some "creative" programming techniques were employed. SimCity has been long a model used for urban planning and while it's just a game, there are a lot of business rules, ecosystem modeling, social dependencies, and other cool stuff going on in this codebase. It may not be pretty code but it's content sure is interesting to see.

In any case, it's out there for you to grab and have fun with. It was originally written in C and of course is old (created before 1983 which is ancient in Internet time). Don spent a lot of time cleaning the code up (including ANSIfying it, reformatting it, optimizing, and bullet-proofing it) as best he could. Don ported the Mac version of SimCity to SunOS Unix running the NeWS window system about 15 years ago, writing the user interface in PostScript. A year or so later he ported it to various versions of Unix running X-Windows, using the TCL/Tk scripting language and gui toolkit. Several years later when Linux became viable, it was fairly straightforward to port that code to Linux, and then to port that to the OLPC.

There's still a lot of craptastic code in there, but the heart of the software (the simulator) hasn't changed. I know there will be efforts underway to port it to a better platform, replace the age old graphics with new ones, rewrite the graphic routines with modern-day counterparts, etc. The modern challenge for game programming is to deconstruct games like SimCity into reusable components for making other games! The code hopefully serves as a good example of how to use SWIG to integrate C++ classes into Python and Cairo, in a portable cross platform way that works on Linux and Windows.

Don also wrote some example Python code that uses the TileEngine module to make a scrolling zooming view of a live city with the Micropolis module, and a scrolling zooming view of a cellular automata with the CellEngine module. The TileEngine comes with a Python TileWindow base class that implements most of the plumbing, tile display and mouse tracking, so SimCity and the CellEngine can easily subclass and customize to suit their needs. You can pan with the mouse and arrow keys, and zoom in and out by typeing "i" or "o", or "r" to reset the zoom. The TileEngine supports zooming in and out, and has a lazy drawing feature that calls back into Python to render and cache the scaled tiles right before they're needed (so you can implement the tile caching strategy in Python, while the rendering is in efficient C++ code calling hardware accelerated Cairo -- and the Python code could easily render tiles with pretty scaled SVG graphics). The Micropolis engine can load a SimCity save file and run it, and use the TileEngine to draw it, but you can't actually interact with it or edit the map yet, since the user interface and other views haven't been implemented, just a scrolling zooming view of its tiles.

Grab the source code from here and go have some fun!

Enjoy!

This is a series of posts exploring and extending the Micropolis code. You can view the full list of posts here.

68 Comments

  • It is called "X Window" not "X-Windows".

  • This is great news to those who enjoy porting software to the many handhelds out there such as me! You'll definitely see some great work come from this from so many grateful developers. Thanks!

  • No, it's called X Windowing System.

  • is it easy to put back the plane crash?

  • Great!

    But that's too bad they aren't providing the original unchanged (apart from removing the "sim city" references) C source code instead of this SWIG/PYTHON/C++ mess which will make it hard if not impossible to port to exotic platforms such as portables (PSP/DS) and alternative (non-Unix) operating systems...

  • "The plane crash disaster has been removed as a result of 9/11."

    Some one should be fired for that decision right there.

  • Great work, thank for all :)

  • @Leo: The original code is basically there (some cleaning up) in the src distribution. Grab the micropolis-activity-source.tgz file which contains the C code. The ported C++ code is in the MicropolisCore.tgz file.

  • Awesome, thanks a lot !

    You made my day.

    Damien.

  • "It's still called X-Windows in order to annoy the X-Windows Fanatics, who take it upon themselves to correct you every time you call it X-Windows. That's why it's called X-Windows."

    Beautifully put. Great blog, great software. Glad to have come across this. Thanks Bil and Don. :)

  • What about creating a project page (sourceforge or other) where contributors could improve the source code?

  • "
    The answer to the question 'Why is it still called X-Windows?' is: It's still called X-Windows in order to annoy the X-Windows Fanatics, who take it upon themselves to correct you every time you call it X-Windows. That's why it's called X-Windows.

    -Don
    "

    How old are you? Do you also feel clever when you call people "chicken butt" because of how predictably they tell you to shut up?

  • This could really make a spectacular foundation for a big, super-creative, open source development community focused exclusively on this code base. There's some good technology here. This could get r-e-a-l-l-y big. Especially since its been ported to python. It has legs now.

  • "The plane crash disaster has been removed as a result of 9/11."

    How does this make sense? I suppose the next time there's a tornado, they'll get rid of that disaster too?

  • I hope, taht we can see SimCity on the PSP in the near future...

  • Thank you.

    Please release the source code to SimAnt next!

  • Cool! Thanks for sharing it as free software, Don. :)

    (The plane thingy is just silly though, what IS the problem with some people... sigh)

  • I thought Will crashed his NSX and took the original code with him... sheeeever me timbers

  • created before 1983? I thought it was late 80's early 1990's time frame.

  • "It's still called X-Windows in order to annoy the X-Windows Fanatics, who take it upon themselves to correct you every time you call it X-Windows. That's why it's called X-Windows."

    I'll remember that the next time someone gets upset over childish names like Micro$haft.

  • Where is the original C source code?

    URL?

  • ... And now, for those of you who paid to get in... From here on out, its a free concert!


  • Awesome!

    Thanks so much Don for you hard work and dedication to this release. I know I can safely speak for all fans of SimCity that use other operating systems when say "Thanks from the heart!"

  • The X11 rename was due to the fact
    that Windows(tm) is a registered trademark
    of Microsoft and we weren't allowed to use
    the name.

    Thanks for doing this.

  • Is there any place we can download a ready-to-to app for the Mac? I'm guessing that a lot of people excited about this going open source won't know how to compile the app from the source files. A bow in the direction of those who may help :-D

  • Please remove tsunamis, mudslides, nuclear disasters. All of those have probably caused more deaths than the 2 plane crashes on 9/11.

  • Sim City was released in 1989. Where did you get the idea that it was written "before 1983"?

  • All great, except who do I punch in the face for being an overly-sensitive idiot and taking the plane crash disaster out?

    Next project: make sure that person gets named as the pilot when the plane crash gets put back in.

  • Tried to run it in X11:

    ./Micropolis: line 4: res/sim: No such file or directory

    I looked and found s sim directory in src, but no sim file in res...

    What gives? Has anyone run the game outside of an XO?

    Maybe I'm having problems using Cocoa Developer environment, and this is a MS blog...;-)

  • wikipedia says :

    X Window System (commonly X11 or X)

  • > No, it's called X Windowing System.

    Quite right! Or more precisely, it *is* the X Windowing System, which is also known as X11 or X. I suppose that whether people _call_ it that depends on how much of a clue they've got. ;)

  • Santa never made it into Darwin, the big wind struck and blew the town away ...

    rubs hands in glee - great, now I can destroy the world!

    mwahahahaha!!!!!!!!!!!! Captain Chaos, enjoy!

    Thanks for this. You've made my holiday!

  • Can you tell me why it's being Pythonised when it already works in Tcl? It seems like a waste of time, remaking the wheel rather than improving what is already there.

  • > The plane crash disaster has been removed as a result of 9/11

    Yep, The Settlers should banned too, because there you can kill cows!!... All indian world can be offended... God sick! :/

  • I also agree that removing the plane disaster was a bad idea. A legitimate disaster that can happen to any city. Please put it back in. If you feel strongly about it by all means talk about it in the README file but don't make your statement by sensoring the game.

    Yep.

  • This is truly a blast from the past. The last time I read Don Hopkins' X-Windows rant was about 10 years ago when I was a freshman CS student who had just moved from Windows home PCs to university Unix mainframes.

    SimCity source code and young punks disrespecting Mr. Hopkins and questioning his mental age. Classic.


    @ foo : Four planes crashed on 9/11, not two.

  • how do you compile this? sorry i'm a noob at this

  • Can someone please post a link to the compiled application OR a link to information on how to compile if for the MacOS?

  • if they're gonna take the plane crash disaster out because of 9/11 they should take all disasters aside from the UFO one... oh wait... this one doesnt HAVE that one.

  • Awesome but I have to agree with everyone that says pulling the plane crash was being overly politically correct. I hope to see that added back in. The choice of Python in this release is a great idea - kudos!

  • @Nathan: Now that it has gone open source, I'm sure the original plane crash will be added back in with a plugin or somesuch. Hell they'll probably add in a subway crash too, or a terrorist takeover of the power plant. Why not spice it up a little...

  • Wow, this is exactly the reason why I don't blog.
    Look at the mess.
    It's about SimCity going Open Source. Not about a windowing system.
    And those ping backs... sigh... some even manage to screw up their ping backs. Pingbacks should be considered spam. After all, it's nothing more but a link to a website that copied this page's content.

    SimCity is open source now and that's good. The few clones we have, could get some usefull stuff from it and it might even get resurrected so we can enjoy it without emulator on any system.

    And Simcity was released for PC's in the late 80-ies, in the early eighties there was a Commodore 64 version and I think I even played it on Amiga too, but I'm not really sure about that.

  • Catching up on the comments here.

    @Terry: Thanks for the tip. I've gone in and cleaned up the pingbacks. I have left the X-Windows discussion because I think it's important (important enough that people are talking about it).

    @SD (and others): Compiled version can be found in my follow-up posts Building a City Part I and Part II.

    @setec: The source code is released under the GPL with an addendum in section 7. See the Micropolis page for this information.

    @Zillable: Don is setting up a page on the OLPC repository (SourceForge is just too icky with all it's popups and whatnot) so watch for that soon.

    @All: The source code comes in two flavors. The TCL/Tk Linux C code, which was updated from the original C SimCity code and the C++/Python version for Linux/Windows (MicropolisCore). See my follow-up blog entries (Building a City I and II) for details on compiling this.

  • To run it, go into the src/sim directory, type make. Copy src/sim/sim to res/. Then run the ./Micropolis script.

    Also, looks like they missed a SimCity graphic.

  • Infogrames in Lyon, France had a prototype version of the game back in 1987 for evaluation purposes. It was running on a Mac in full black and white. The only detail I can remember is that the player actually had to place each and every electric line pole. It was fun in a way but a more model train than city management game experience.

  • The plane crash was a legitimate urban planning tool: If you build in the flight path of an airport, you have to take into consideration that, at some point, there may be a plane crash.

    (This is why, in the real world, most planning departments wouldn't let you put a school or a high-density apartment building in a flight path.)

    Taking out the plane crash makes the game less realistic. Disasters happen. Part of the fun of Sim City is dealing with them.

  • played SIMCITY for days on the AMIGA
    and also on MAC when AMIGA went defunct

    Later versions were never quite as good as the ORIGINAL
    But maybe that was just me.

    BUT SimCity 4 sucks for sure.....

    I too WANT a MAC OSX version that is as close to the ORIGINAL as possible!!!
    BUT MAYBE a BIGGER WORLD would be nice since should be possible with the new hardware now.

    DON'T care to much about the disasters except the " natural " ones.

    DITTO on
    " Is there any place we can download
    a ready-to-play app for the Mac?"



  • What's the idea of making the new code only Visual Studio compatible?

  • @Bob: The new code (MicropolisCore) isn't "only" Visual Studio compatible. You can run the makefile and build it on Linux. It works on both.

  • @MarmiteToast: Not sure what you mean by "script language agnostic". You mean having it written so that *any* scripting language can be run against it? That's rather lofty. At some point, something has to be able to understand the language that it's interacting wtih. It's a C++ dll exposed to Python via SWIG. There's nothing saying you can't expose the C++ methods directly as exports in a Win32 dll or linux shared library and consume them from whatever tool you want.

  • @Michael Fremlins: "Can you tell me why it's being Pythonised when it already works in Tcl?"

    Didn't see this answered above, but it's probably because the XO's Sugar interface is written mostly in Python. Using the existing XO Python with Micropolis makes the flash footprint a lot smaller than using Micropolis + Tcl.

    Plus, one of the goals of Sugar is to allow the students to modify apps / games directly in Python. Asking them to learn Tcl just for Micropolis works against that goal.

    Just my $0.10 (in binary).

  • While i'm really pleased to see this project under way and releasing usable code it's very disappointing to read comments that sound like juvenile grousing about mythical X fanatics, yes there are slashdot trolls who will always pick up on that kind of thing but they'll also attack you for calling linux an operating system and correct your language and grammar, they don't care about X itself.

    It's a little disconcerting seeing this project developed for the OLPC, a project that microsoft have dismissed in the past as pointless, using open source technologies which provide cross platform alternatives to many of microsoft's proprietary solutions, released under the GNU GPL, a license that most M$ associates strongly disapprove of, and then blogged about in positive ways on the blog of a MSMVP on asp.net of all places.

  • It's a window system called X.
    Not a system called X Window.

    Hey Don, can we get your special sound effects you did for the SGI version?

  • @Bil Simser:

    I guess it depends on how the code is split though. All the core stuff would have to stay C++ and then perhaps only game logic is exported to scripts. This may be what you're doing anyway so please ignore if that's the case.

    @Simfan:

    I agree, the whole X Windows discussion is completely pointless and way off topic. It doesn't matter what you call it, it's still the same thing.

  • I'm using Fedora Core 5. The game built just fine and runs but the local map has no graphics in it, just a solid color. If there is a train or a monster, that show up, but nothing else does though the game acts like it is building things, etc. Actually, all the colors look off, too, like there are too few of them being used.

    Has anyone else seen this?

  • @oneelkruns

    you are not the only one, I have the same problems.

  • Perhaps it is a Tcl version issue? When I have some time I'll look into it a bit more.

  • Very cool indeed... sim city has consumed many hours of my life. Now it can consume even more on the development side of things!

    @ricegf
    Oh not to be mean or anything but 2cents in binary would be something more like:
    .0000 0010 1000 1111

    A difficult value to reach with binary fractions! Its a nonterminating fraction in binary so next time you can go on and on just to say its your 2cents in binary.

  • Unless I'm missing something the FULL source isn't included since there are precompiled hex files that aren't in the source directory (again at least from what I can tell). What's contained in these files? They aren't created when running make. I've opened them in a hex editor and the results are.... well open one up and judge for yourself.

    I would like to say I'm not complaining by any means, I'm just curious. Thanks Don for all the hard work, this is my favorite game since childhood and I'm so glad it's been released.

  • re: X vs X-windows.

    apparently noone here knows it, but X-windows was an actual product and that's why X is called X and not X-windows IN ADDITION to the actual formal name (yes i have the R5 series and before).

    X-windows was a direct competitor with desqview and one of the first DPMI implementations. the name was changed due to collision with the unix world which it was developed in complete ignorance thereof.

  • I'll be hoping that the open source community really does something good with this game. Take it on par with SimCity 2000 at least in terms of buildings and features.

  • @kse: Yes, I know, but somehow "Just my approximately $0.0000 0010 1000 1111 worth" loses the effect. Never did stand up comedy, I suspect.

    Just for you, though, I'll withdraw my sig and switch to "Just my 10¢ in binary". :-)

  • Dearest programmers,

    As a non-programmer, non-coder, is there a way that this is available as a normal .exe, hopefully to be able to enjoy on my ancient windows 2000 platform?

    Thank you
    nels

  • umm ya i tried to open the thing i downloaded and it says windoes needs to find what program created it. it wont let me open it until i find it.

  • As a non-programmer, non-coder, is there a way that this is available as a normal .exe, hopefully to be able to enjoy on my ancient windows 2000 platform?

  • Oh, this is a game.. using module engines and code are great, can you share what other codes?

  • I wanna know on how to download this thing. It seems like im doing something wrong that is why I am having a hard time downloading.

  • I wish you could publish the source code for the SimAnt game. I want to port it to different platforms, because I find the game fun.

    I am sure that you will not lose to much money (because nobody buys the game nowadays) if you publish the source code.

    Kind regards,
    Vest

Comments have been disabled for this content.