SimCity Source Code Is Now Open 360
Tolkien writes "Source code for SimCity has been released under the GPLv3. For legal reasons the open source version was renamed Micropolis, which was apparently the original working title. The OLPC will also be getting a SimCity branded version that has been QA'ed by Electronic Arts. Some very cool changes have been made by Don Hopkins, who updated and ported what is now Micropolis. (Here is an earlier Slashdot discussion kicked off by a submission Don made.) Among other things, it has been revamped from the original C to using C++ with Python. Here is the page linking all the various source code versions. Happy hacking!"
All of a sudden... (Score:5, Funny)
The plane crash disaster has been removed as a res (Score:5, Insightful)
It's official, the terrorists have won.
Re:The plane crash disaster has been removed as a (Score:5, Funny)
Re:The plane crash disaster has been removed as a (Score:4, Insightful)
(That and I want a global thermal-nuclear war scenerio.)
Re:All of a sudden... (Score:5, Funny)
1. Reinstall your OS, taking note of which libraries you compile into the kernel and which you merely reference as modules (this will be used later).
2. Scan all the ansi files in the download and replace references to other hardware with the
3. Start the game, turn off sound and network options (don't kid yourself; it's for the best) and start a new game.
4. If it runs too slowly, go back to step one and change the kernel\module mix to something more suitable.
Yes, this was an OSS troll and a superficial attempt at light humour... take a breath, count to ten, then mod me down.
- fodi
5. Play !!
Craptastic Code? (Score:5, Insightful)
I dunno, from the QA side in 88/89, the results were darn clean. The simulation would crash from time to time, but the interface, never. To all those who point to multi-threaded apps and say it's too hard for coders to do, I'd suggest that really good programmers are hard to come by.
So maybe somebody can point to what's being complained about here. Back in the day, we didn't have the luxury of infinite space for code and variables. But from a quality-of-product point-of-view, very little could match (and can match) SimCity
Re: (Score:2, Interesting)
The Mac seemed such a natural platform for Maxis in those days.
Re:Craptastic Code? (Score:4, Informative)
Well, except for the use after free bug that required a special case in Windows 95 so that the game would keep working.
See e.g. here (look for SimCity):
http://www.joelonsoftware.com/articles/APIWar.html [joelonsoftware.com]
Re:Craptastic Code? (Score:5, Insightful)
Re:Craptastic Code? (Score:5, Funny)
Slashdot, the only place one can make a flippant remark regarding the state of 20 year old code and successfully find someone who worked on it.
Re:Craptastic Code? (Score:5, Funny)
Re:Craptastic Code? (Score:5, Informative)
Re: (Score:3, Informative)
Re:And yet... (Score:5, Funny)
Re:And yet... (Score:5, Funny)
Re:And yet... (Score:5, Funny)
Version? (Score:5, Interesting)
I'm assuming the classic, which is a shame as I felt 2000 was one of the few times a sequel actually made the game better. Unfortunately 3000 and 4000 continued to suggest otherwise however.
Even if it's just classic however I'm sure I remember even that had some differences between platforms.
Perhaps I'm just blind but it'd be interesting to know which version this is!
Re: (Score:2, Informative)
Re: (Score:3, Insightful)
Re: (Score:2)
Re: (Score:3, Interesting)
I never found it to be a big problem.
Re: (Score:2, Informative)
Re:Version? (Score:5, Informative)
Looks a lot like Classic.
Re: (Score:3, Informative)
(there is a larger version on the website but I'm trying NOT to set fire to his provider's systems)
It's stated in the article (Score:5, Informative)
It actually states the history of where it's come from in one of the linked articles [donhopkins.com] (emphasis added):
So it looks as if it's some kind of mutated version of SimCity Classic which dates back to the C64 version.
Awesome (Score:2)
Finally! (Score:3, Funny)
Re:Finally! (Score:5, Informative)
Though their move is still good, and interesting just to dig into the code.
Re:Finally! (Score:4, Interesting)
Hell, it's more similar to SimIsle than Simcity actually. Lincity was too much of a "everything is a consumable resource" game, which was rather silly...
I would say that Simcity 4 is the most advanced simulator I played so far, that is also playable as a game.
Though in terms of open source simulation games, nothing beats openTTD.
Re: (Score:3, Informative)
Re: (Score:2)
Maybe now we can finally find out (Score:5, Funny)
Don't destroy the church (Score:2, Funny)
Re:Maybe now we can finally find out (Score:5, Informative)
left of the city center
Probably because they borrowed some of the code from SimAnt, which had less ant growth towards the upper left due to a processing order issue in the updating algorithm. It's one of those problems where step N+1 is computed incrementally from the current state, rather than from a frozen copy of step N.
Re:Maybe now we can finally find out (Score:4, Interesting)
It's a classic type of bug (Score:3, Interesting)
It's a type of bug more common back when memory was limited. Classically, it was a spreadsheet bug. The dumb way to evaluate a spreadsheet is to start at the upper left, evaluating the formula (if any) for each cell. If any formula refers to a value that's to the right or below the cell being evaluated, the spreadsheet values will be wrong. Each time you hit the recalculate key, the values propagate through one more wrong-direction dependency. Once you've hit "recalc" enough times, the values stabilize
port to win32 (Score:2)
Re: (Score:3, Interesting)
Re: (Score:2)
Re:port to win32 (Score:5, Funny)
Boo-hoo (Score:5, Interesting)
Re:Boo-hoo (Score:5, Insightful)
Re:Boo-hoo (Score:4, Informative)
Nuclear meltdown because of Chernobyl.
Earthquakes because of California, Kobe Japan, and Pakistan.
Alien Invasion because of Orson Welles war of the worlds radio broadcast.
Re: (Score:2)
I'm glad I should soon be able to remedy to that
Re: (Score:3, Funny)
Re:Boo-hoo (Score:4, Funny)
Re: (Score:3, Funny)
And we can add in kidnappings and beheadings. Everyone wins!
Tried it, builds but doesn't work. (Score:4, Informative)
Re: (Score:2)
Win32 binary versions available? (Score:3, Interesting)
Re: (Score:2, Interesting)
Re: (Score:3, Informative)
The Brown Sheet of Paper (Score:3, Funny)
Re: (Score:2)
somebody can go to the copyright check function and change it to something like this:
boolean is_valid_copy() {
return TRUE;
}
(or just comment out the copyright check in the first place)
Re: (Score:3, Interesting)
(historical note- there was an early binary edit 'exploit' for SimCity that worked for bypassing the 'Brown Paper' copy protection, but as soon as you bought and installed an Expansion pack it quit working)
So where is it? (Score:3, Insightful)
Re: (Score:2)
Re:So where is it? (Score:5, Funny)
good news (Score:5, Insightful)
No build on MacOS X (Score:5, Informative)
Re:No build on MacOS X (Score:5, Interesting)
My patch agains micropolis can be found at: http://rmdir.de/~michael/micropolis_mac-osx.patch [rmdir.de]
This patch also seems to fix graphic problems on Linux with a 24 bit X server.
Re: (Score:3, Informative)
In regards to patching the files...
Just download the source and unzip/untar it, put it in
Then execute the patch command, like this for example: patch < micropolis_mac-osx.patch. The the paths are off, it will ask you what file to patch, take a look at the "diff" line and simply supply the file name from there, for example (src/tclx/ossupp/makefile), or whatever the right path is for you to tha
hammered to death? (Score:2)
Lincity Absorption (Score:5, Interesting)
Anyone remember the old Simcity "skins"? (Score:2)
But I remember a friend who found various themes for his Simcity -- there was an "old west" style theme, and a futuristic one and one or two others. The game itself wasn't any different, but instead of, say, gas stations, you'd have horse pastures or something.
I should probably JFGI (again), but I have tried in the past to find anything about them and have been unable.
Slashdotted (Score:2, Funny)
Re: (Score:2)
If you're looking for a legal/legit version of the SNES version, it's 500 Wii Points on the Nintendo Wii VC.
Re: (Score:2)
Re: (Score:2)
Re: (Score:3, Informative)
Re: (Score:3, Insightful)
Re: (Score:3, Funny)
If you read the article... (Score:3, Informative)
This is actually clearly explained in one of the linked articles [donhopkins.com]:
Re: (Score:2)
You can do that in C, too.
Re: (Score:2)
Re:If you read the article... (Score:5, Informative)
You can do anything in C you can do in C++, but it's a total pain in the ass. Why, you can even write a C++ compiler in C that compiles C++ into C, and call it CFront.
If you want to see what happens when you try to simulate C++ interfaces in C, then look at Microsoft's COM header files, which do exactly that.
The reasons I translated the C code to C++ were: 1) eliminate all global variables, so multiple simulators could exist simultaneously without interfering with each other, 2) define all interfaces in one place so it's easier to work with and evolve the code, 3) enable SWIG to automatically generate an object oriented wrapper for any of a large number of scripting languages, like Python, 4) Impose some sane programming conventions on the code, for reliability and readability's sake.
I hate C++ as much as anyone else does, probably more than most [google.com]. But I know when it's better to use C++ than C, and this is one of those times.
-Don
Re:If you read the article... (Score:5, Informative)
In order to modify a C program to use structures and function pointers instead of global variables, you have to meticulously modify almost every line of code. And that is simply far too much work to do, and would be extremely tedious and error prone.
The one thing C++ is really great at, is taking a C program with global variables and global functions, and easily transforming it into a C++ class that encapsulates all the variables and functions, without disrupting every line of code. Because "this" is an implicit argument. Because member references don't have to explicitly go through "this".
But if you did that kind of a transformation on C code by hand, you would have to rewrite every function signature to take an explicit "this" argument, and rewrite every variable or function reference to go through the "this" pointer.
Actually, I really dislike GTK's Python binding mechanism. It's horribly complex, totally undocumented, and very brittle. It doesn't handle other languages, either. SWIG is a much more advanced, much easier to use tool. I also don't like GTK's "yet another object system". It accounts for most of the time spent by OLPC Sugar python applications initializing. It takes a horribly long time for GTK to initialize, and it's not Python's fault, it's GObject's fault. There's nothing worse than having several object systems, especially when some of them are slow, non-standard and difficult to work with.
Have you ever looked at or used the COM macros for generating C++ vtable layouts? It's attrocious! Actually, I really like COM for what it is (I use XPCOM at work, since we use xulrunner to implement TomTom Home), but COM's C bindings are total crap. It's much easier to use from C++ with templates, ala ATL (ActiveX Template Library), WFC (Windows Foundation Classes), etc. The MFC COM and OLE stuff is much worse, but not as bad as the C stuff.
C++ templates can't hold a candle to Common Lisp macros. C++ templates are a totally different animal, totally inferior to the macros that Lisp has had for many years. The arcane C++ syntax makes it impossible to support the kind of high level metaprogramming macros that Lisp so easily supports.
-Don
Re:huh? (Score:5, Funny)
It needed to be updated, because it ran too fast on modern hardware.
Re: (Score:3, Insightful)
Glad you set me straight on that.
C++ & Python does seem to be a weird and cumbersome choice though. But when all you have is a hammer everything looks like a nail. I hope at least the core simulation is all one language.
Re:No, its worse (Score:5, Insightful)
One person's hammer is another person's "right tool". If you read the article, it appears to me that the guy who ported the code has a clue about a few things. I'm gonna bet that his choice of Python was thought through. Likely he is leveraging some existing infrastructures that he knows, thus speeding the time-to-release. To me, that's a very handy hammer.
The code is now open. Feel free to hack onto oblivion the design choices you don't appreciate.
Re:No, its worse (Score:5, Insightful)
Put aside your prejudices and you may actually learn something.
Re: (Score:2)
Re:No, its worse (Score:5, Informative)
To clear up some confusion: The old version of SimCity/Micropolis uses TCL/Tk to implement the user interface. That is the version currently being distributed on the OLPC. The new version is rewritten in C++, and has all the TCL/Tk and user interface stuff ripped out of it. I converted it to C++ for the reasons I described in other posts (quoted above), so it is now modular and can be run through SWIG to integrate it with many different scripting languages.
But the core simulator is independent of Python, and runs extremely fast (the TCL/Tk version can run more than a year a second on the relatively slow OLPC). The OLPC uses Python as its standard system wide programming language, and all of its important libraries (like Cairo and Pango) are integrated as Python modules. So it makes the most sense to use SWIG to cast Micropolis into a Python module, first. Of course SWIG also makes it easy to integrate it with any other scripting language.
If it's not immediately obvious to you (or even if it is), why anyone would want to integrate SimCity with a scripting language, instead of just writing the whole thing in C, then you should read some of the discussions I've been having with Alan Key about that topic, on my blog [donhopkins.com].
-Don
Re:No, its worse (Score:5, Interesting)
The UI is quite abstract. I had to cleanly separate the UI and the simulator engine to port SimCity to NeWS, and TCL/Tk maintained that separation. The new MicropolisCore has all the UI code taken out, so all the rendering and event handing has to be implemented outside of the simulator core, in a scripting language like Python, with a graphics library like Cairo, and a user interface toolkit like GTK.
The new Micropolis core simulator engine talks to the tile engine through efficient raw memory pointers. Micropolis hands the tile engine a pointer to its tile memory and a description of the format, and a tile bitmap and a description of the tile layout (including an indirect tile map). The tile engine uses Cairo to render the tiles. Cairo is a much more advanced imaging library than SDL, and most importantly it supports Unicode and fully internationalized text via the Pango library (OLPC activities must support many different languages). Cairo enables scaling and transformation, vector graphics, anti-aliasing, clipping, SVG, etc. It is more like the PostScript based user interface to SimCity I developed for NeWS. The Cairo tile engine supports zooming into the city, and the old NeWS version used to let you play the game at any scale. Zooming is very important on the OLPC's 200 dot per inch resolution screen, because the unscaled tiles are very small, and kids like to zoom in to look closer at the city, so it's easier to see. Another reason for using Cairo is that it's great for drawing map overlays and data visualizations, with scalable vector graphics, transparency, etc. And also, Cairo is hardware accelerated on Linux, the Mac and Windows, so it can draw extremely fast and still look pretty.
-Don
Re: (Score:2)
And Python uses a form of precompilation. The first time a Python module is loaded, it's compiled into Python bytecode, and stored in a .pyc file alongside the source code. Further invocations use the bytecode. Python's bytecode compiler is blazingly fast, and that's why it's suitable for the modern 3D games listed above.
You make a statement about bytecode, then claim its blazingly fast? Granted, it is faster than an interpereted language, but its nowhere near the speed of compiled language.
While your 2 GHz processor may be more than fast enough to run Python code, it will NEVER be as fast as a compiled binary. So while your quad core processor running at 3.2GHz will run these products just fine, you will probably find that it chokes on a 133 MHz Pentium machine in Python when the original sorce, written in C, ran just fin
Re:What the fuck are you talking about? (Score:5, Insightful)
The original SimCity code written in C ran just fine of an 8 bit 1.02 MHz 6510. And I've optimized to run even more efficiently since then. So worrying about Python slowing SimCity down is totally lacking in perspective -- penny wise but pound foolish. SimCity is already many orders of magnitude faster than it needs to be. Anyway, the core simulator is written in C, so Python doesn't slow it down at all. You should learn more about Python programming, developing Python modules in C and C++, and using SWIG for integrating Python and native code, and using Python as an embedded application extension language, before "making such [...] comments".
Using Python drastically speeds up the software development process, which is a great thing when software developer's time is so expensive, and computers are so fast. Python is also is a much easier language for kids to read, learn and program -- and the OLPC is an educational project, not a laptop project.
-Don
Re:What the fuck are you talking about? (Score:5, Interesting)
Agreed. But Java isn't exactly what I'd call a scripting language. What I expect from a scripting language is the easy ability to interact with it on a command line or interactive interpretive interface (like Smalltalk). (It doesn't actually have to be interpreted, just compiled fast enough that I don't notice, like many Lisps and OpenLaszlo implement their interactive command line.) Java's problem is not just that the compilers and tools aren't set up for interactive evaluation, but also that the syntax makes it extremely tedious and required typing a lot of boilerplate structural crap. Of course there are some good interactive interpreted languages like JavaScript (Rhino), Python (Jython) and Groovy implemented in Java.
The great thing about integrating C++ modules like micropolis with Python is that you can play around with it from the keyboard, test and debug it easily, and get it to work quickly. Immediately after I compiled the micropolis module for the first time, I was able to import it, make a simulator, load a city, set the tax rate, and run the simulation loop, all from the keyboard! Then I copied that code I typed into a python file, and I had the first test framework.
-Don
Re: (Score:2)
hey wait a minute, that might just wo
Re: (Score:2)
The purpose of a counter-insurgency, from the Brits in Malaysia to the Marines in Anbar, is to deny the enemy the use of the populace as cover by getting the people to want to turn them in. Sometimes it's shooting the bad guys (and making darn sure you shoot JUST the bad guys), sometimes it's building a school or making sure they get power.
Sounds like that could be easily m
Didn't need this for it... (Score:2)
That's assuming you think it's the right game for the job.
Re: (Score:2, Flamebait)
cd TileEngine ; make
make[1]: Entering directory `/tmp/MicropolisCore/src/TileEngine'
cd python ; python setup.py build
running build
running build_py
running build_ext
building '_tileengine' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I. -I.. -I/usr/include/cairo -I/usr/include/pycairo -I/usr/include/python2.4 -c tileengine_wrap.cpp -o build/temp.linux-x86_64-2.4/tileengine_wrap.o
cc1pl
Re: (Score:2)
(and yes, "f-u-n-d" still gives you $10,000, even though you're an ant)
Re: (Score:2)
Re:Opportunity for a more realistic SimCity... (Score:5, Insightful)
From Designing User Interfaces to Simulation Games, a summary of Will Wright's talk to Terry Winnograd's User Interface Class at Stanford, in 1996. [donhopkins.com]:
-Don
Welcoming a master coder (Score:5, Funny)
Re: (Score:3, Funny)
Re:PostScript (Score:5, Insightful)
NeWS [wikipedia.org] was like AJAX, but with PostScript instead of JavaScript for programming, with PostScript instead of DHTML for rendering, and with PostScript instead of XML for data representation.
-Don
Re:Nice move, but... (Score:5, Funny)
Yes, it'll be great to port Micropolis (SimCity) to embedded devices! I'd like to port it to the TomTom, and hook it up so you can operate the bulldozer or road building tool via GPS, just by driving around!
-Don
(Disclaimer: I work for TomTom, and this should NOT be interpreted as a product announcement!)
Re: (Score:3, Insightful)
Cleaning up code -production code- is often not an optio
Re: (Score:3, Informative)