HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
SimHacker
MicropolisCore
TypeScript2024–2026
SimHacker / MicropolisCore

MicropolisCore

Micropolis C++ Core (based on the original SimCity Classic by Maxis/EA)

2Distinct people
27Mentions
1Explicit recommenders
222GitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Micropolis C++ Core (based on the original SimCity Classic by Maxis/EA)

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

I've started a new Space Age game, too! With the understanding that you can regularly leave Factorio running overnight or even all week to build up resources, how many hours…

DonHopkins used a recommendation phrase. One indexed comment matches. This is a phrase match, not a verdict.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

Mentioned in the same Hacker News threads. That is not proof they are substitutes.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 1:49:46 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year27 dated mentions

Observed mentions: 2024-02-18 22:34:23 UTC to 2026-10-24 18:44:22 UTC.

0369122024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 12 mentions; 0 submissions, 12 comments20242025-01-01 00:00:00 UTC to 2026-01-01 00:00:00 UTC (exclusive): 4 mentions; 0 submissions, 4 comments20252026-01-01 00:00:00 UTC to 2027-01-01 00:00:00 UTC (exclusive): 11 mentions; 0 submissions, 11 comments. Incomplete calendar period.2026*

* An incomplete calendar period is marked with an outlined bar. Its count is not directly comparable with a full period.

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC12012
20252025-01-01 00:00:00 UTC2026-01-01 00:00:00 UTC404
2026 (partial)2026-01-01 00:00:00 UTC2027-01-01 00:00:00 UTC11011

What Hacker News says

27 sources
Thanks for the link! That's the older C/TCL/Tk code from the original micropolis repo and OLPC release. Here's the latest version of the code, translated to C++ with better names and comments, in the newer MicropolisCore repo: https://github.com/SimHacker/MicropolisCore/blob/main/packag... Chaim Gingold wrote a book all about "Building SimCity": https://mitpress.mit.edu/9780262547482/building-simcity/ He answered questions about it in this HN discussion: https://news.ycombinator.com/item?id=40698442 For more detail than the article gives, Chaim Gingold drew the whole loop for his book "Building SimCity: How to Put the World in a Machine" (MIT Press, 2024), and kindly let us put his diagrams in the MicropolisCore repo. Chaim Gingold's "SimCity Reverse Diagrams": https://github.com/SimHacker/MicropolisCore/tree/main/images... Simulation Loo
Read the rest
p (Simulate): https://github.com/SimHacker/MicropolisCore/blob/main/images... Map Data Flow: https://github.com/SimHacker/MicropolisCore/blob/main/images... Maps: https://github.com/SimHacker/MicropolisCore/blob/main/images... Map Scan: https://github.com/SimHacker/MicropolisCore/blob/main/images... Make Traffic: https://github.com/SimHacker/MicropolisCore/blob/main/images... Animation Characters: https://github.com/SimHacker/MicropolisCore/blob/main/images... From the micropolis repo README: NOTE: Please See: MicropolisCore https://github.com/SimHacker/MicropolisCore This "micropolis" repo is mainly for historical purpose, and it's probably better to use the newer MicropolisCore repo for development. I rebooted micropolis into the fresh new MicropolisCore repo, without all the old X11/TCL/Tk stuff. MicropolisCore is a C++ rewrite/refactor/cleanup of the original C code into a simulation engine that's independent of the user interface. The full lineage of the code is C64 => Mac => SunOS/NeWS/HyperLook => Unix/X11/TCL/Tk + multiplayer => Linux/X11/TCL/Tk + multiplayer => OLPC/X11/TCL/Tk (single player) => C++ MicropolisCore => C++/SWIG/Python/PyGTK => C++/SWIG/Python/TurboGears/AMF/Flash/OpenLaszlo => C++/Emscripten/Embind/TypeScript/SvelteKit. Now it compiles with emscripten/embind into WASM, and it's possible to run it "headless" in node, or with any kind of user interface in the browser. So if you're making something new, you should use MicropolisCore, but if you're into retrocomputing and want to renovate the TCL version, or even the old PyGTK or Python/TurboGears/AMF/Flash/OpenLaszlo version, then this repo's got what you need! ---- Work in progress live demo (I have't finished the UI yet, but the simulator and tile engine run): https://micropolisweb.com/ Video demo: https://www.youtube.com/watch?v=wlHGfNlE8Os SimCity Micropolis Tile Sets Space Inventory Cellular Automata To Jerry Martin's Chill Resolve: https://www.youtube.com/watch?v=319i7slXcbI
In How to run a city builder on 16 MHz
Set showdead=true and you can see his fanatical arguments in defense of Musk's Nazi salutes, and attacks on other people who disagreed with him, which rightly got his multiple comments flagged dead. His evidence-free Nazi-salute-defending arguments were in such bad faith, ignoring and refusing to address other people's valid counter arguments, the exact same way he is now ignoring and refusing to engage with mine, and sealioning questions whose very premises so wrong they don't deserve the answers I gave him anyway, that his old dead boot licking comments don't deserved to be linked or repeated, since they're a distraction from the useful things I actually linked to. The only thing his comments prove is that he's not arguing in good faith, and can only dispense drive-by evidence-free attacks. You can easily find them yourself if you reall
Read the rest
y don't believe me, but it's a waste of your time, because his comments have no value. Have you looked at any of those valuable links I did post yet, or did you just get stuck in the worthless rabbithole of his posting history? I believe your time would be much better spent reading the links I already provided than his Musk cheerleading and oligarch water carrying and Nazi salute whitewashing. But if you really care about his arguments, why don't you ask him now to explain what he said about Musk, privately? Or doesn't he publish under his own name with his own email address so you can ask him, like I do? I'm more than happy to answer your personal email about my own arguments and projects, and continue this discussion in private: don@donhopkins.com His own ungrounded vitriolic words attacking Jens Mönig's and Brian Harvey's and Seymour Papert's life work like "it's because this is BS and just a toy, it's got no connection to the real world" and "like almost as if the ecosystem simply serves to show off Snap and thus misses the mark" are dismissive, insulting, and provably wrong. So I posted several links and evidence refuting him and defending my friends. Yet then he repeated the same pattern as his full throated defense of Musk's Nazi salutes, by ignoring all the evidence, and reiterating his unsubstantiated false accusations, without providing any objective evidence or coherent arguments or even any citations himself. If you'd like to learn about cool free open source educational projects, please look at the many links I already posted, and what I posted to the Logo discussion. At least spend as much time on those interesting relevent links as you already have wasted reading his uninteresing irrelevent posting history, please. He didn't post any links or evidence or even coherent arguments to support his mistaken and aggressive accusations, while I refuted "this is BS" by linking to and quoting the Wikipedia page about Seymour Papert's Constructionist Education philosophy, "just a toy" by naming and linking to many Snap! projects and demos, and "no connection to the real world" by citing several physical real world connections like TurtleStitch. Yet he dismissed and ignored all of that, and questioned the motives of sincere professional educators and developers of free open source software as merely and illegitimately promoting Snap!, because he isn't arguing in good faith, just attacking, and he didn't bother looking at any of the links, so he still doesn't know what he's talking about. If reading his oligarch-syncophantic posting history (which I was trying to save you from by identifying where he's actually coming from) isn't interesting enough for you, and you still thirst to learn about cool projects, then please look at the links I already posted, read my other recent posts about Logo, and check out some of the other educational projects I've been developing over several decades, which were deeply inspired by Seymour Papert's Constructionism, that I've written a lot about. But if like him you're so offput and triggered by the very mention of diversity, constructionist education, free speech for anyone but Musk, and criticism of an unloving parent so terrible and unaccepting that he publically and vitriolically disparages, abuses, and disowns his own trans daughter in front of millions of people that you have to leap to his defense, then there's nothing I can do for you, sir. But I certainly hope you're not like that, so here are some links in good faith: Logo Adventure for C64 Terrapin Logo: https://donhopkins.medium.com/logo-adventure-for-c64-terrapi... Micropolis: Constructionist Educational Open Source SimCity: https://donhopkins.medium.com/har-2009-lightning-talk-transc... This is Micropolis (open source SimCity) in WebAssembly: https://micropolisweb.com/ This is The Sims 1 character animation system (which I original wrote in C++ 30 years ago) rewritten in TypeScript and WebGL: https://vitamoo.space/ Micropolis and other open source code, documentation, and designs for new educational software: https://github.com/SimHacker/MicropolisCore/ MOOLLM Constructionism skill: https://github.com/SimHacker/moollm/blob/main/skills/constru... MOOLLM Adventure skill: https://github.com/SimHacker/moollm/tree/main/skills/adventu... Adventure Compiler: https://github.com/SimHacker/moollm/blob/main/skills/adventu... Gary Drescher's Schema Mechanism skill from "Made Up Minds" (based on his PhD thesis and book about how children learn, with his advisor Marvin Minsky at the MIT AI Lab): https://github.com/SimHacker/moollm/blob/main/skills/schema-... MOOLLM Play Learn Lift skill: https://github.com/SimHacker/moollm/tree/main/skills/play-le...
In Λ Snap – An inviting programming language for kids and adults for CS study
The original 1989 SimCity box was a Rorschach test that cost Maxis $50k. The cover was a Bakelite toy city simulator appliance with a red MONSTER disaster button, and a stompy T-Rex-looking creature waving over San Francisco on its TV screen. Maxis never called it Godzilla on the box or in the game. Reviewers looked at the inkblot and saw Godzilla anyway. Original monster cover: https://raw.githubusercontent.com/SimHacker/MicropolisCore/m... Revised cover after the lawsuit, monster swapped for a tornado (the MONSTER button survived): https://raw.githubusercontent.com/SimHacker/MicropolisCore/m... In Feb 2024 I emailed Jeff Braun (Maxis co-founder/CEO) and asked what actually happened and how much Maxis had to pay. He wrote back the same day: > Maxis was sued by Toho. We never referred to the name Godzilla, our monster on the box cover was
Read the rest
a T-Rex looking character, but... a few magazine reviews called the monster, Godzilla. That was all it took. Toho called it "confusion in the marketplace". We paid $50k for Godzilla to go away. In all honesty, Toho liked Maxis, they said $50k was the minimum they take for Godzilla infringement. All the box scans are in the Micropolis repo -- high res front, back with the "floods, earthquakes, fires, tornados, meltdowns and monsters" disaster list, side panels, and the platform variants, each with descriptions: https://github.com/SimHacker/MicropolisCore/blob/main/docume... Full email thread: https://github.com/SimHacker/MicropolisCore/blob/main/docume... The back of the box kept advertising monsters as a feature the same year the monster got lawyered off the front. The function names in the code all refered to it like "MakeMonster()", but admittedly there was a "GOD" symbol in the code used to index the Monster sprite likw "GetSprite(GOD)", but Toho could not have know that, since it was a C preprocessor macro that was compiled away in the binary: https://github.com/SimHacker/micropolis/blob/master/micropol...
In Windows brings out the Rorschach test in everyone (2003)
Good point! To respect EA's trademark and the terms of their modifications to the GPL-3 license regarding the use of their SimCity trademark, I renamed the open source version of SimCity to Micropolis, which was its original working title. It would be safe to call this project "PGMicropolis" as long as it wasn't for profit. At the time, there was a disk drive manufacturer by that name, so Will Wright renamed it SimCity. Fortunately the guy who now owns the rights to the Micropolis trademark (and is an old school hacker who really gets it) was kind enough to allow us to use the name for non commercial purposes, under the Micropolis Public Name License. https://github.com/SimHacker/MicropolisCore/blob/main/Microp... Here's the explanation from the MicropolisCore repo's LICENSE file: https://github.com/SimHacker/MicropolisCore/blob/main/LICE
Read the rest
NS... >MICROPOLIS LICENSING >The Micropolis project operates under two important licenses: >1. The Micropolis GPL License Notice - This is the GNU General Public License with additional terms added by Electronic Arts to protect the SimCity trademark while allowing the code to be freely used and modified. >2. The Micropolis Public Name License - This license governs the use of the "Micropolis" name itself, which is a registered trademark of Micropolis Corporation. >We extend our sincere gratitude to Electronic Arts <https://www.ea.com> for their generosity in releasing the SimCity source code under an open-source license, and to Micropolis Corporation <https://www.micropolis.com> for allowing the community to use the Micropolis name for this open-source city simulation project. Please respect both Electronic Arts' SimCity trademark and Micropolis Corporation's Micropolis trademark by adhering to the terms of these licenses. Additionally, we ask all users to please honor the terms of the <https://www.gnu.org/licenses/gpl-3.0.html> GNU General Public License v3, which protects the freedoms that allow this project to exist and thrive as open-source software. More details, and another cautionary tale about accidentally getting sued for trademark infringement: https://news.ycombinator.com/item?id=46981012 >This matters more than people think. Jeff Braun, CEO of Maxis, told me this story: >"Maxis was sued by Toho. We never referred to the name Godzilla, our monster on the box cover was a T-Rex looking character, but... a few magazine reviews called the monster, Godzilla. That was all it took. Toho called it 'confusion in the marketplace'. We paid $50k for Godzilla to go away. In all honesty, Toho liked Maxis, they said $50k was the minimum they take for Godzilla infringement." >So please: call the game Micropolis, not SimCity, or EA's lawyers may come knocking. And unlike Toho, EA and their Saudi investors and Jarod Kushner might want to use their bone saws on you, which are much worse than Godzilla. If any busy-body lawyers find this thread and actually want to go after someone's who's disparaging their trademark, they should look into this instead of open source projects: https://news.ycombinator.com/item?id=43952567 >I let the domain "micropolisonline.com" expire, which I was using for the old OpenLaszlo/Flash Python/SWIG/C++ client/server based version of open source SimCity, and somebody took it over and replaced it with AI generated claptrap, stealing a lot of my own and other's images without any credit. It even promises the source code, but doesn't actually link to it, just has promises and placeholders. >It totally misrepresents what Micropolis is, which was based on the original SimCity classic, and confuses it with all the subsequent versions of SimCity and other made-up stuff. And it never mentions the GPL-3 license, EA's license and restrictions on the use of their SimCity trademark, or Micropolis's license to use their trademark. I have no idea what the point of it is. Here's some more interesting stuff about applying machine learning and LLMs to Micropolis: https://news.ycombinator.com/item?id=46981043 >Sam Earle's fractal neural network approach (https://arxiv.org/pdf/2002.03896) is exactly this kind of thing. His key trick: recursive weight-sharing in fractal convolutional blocks, so each column of the network acts as a continuous-valued cellular automaton ticking different numbers of times. The deepest column gets a 33x33 receptive field -- enough to connect power across an entire 32x32 map in one forward pass. >The agents discovered power-plant + residential pairing, road placement for density, zone clustering by type, and traffic-avoiding road layouts. When stuck at local optima, a human player could intervene (deleting power plants) to force re-exploration -- and the agent would improve its design. >The paper was 2019, before LLMs were doing this kind of thing. Different paradigm (RL on tile grids vs. LLMs on coordinate text), same hard problem. https://news.ycombinator.com/item?id=46981059 >Sam Earle did exactly this with RL agents trained via quality-diversity methods on Micropolis: https://github.com/smearle/gym-city >[...] Here's more about my plans for making a multi player version of Micropolis with time travel, branching, and merging, by using github as a social network and MMPORG platform (when it's not down ;): https://github.com/SimHacker/moollm/blob/main/designs/sims/s...
In PGSimCity - How PostgreSQL Works
I've been porting Micropolis (SimCity Classic) to WASM / WebGPU / Svelte 5. Emscripten + Embind compile the C++ engine and glue it to TypeScript/Svelte/Runes/Reactivity; TypeScript owns UI, rendering, and callback handlers. I agree with the article's main lessons: wasm32 pointer size, don't serialize structs with pointers, debug native 32-bit when you can, WebGL/WebGPU is stricter than desktop GL, Emscripten export flags still bite. I hit some of the same categories; the parts that were actually tricky for Micropolis are below. Svelte 5 runes ($state, $derived, etc.) work in plain .ts modules, not just .svelte templates. That matters because the WASM bridge is a reactive module the HUD, command bus, and Vitest all import -- not a component-only trick. The file has to be MicropolisReactive.svelte.ts so runes compile under the same Vite/Sve
Read the rest
lteKit pipeline as the app; plain .ts breaks in Node with "$state is not defined". Embind API surface -- what to expose and what to leave out: https://github.com/SimHacker/MicropolisCore/blob/main/packag... // This file uses emscripten's embind to bind C++ classes, // C structures, functions, enums, and contents into JavaScript, // so you can even subclass C++ classes in JavaScript, // for implementing plugins and user interfaces. // // Wrapping the entire Micropolis class from the Micropolis (open-source // version of SimCity) code into Emscripten for JavaScript access is a // large and complex task, mainly due to the size and complexity of the // class. The class encompasses almost every aspect of the simulation, // including map generation, simulation logic, user interface // interactions, and more. The comments in that file go on to describe the strategy for wrapping: Core Simulation Logic, Memory and Performance Considerations, Direct Memory Access, User Interface and Rendering, Callbacks and Interactivity, and Optimizations. The engine callback virtual interface bridged C++ to JS via JSCallback: https://github.com/SimHacker/MicropolisCore/blob/main/packag... In the old NeWS/Hyperlook, TCL/Tk/X11, SWIG/Python/PyGTK, and SWIG/Python/TurboGears/AMF/Flash versions, this callback interface used to be a stringly typed general purpose event callback interface, which I tightened up into a strict C++ interface and corresponding typescript interface, so embind could help me integrate it safely and cleanly with TypeScript and Svelte Runes. TypeScript handlers that update rune-backed state (sendMessage, didTool, budget hooks, etc.): https://github.com/SimHacker/MicropolisCore/blob/main/apps/m... Simulator attach/detach, singleton engine load, wiring JSCallback into Micropolis: https://github.com/SimHacker/MicropolisCore/blob/main/apps/m... The pattern: C++ fires callbacks with enough context for the UI; TS updates $state; components read micropolisReactive (peek / poke / memory / getSnapshot) instead of calling Embind or touching HEAP* directly. That is where the rubber hits the road for interactivity. Heap access is its own footgun. Emscripten may expose Module.wasmMemory, HEAPU16, or neither until init; some getters throw if you read too early. Centralized helper: https://github.com/SimHacker/MicropolisCore/blob/main/apps/m... Bridge design, Vitest against real WASM, teardown order with Embind lifetimes: https://github.com/SimHacker/MicropolisCore/blob/main/docume... Map rendering: WebGPU tile renderer with canvas fallback (legacy WebGL frozen, now reimplementing in WebGPU). The renderer reads 16 bit flags + tile indices from direct simulator memory views into WASM linear memory (mapData / mopData), not per-frame Embind copies. https://github.com/SimHacker/MicropolisCore/blob/main/packag... https://github.com/SimHacker/MicropolisCore/blob/main/docume... City saves are a defined binary format (.cty), not fwrite of engine structs. Live map data is views into WASM linear memory (mapData / mopData), not embedded native pointers -- same idea as the article's side-table fix, but that is how this codebase is already structured. Why I find this stack interesting: original SimCity engine lineage, narrow Embind surface on purpose, reactive TS facade so automation and UI share one sim without reviving the old Python/SWIG/pyGTK path. Sprites (trains, choppers, generic orange monsters wrecking chaos and havoc -- definitely not Godzilla [TM], but possibly Trump adjacent) simulate in C++; compositing them in the WebGPU path is still work in progress. The WebGPU renderer is being built as a general stack with pluggable layers, including Sims content rendering (characters, animations, terrain, objects, walls, floors, ui effects, etc). Character animation demo: https://vitamoo.space VitaMoo code: https://github.com/SimHacker/MicropolisCore/tree/main/packag... Unified WebGPU Renderer: https://github.com/SimHacker/MicropolisCore/blob/main/docume... Render Core Package: https://github.com/SimHacker/MicropolisCore/blob/main/docume... Renderer Plugin Roadmap: https://github.com/SimHacker/MicropolisCore/blob/main/docume... Live Micropolis tile renderer and simulator demo (no other ui yet, work in progress): https://micropolisweb.com Demo of the simulator, cellular automata, and tile engine to Jerry Martin's music: https://www.youtube.com/watch?v=319i7slXcbI Repo: https://github.com/SimHacker/MicropolisCore
In Ported my C game to WASM, here's every bug that I hit
Also, Fabian Wesner's posted about using Claud Code to analyze the original micropolis repo's code and documentation to generate a new version. Here is a deep dive "podcast" he generated (presenting Claud's analysis in a conversational format) that describes the work. I listened to it, and it got the important trademark and licensing issues right, was quite comprehensive and technically accurate, up until the end where they said maybe there's something to learn about city planning from SimCity! ;) https://drive.google.com/file/d/1SGAkLIb4CQMPKU7TJ2sRdEjc0Dh... It pretty much parallels the analysis docs in his repo, which are also quite accurate: https://github.com/FabianWesner/micropolis/tree/master/docs This lightning talk I gave at HAR 2009 goes into what you can actually learn from playing SimCity/Micropolis (and reading and extending
Read the rest
the code), thanks to Seymour Papert's and Alan Kay's philosophy of Constructionist Education, and it's much wider and more generally useful than just city planning: https://donhopkins.medium.com/har-2009-lightning-talk-transc... To save you the indignity of LinkedIn scraping your browser extensions, here is a copy of Fabian Wesner's post and my response with the link spying urls resolved: https://www.linkedin.com/posts/fabian-wesner_micropolis-simc... Fabian Wesner | CTO | Passionate about AI and Entrepreneurship | 1 month ago Claude Code is extremely good at documenting legacy software. That's a huge blessing, especially when the original developers are no longer around or are finally ready to retire. If you haven't tried this, you might be missing out. So I did it for you. #Micropolis is the open-source release of the original #SimCity, published by Electronic Arts in 1989. EA released the source code under GPLv3 in 2008 for the One Laptop Per Child project. The codebase is decades old, and there's likely no one left who knows it inside out. SimCity was one of the very first games I played, back in 1990 on my father's 286. Just a few months after the Wall fell. So this one is personal. I let Claude Code read the entire codebase and write a full documentation. As far as I can see, it looks correct and complete. I'm no expert on this particular codebase, but that's exactly the point: there might be no expert left on earth. I have tried this on other software where I am an expert, and the results are surprisingly accurate. You can find the resulting docs and the prompt here: https://github.com/FabianWesner/micropolis/tree/master/docs I also converted the docs into a podcast episode for easier consumption: https://drive.google.com/file/d/1SGAkLIb4CQMPKU7TJ2sRdEjc0Dh... Enjoy! I know I’m not the first to use Claude Code on this treasure and - of course - I already rebuilt the game with JavaScript. More on this tomorrow! Don Hopkins | Full Stack Generalist AI Engineer Although I may have two feet firmly planted in mid-air, I am still on Earth and know the code. I reviewed it and am I'm impressed with this documentation, which even caught my experimental Eliza chatbot easter egg in the PyGTK version! Importantly it correctly covered all the licensing and trademark issue, and mentioned that active development has moved on to the cleaned up and renovated MicropolisCore repo. https://github.com/SimHacker/MicropolisCore Here are the latest design docs: https://github.com/SimHacker/MicropolisCore/tree/main/design... The documentation you generated does a good job at mapping out and comparing the several different versions of the code. Albert Hofkamp and I cleaned up and refactored the code into C++ MicropolisCore (which I integrated with Python with SWIG, and later WebAssembly with emscripten/embind), and we wrote Doxygen comments and documentation in the code. Chaim Gingold deeply studied multiple versions of the SimCity source code for his PhD thesis in Play Design, and interviewed many people involved, then wrote the definitive magnum opus "Building SimCity". Chaim is the one person on Earth who understands SimCity better than Will Wright! https://direct.mit.edu/books/monograph/5791/Building-SimCity... >Building SimCity: How to Put the World in a Machine >A deep dive into the trailblazing simulation game SimCity, situating it in the history of games, simulation, and computing. Building SimCity explores the ... Good grief you can't hide easter eggs any more! "Additionally, the web version includes: PacBot -- an AI robot that follows roads toward heavy traffic and "eats" cars, reducing traffic density. This was an early experiment in programmable game avatars." PacBot appears one minute into this video: https://youtu.be/8snnqQSI0GE?t=56 >Micropolis Online (SimCity) Web Demo. A demo of the open source Micropolis Online game (based on the original SimCity Classic source code from Maxis), running on a web...
In Reverse Engineering SimTower
I spoke with Yoot about it recently. There are some issues with Nintendo and licensing that may take some time to work through. My fingers are crossed, but it might take a while and require patience. We all want it to happen though! Meanwhile I'm working on Micropolis (based on the original SimCity Classic code, cleaned up, and compiled with Emscripten into WASM), and also reimplementing The Sims character animation system and content management and creation system in TypeScript with WebGPU and MOOLLM. ;) Micropolis WASM + WebGL tile renderer demo: https://micropolisweb.com MicropolisCore repo: https://github.com/SimHacker/MicropolisCore Micropolis design docs: https://github.com/SimHacker/MicropolisCore/tree/main/design... Sims character animation demo with WebGPU renderer: https://vitamoo.space Source code: https://github.com/DnfJeff/Si
Read the rest
mObliterator_Suite/tree/main/vi... Design docs: https://github.com/DnfJeff/SimObliterator_Suite/tree/main/vi... Designs for creating LLM driven Sims content editing and creation tools, uplifting and simulating The Sims in MOOLLM, and downloading The Sims content back into the original game: https://github.com/SimHacker/moollm/tree/main/designs/sim-ob... >"What would your Sims say if they could finally talk to you?" >Two-way bridge between The Sims 1 save files and MOOLLM. Characters, objects, and pets step between a 26-year-old game VM and an LLM-powered universe, retaining and synchronizing their parallel existences. >The One-Line Version >Drag a 25-year-old Sims save file in. Watch the character wake up. Have a conversation with them. Send them home changed. The Uplift: Sims ↔ MOOLLM Character Bridge https://github.com/SimHacker/moollm/blob/main/designs/sim-ob... It's all still a work in progress that I hack on when I have spare time (and spare money for tokens), so no ship date known! ;)
In Reverse Engineering SimTower
I'm thrilled that you and other people are taking it and running with it! That was the whole point of making it free: it was inspired by Seymour Papert's Constructionist philosophy, Alan Kay's ideas, and the mission of the OLPC. EA granted the right to use the trademark "SimCity" only if it passed their QA process, and it was quite an ordeal hand holding their QA department through running Linux in a VM on Windows to test it. Since I never want to go through that ever again, I asked Will Wright for a suggestion about the name, and he recommended its original working title, Micropolis. At the time, he had to change the name to SimCity because Micropolis was a hard disk drive manufacturer. They eventually changed names then went out of business, but was recently restructured under the name Micropolis GmbH. https://en.wikipedia.org/wiki/Micr
Read the rest
opolis_Corporation Fortunately the owner of Micropolis GmbH is really cool, an old school hacker, who was generous enough to grant the Micropolis Public Name License that allows the game to use the name Micropolis under reasonable conditions: https://github.com/SimHacker/MicropolisCore/blob/main/Microp... Check out his BBS, robotics, and data storage primers: https://www.micropolis.com/micropolis-bbs-primer https://www.micropolis.com/micropolis-robotics-primer https://www.micropolis.com/micropolis-data-storage-primer
In Show HN: AI agents play SimCity through a REST API
Sam Earle did exactly this with RL agents trained via quality-diversity methods on Micropolis: https://github.com/smearle/gym-city For running locally, I'd recommend the MicropolisCore repo over the one linked in the original post. MicropolisCore is a clean C++ rewrite that compiles to WASM -- runs headless in Node or in any browser: https://github.com/SimHacker/MicropolisCore The Raspberry Pi wall display idea is great. The simulation is lightweight enough for that. The simulator runs and I've written a tile rendering engine in TypeScript/WebGL, but I haven't finished the user interface. (But the Space Inventory works!) Live demo: https://micropolisweb.com Here is a video demo of how it works: Micropolis Web Demo 1: https://www.youtube.com/watch?v=wlHGfNlE8Os For fun, I added all the classic tile sets, and it can run a couple of cellular
Read the rest
automate rules as well as the game simulator. Here's a video to some original music by Jerry Martin, who composed the music in The Sims and SimCity (see the above video and the keyboard shortcuts in the help window to understand what's going here): SimCity Micropolis Tile Sets Space Inventory Cellular Automata To Jerry Martin's Chill Resolve: https://www.youtube.com/watch?v=319i7slXcbI Here's more about my plans for making a multi player version of Micropolis with time travel, branching, and merging, by using github as MMPORG platform (when it's not down ;): https://github.com/SimHacker/moollm/blob/main/designs/sims/s... MOOLLM's "micropolis" skill is still in the design stages, but here's what I've started, which starts by describing the multi player version of SimCity I released in 1993: SimCityNet announcement (1993): http://www.art.net/~hopkins/Don/simcity/simcity-announcement... Multi Player SimCityNet for X11 on Linux: https://www.youtube.com/watch?v=_fVl4dGwUrA micropolis skill README, including GitHub-as-MMPORG (MicropolisHub), and Alan Kay's Critique and Vision: https://github.com/SimHacker/moollm/tree/main/skills/micropo... micropolis skill prototype: https://github.com/SimHacker/moollm/blob/main/skills/micropo... More context about what MOOLLM is: https://github.com/SimHacker/moollm And how it extends Anthropic Skills with 8 important features: MOOLLM: A Microworld Operating System for LLM Orchestration: https://github.com/SimHacker/moollm/blob/main/designs/LEELA-... MOOLLM is kind of like The Sims meets LambdaMOO in Cursor then steals all the great ideas from Factorio: Factorio MOOLLM Design: https://github.com/SimHacker/moollm/blob/main/designs/FACTOR... Factorio Logistics Protocol: https://github.com/SimHacker/moollm/blob/main/designs/factor... logistic-container skill: README.md: https://github.com/SimHacker/moollm/tree/main/skills/logisti... SKILL.md: https://github.com/SimHacker/moollm/blob/main/skills/logisti...
In Show HN: AI agents play SimCity through a REST API
I developed the open source version of this game, called Micropolis. Great to see more people building on it! A few years before the LLM era, Sam Earle took a different approach -- training reinforcement learning agents with fractal neural networks to play Micropolis, optimizing for population at variable map scales: Using Fractal Neural Networks to Play SimCity 1 and Conway’s Game of Life at Variable Scales: https://arxiv.org/pdf/2002.03896 His gym-city repo wraps Micropolis as an OpenAI Gym environment: https://github.com/smearle/gym-city The interesting finding was that fractal architectures with weight-sharing let agents transfer local strategies (zone placement, power connection) into deeper networks with larger receptive fields -- giving them both local and global spatial reasoning from one set of weights. But even those agents coul
Read the rest
dn't manage demand at larger scales, so the spatial reasoning problem discussed here has been hard for RL too, not just LLMs. He described the project and we discussed it on the Micropolis repo in this issue: https://github.com/SimHacker/micropolis/issues/86 He used the old PyGTK interface for his project: https://github.com/SimHacker/micropolis/tree/master/Micropol... These days I'd recommend the MicropolisCore repo instead. It's a C++ rewrite independent of any UI, compiles to WASM via Emscripten/Embind, and runs headless in Node or with any browser UI: https://github.com/SimHacker/MicropolisCore Live demo: https://micropolisweb.com One note on naming: the open source license from EA requires using "Micropolis" rather than "SimCity" (which is EA's trademark). The Micropolis Public Name License allows use of the original name: https://github.com/SimHacker/micropolis/blob/master/Micropol... This matters more than people think. Jeff Braun, CEO of Maxis, told me this story: "Maxis was sued by Toho. We never referred to the name Godzilla, our monster on the box cover was a T-Rex looking character, but... a few magazine reviews called the monster, Godzilla. That was all it took. Toho called it 'confusion in the marketplace'. We paid $50k for Godzilla to go away. In all honesty, Toho liked Maxis, they said $50k was the minimum they take for Godzilla infringement." So please: call the game Micropolis, not SimCity, or EA's lawyers may come knocking. And unlike Toho, EA and their Saudi investors and Jarod Kushner might want to use their bone saws on you, which are much worse than Godzilla.
In Show HN: AI agents play SimCity through a REST API
When I ported the Mac version of SimCity to Unix using NeWS/HyperLook for the front end, I naturally had to split it into and engine (the C simulator back-end "client"), and the user interface (the PostScript/NeWS/HyperLook front-end "server"), and define a network messaging interface (API) between them. https://donhopkins.medium.com/hyperlook-nee-hypernews-nee-go... That made it a lot easier to later port it to X11/TCL/Tk, since it then had a well defined interface between the simulator and UI, by exposing the same API to TCL (via C calls) like I'd exposed to NeWS (via network messages). It was more monolithic though, integrated into TCL/Tk in the same process instead of talking to the user interface over a socket like a modern web client/server (but the web switches the terms client and server). https://www.youtube.com/watch?v=_fVl4dGwU
Read the rest
rA That separation made it much easier to later refactor the simulation engine into MicropolisCore, a C++ library that was totally independent of the UI. The C++/SWIG/Python/TurboGears/AMF/Flash/OpenLaszlo version is a more traditional (for the time) client/server web stack: https://www.youtube.com/watch?v=8snnqQSI0GE More recently I compiled the C++ simulator engine with emscripten into a WASM module, so the simulator and the UI can run in the browser client, with the UI being implemented in TypeScript/canvas/WebGL: https://micropolisweb.com/ https://github.com/SimHacker/MicropolisCore https://donhopkins.medium.com/open-sourcing-simcity-58470a27...
In Show HN: Micropolis/SimCity Clone in Emacs Lisp
Emscripten has a handy tool called "Embind" for binding JavaScript/TypeScript and C/C++/whatever code. It's underappreciated and not well documented all in one place, but here is a soup-to-nuts summary. Emscripten + Embind allow you to subclass and implement C++ interfaces in TypeScript, and easily call back and forth, even pass typed function pointers back and forth, using them to call C++ from TypeScript and TypeScript from C++! Embind: https://emscripten.org/docs/porting/connecting_cpp_and_javas... Interacting with Code: https://emscripten.org/docs/porting/connecting_cpp_and_javas... Embind's bind.cpp plumbing: https://github.com/emscripten-core/emscripten/blob/main/syst... C Emscripten macros (like EM_ASM_): https://livebook.manning.com/book/webassembly-in-action/c-em... Emscripten’s embind: https://web.dev/articles/embind I'm using i
Read the rest
t for the WASM version of Micropolis (open source SimCity). The idea is to be able to cleanly separate the C++ simulator from the JS/HTML/WebGL user interface, and also make plugin zones and robots (like the monster or tornado or train) by subclassing C++ interface and classes in type safe TypeScript! emscripten.cpp binds the C++ classes and interfaces and structs to JavaScript using the magic plumbing in "#include <emscripten/bind.h>". There is an art to coming up with an elegant interface at the right level of granularity that passes parameters efficiently (using zero-copy shared memory when possible, i.e. C++ SimCity Tiles <=> JS WebGL Buffers for the shader that draws the tiles) -- see the comments in the file about that): emscripten.cpp: https://github.com/SimHacker/MicropolisCore/blob/main/Microp... /** * @file emscripten.cpp * @brief Emscripten bindings for Micropolis game engine. * * This file contains Emscripten bindings that allow the Micropolis * (open-source version of SimCity) game engine to be used in a web * environment. It utilizes Emscripten's Embind feature to expose C++ * classes, functions, enums, and data structures to JavaScript, * enabling the Micropolis game engine to be controlled and interacted * with through a web interface. This includes key functionalities * such as simulation control, game state management, map * manipulation, and event handling. The binding includes only * essential elements for gameplay, omitting low-level rendering and * platform-specific code. */ [...] //////////////////////////////////////////////////////////////////////// // This file uses emscripten's embind to bind C++ classes, // C structures, functions, enums, and contents into JavaScript, // so you can even subclass C++ classes in JavaScript, // for implementing plugins and user interfaces. // // Wrapping the entire Micropolis class from the Micropolis (open-source // version of SimCity) code into Emscripten for JavaScript access is a // large and complex task, mainly due to the size and complexity of the // class. The class encompasses almost every aspect of the simulation, // including map generation, simulation logic, user interface // interactions, and more. [...] class_<Callback>("Callback") .function("autoGoto", &Callback::autoGoto, allow_raw_pointers()) [...] Here's the WebGL tile renderer that draws the tiles directly out of a Uint16Array pointing into WASM memory: https://github.com/SimHacker/MicropolisCore/blob/main/microp... The corresponding C++ source and header and TypeScript files define the callback interface and plumbing: callback.h defines the abstract Callback interface, as well as a ConsoleCallback interface that just logs to the JS console, for debugging: callback.h: https://github.com/SimHacker/MicropolisCore/blob/main/Microp... /** * @file callback.h * @brief Interface for callbacks in the Micropolis game engine. * * This file defines the Callback class, which serves as an interface * for various callbacks used in the Micropolis game engine. These * callbacks cover a wide range of functionalities including UI * updates, game state changes, sound effects, simulation events, and * more. The methods in this class are virtual and intended to be * implemented by the game's frontend to interact with the user * interface and handle game events. */ class Callback { public: virtual ~Callback() {} virtual void autoGoto(Micropolis *micropolis, emscripten::val callbackVal, int x, int y, std::string message) = 0; [...] callback.cpp implements just the concrete ConsoleCallback interface in C++ with "EM_ASM_" glue to call out to JavaScript to simply log the parameters of each call: callback.cpp: https://github.com/SimHacker/MicropolisCore/blob/main/Microp... /** * @file callback.cpp * @brief Implementation of the Callback interface for Micropolis game * engine. * * This file provides the implementation of the Callback class defined * in callback.h. It includes a series of methods that are called by * the Micropolis game engine to interact with the user interface. * These methods include functionalities like logging actions, * updating game states, and responding to user actions. The use of * EM_ASM macros indicates direct interaction with JavaScript, typical * in a web environment using Emscripten. */ js_callback.h contains an implementation of the Callback interface that caches a "emscripten::val jsCallback" (an enscripten value reference to a JS object that implements the interface), and uses jsCallback.call to make calls to JavaScript: js_callback.h: https://github.com/SimHacker/MicropolisCore/blob/main/Microp... #include <emscripten/val.h> #include "callback.h" class JSCallback : public Callback { public: explicit JSCallback(emscripten::val jsCallback) : Callback(), jsCallback(jsCallback) {} // Implement all pure virtual functions from Callback void autoGoto(Micropolis *micropolis, emscripten::val callbackVal, int x, int y, std::string message) override { jsCallback.call<void>("autoGoto", emscripten::val(micropolis), callbackVal, x, y, message); } [...] private: emscripten::val jsCallback; }; Then emscripten/embind generates a TypeScript file that defines the JS side of things: micropolisengine.d.ts: https://github.com/SimHacker/MicropolisCore/blob/main/microp... // TypeScript bindings for emscripten-generated code. Automatically generated at compile time. [...] export interface Callback { autoGoto(_0: Micropolis, _1: any, _2: number, _3: number, _4: EmbindString): void; [...] export type MainModule = WasmModule & typeof RuntimeExports & EmbindModule; export default function MainModuleFactory (options?: unknown): Promise<MainModule>; Then you can import that TypeScript interface (using a weird "<reference path=" thing I don't quite understand but is necessary), and implement it in nice clean safe TypeScript: https://github.com/SimHacker/MicropolisCore/blob/main/microp... /// <reference path="../types/micropolisengine.d.ts" /> import type { Micropolis, JSCallback } from '../types/micropolisengine.d.js'; // Micropolis Callback Interface Implementation export class MicropolisCallbackLog implements JSCallback { verbose: boolean = false; autoGoto(micropolis: Micropolis, callbackVal: any, x: number, y: number, message: string): void { console.log('MicropolisCallbackLog: autoGoto:', 'x:', x, 'y:', y, 'message:', message); } It's all nice and type safe, and Doxygen will even generate documentation for you: https://micropolisweb.com/doc/classJSCallback.html And it even works, and it's pretty fast! (Type "9" to go super fast, but for the love of god DO NOT PRESS THE SPACE BAR!!!) https://micropolisweb.com
In When Is WebAssembly Going to Get DOM Support?
I let the domain "micropolisonline.com" expire, which I was using for the old OpenLaszlo/Flash Python/SWIG/C++ client/server based version of open source SimCity, and somebody took it over and replaced it with AI generated claptrap, stealing a lot of my own and other's images without any credit. It even promises the source code, but doesn't actually link to it, just has promises and placeholders. It totally misrepresents what Micropolis is, which was based on the original SimCity classic, and confuses it with all the subsequent versions of SimCity and other made-up stuff. And it never mentions the GPL-3 license, EA's license and restrictions on the use of their SimCity trademark, or Micropolis's license to use their trademark. I have no idea what the point of it is. https://micropolisonline.com/ https://micropolisonline.com/source-code/ >
Read the rest
How to Access the Source Code: For those eager to explore the Micropolis Online Source Code, it is available on our dedicated GitHub repository. Visit [Link] to access the repository, where you can browse the code, contribute to ongoing projects, or initiate your own. The source code is actually not at [Link] but at: https://github.com/SimHacker/MicropolisCore Not even so much as a link to the my demo! https://www.youtube.com/watch?v=8snnqQSI0GE They could be in some legal jepordy since they didn't mention or link to the Micropolis GPL License or the Micropolis Public Name License, which they may be violating. https://github.com/SimHacker/MicropolisCore/blob/main/Microp... https://github.com/SimHacker/MicropolisCore/blob/main/Microp... The have a "Meet the Team" page that mentions nobody, just hand waves about "we" and the community. They couldn't even bother to generate generic looking fake profiles of non-existent people. Suffice it to say I never heard back from anyone after using the "Contact Us" page. They even have a cute little Terms and Conditions page with their very own license, which doesn't allow anyone to do to them what they did to me, and is not particularly GPL-v3 compatible: https://micropolisonline.com/terms-conditions/ >License to Use Micropolis Online >Unless otherwise stated, Micropolis Online and/or its licensors own the intellectual property rights for all material on Micropolis Online. All intellectual property rights are reserved. You may view and/or print pages from micropolisonline.com for your own personal use subject to restrictions set in these terms and conditions. >You must not: >Republish material from micropolisonline.com Sell, rent, or sub-license material from micropolisonline.com Reproduce, duplicate, or copy material from micropolisonline.com They also claim all rights to all user created content: >By displaying Your Content, you grant Micropolis Online a non-exclusive, worldwide irrevocable, sub-licensable license to use, reproduce, adapt, publish, translate, and distribute it in any and all media. Kind of ironic for an LLM to go around stealing people's content, then telling them that not only can't anyone copy it back, but it owns the rights to everything anyone else may contribute in the future.
In A critical look at MCP
Thank you for the kind feedback and encouragement! I'd love to write a book, but it's an enormous investment of time and effort, so I write about it here off and on when I can. I'm working on collecting it all and publishing it in a blog in my rare spare time. Chaim Gingold wrote an excellent tour-de-force book all about Building SimCity, which he invested many years in, and I can only dream and aspire to write something as deep and comprehensive as that, but writing on Hacker News and collecting it in blog will have to do for now. Check out the Hacker News discussion about Chaim's book, where he popped in and answered questions: Building SimCity: How to put the world in a machine (mitpress.mit.edu) 440 points by jarmitage 8 months ago | hide | past | favorite | 168 comments https://news.ycombinator.com/item?id=40698442 chaimgingold 8 mon
Read the rest
ths ago | next [–] Hi! I wrote this book. Ask me anything. I also was a designer on Spore. I'm also trying to feed my 8 month old lunch and he is very excited to asn``wer anything too. https://news.ycombinator.com/item?id=40695565 DonHopkins 8 months ago | parent | context | favorite | on: SimCity in the web browser using WebAssembly and O... Micropolis Web Demo 1: https://www.youtube.com/watch?v=wlHGfNlE8Os Micropolis Web is the browser based version of Micropolis (open source SimCity), that uses WebAssembly, WebGL, and SvelteKit. Based on the original SimCity Classic code, designed by Will Wright, ported by Don Hopkins. This first demo shows an early version that runs the WebAssembly simulator and animates the tiles with WebGL, but most of the user interface is still a work in progress. Live MicropolisWeb Site: https://MicropolisWeb.com GitHub Repo with source code and documentation: https://github.com/SimHacker/MicropolisCore Much more Info in Chaim Gingold's book, "Building SimCity": https://mitpress.mit.edu/9780262547482/building-simcity/ Chaim Gingold's "SimCity Reverse Diagrams": https://smalltalkzoo.thechm.org/users/Dan/uploads/SimCityRev... Micropolis Web Space Inventory Cellular Automata Music 1: https://www.youtube.com/watch?v=BBVyCpmVQew Micropolis Web is the browser based version of Micropolis (open source SimCity), that uses WebAssembly, WebGL, and SvelteKit. Based on the original SimCity Classic code, designed by Will Wright, ported by Don Hopkins. This first video has music by Juho Hietala, Blamstrain, and the Space Inventory Cellular Automata is performed by Don Hopkins. Music by Juho Hietala, Blamstrain: https://blamstrain.com/
In The Sims Game Design Documents (1997)
In this recent discussion of "SimCity in the web browser using WebAssembly and OpenGL (micropolisweb.com)", I posted a description of a couple of general purpose cellular automata optimization techniques for CPUs (which don't apply to GPU cores working in parallel, but optimize the edge condition branching and memory bandwidth of a serial scanning CPU implementation). I used both techniques in my CAM6 simulator, and the SimCity/Micropolis code, to run CA in SimCity's tiles. The edge condition optimization eliminates the eight conditional branches in the inner loop checking for edge conditions, and the memory optimization eliminates six out of nine loads per cell in the inner loop. Here are the comments about optimization from the CAM6 code: https://github.com/SimHacker/CAM6/blob/master/javascript/CAM... // Optimization Techniques //
Read the rest
// Extra copying is eliminated by swapping between two cell buffers, // one for the past and the other for the future. After applying the // rule, the past cell buffer becomes the future, and the future // becomes the past. It's necessary to have two buffers, because // you can't apply cellular automata in-place in one buffer, since // you would stomp on your past neighbors whose future you just // computed, since the neighbors above and to the left would be // from the future instead of the past. // // Edge conditions eliminated from inner loop by making cell buffers // two cells wider and taller, and wrapping edges around to the // extra edge cells before applying rule, so the inner loop does not // have to check for edge conditions to wrap the cells, and other // edge treatments can be applied besides wrapping, like clamping or // reflecting. // // Index table lookup based rules, that allow you to define rules in // JavaScript in terms of their neighbors, which are then applied to // every possible combination of neighbor states, to generate a // lookup table that is used by the neighborhood to evaluate the // rule without running a lot of JavaScript code. This is how the // CAM6 hardware works, and the rule tables are compatible with its // rule tables. The hardware concatenates the bits of the neighbors // into an index that is used to look up the next cell value in the // lookup table. It's not clear if this is actually any faster in // software, because it's a software emulation of a hardware // optimization, and depends a lot on the rule and the code that // implements it, but at least it lets you write your rule // definitions clearly without worrying about efficiency, and also // translate the Forth rules defined in the Cellular Automata // Machine to JavaScript (or use old rule tables generated by Forth // if you can find them), and run them in the simulator. // // JavaScript code templates for neighborhood functions, rules, // tools, colormap generators, etc, with slots that let rules inject // custom code into the inner loop, disable unnecessary code, // calculate parameters, inline constants, etc. This enables // neighborhoods to be much more general purpose, and not only // deeply parametrizable but also arbitrarily extensible, // supporting complex rule definition, as well as real time analysis // and event reporting (like the cell value histogram). And it also // enabled users to play around with writing their own rules and // modifying and extending existing ones, and they will still run // efficiently. You can play with the SimCity/Micropolis CA by disobeying the important safety warning about not opening up the Space Inventory, by pressing the space bar a few times: https://micropolisweb.com Here's a video I recoded of playing around with that to music: SimCity Micropolis Tile Sets Space Inventory Cellular Automata To Jerry Martin's Chill Resolve: https://www.youtube.com/watch?v=319i7slXcbI The musical style of "Chill Resolve" may ring a bell, because Jerry Martin is the musician who composed the music for The Sims and SimCity 2000 and many other Maxis games, and he has some more great free music on his web site: https://boombamboom.com/ And here is a longer demo that explores some of the more subtle effects, starting out with an homage to "Powers of 10", with some more great music by Juho Hietala, Blamstrain: Micropolis Web Space Inventory Cellular Automata Music 1: https://www.youtube.com/watch?v=BBVyCpmVQew The space bar randomly toggles between two CA rules (one heat diffusion with randomized parameters, and one combination of Anneal, Life, and Brain's Brain). Here's the code that implements the cellular automata running in SimCity's 16 bit tile memory. I originally wrote it a long time ago in C on a 68k Sun 3 Workstation, so it uses some terribly ugly C macrology. This code is written in C++ and compiled to WebAssembly, and is adapted to deal with SimCity's in-memory tile layout that doesn't have an gutter around it, so it performs an extra copy, so isn't optimal. But if you were implementing a pure optimized cellular automata not duct-taped and bailing-wired into an existing game, you could just use two buffers of the same size with gutters around them, and swap their pointers each iteration, to eliminate the extra copy of all the cells, of course: https://github.com/SimHacker/MicropolisCore/blob/main/Microp... The heatWrap parameter switches between different edge condition wrapping/clamping modes applied to the gutters, defaulting to 4, which wraps the edges around like a torus. You can play with the CAM6 emulator here, which is written in JavaScript. Click the square in the upper right corner to show the controls, and switch the rule to Life, but it has many other rules too: https://donhopkins.com/home/CAM6 Here's the source code of a hard-coded Life rule (with some bonus features like running a heat diffusion in parallel in the upper bits, and rotating the scanning order to cancel out the heat diffusion dithering artifacts): https://github.com/SimHacker/CAM6/blob/master/javascript/CAM... There is another lookup-table based implementation of Life that is compatible with the way the CAM6 hardware works. It uses a Moore neighborhood. This code snippet is not run in the inner loop, it's run over all possible input configurations to generate a lookup table that is used by the generic Moore neighborhood code. So it doesn't need to be optimized because it runs outside of the inner loop: https://github.com/SimHacker/CAM6/blob/master/javascript/CAM... // ruleFunction_Moore_life computes the life rule Moore // neighborhood lookup table. function ruleFunction_Moore_life(ruleDict, state) { var sum8 = ruleUtil_Moore_sum8_0(state); if (state.c0) { return (((sum8 == 2) || (sum8 == 3)) ? 1 : 0); } else { return ((sum8 == 3) ? 1 : 0); } } There's some other rule compiler code that calls that function repeatedly over all possible permutations of neighbor states in ruleDict, to generate the lookup table, that's used by the Moore neighborhood (which itself also has some fancy optional features): https://github.com/SimHacker/CAM6/blob/master/javascript/CAM... Moore neighborhood explained: https://en.wikipedia.org/wiki/Moore_neighborhood Here's an in-depth technical demo that I recorded for Norman Margolus explaining how it was inspired by his book and how it works: https://www.youtube.com/watch?v=LyLMHxRNuck Here's the technique for reducing the number of memory loads per cell in the inner loop from 9 to 3. For each row you "prime the pump" by loading the right two columns of a 3x3 window, and then for each cell you scroll the window to the left and load the three incoming cells. for (var cellY = 0; cellY < height; cellY++) { // Load the right two columns of the 3x3 window. n = cells[cellIndex - nextCol - nextRow]; ne = cells[cellIndex - nextRow]; c = cells[cellIndex - nextCol ]; e = cells[cellIndex ]; s = cells[cellIndex - nextCol + nextRow]; se = cells[cellIndex + nextRow]; for (var cellX = 0; cellX < width; cellX++) { // Scroll the 3x3 window to the right, scrolling the middle and right // columns to the left, then scooping up three new cells from the right // leading edge. nw = n; n = ne; ne = cells[cellIndex + nextCol - nextRow]; w = c; c = e; e = cells[cellIndex + nextCol ]; sw = s; s = se; se = cells[cellIndex + nextCol + nextRow]; Here's the explanation of the edge condition gutter optimizations that I posted recently: https://news.ycombinator.com/item?id=40701784 DonHopkins 8 months ago | parent | next [–] Amazing! Decades ago, Will Wright suggested to me a nice optimization for cellular automata and convolution filters that lets you eliminate the bounds checks in the inner loop, which I implemented in my CAM6 cellular automata machine simulator: Eliminate the edge conditions (and conditionals in the inner loop) by making a "gutter" of one extra pixel (or however many pixels your neighborhood extents out) around all the edges of the bitmap (i.e. increase the width and height by 2, then inset x and y by 1), then before processing each frame, copy the appropriate edges into the corresponding gutters (wrapping or clamping), then iterate over the pixels just inside the gutters, so you don't have to perform any bounds checks. https://github.com/SimHacker/CAM6/blob/master/javascript/CAM... [...see Optimization Techniques comments above...] You can either wrap the cells into the gutter from the opposite edge like a torus, which makes nice seamlessly tileable patterns, or in the case of something like SimCity pollution diffusion, you can just clamp the pixels into the gutter along the same edge. Shaders have a way of wrapping and clamping and mirroring automatically (wrapping modes): https://webglfundamentals.org/webgl/webgl-3d-textures-repeat... But on old school consoles you have have to use software tricks like that instead of relying on the hardware. And of course if you're using power of two sized bitmaps you can just mask the coordinates, which is practically free. You could fix SimCity to use that trick, but it would make the code more complex, and it's probably not worth it on anything but really old hardware like the C64 or Sega Dreamcast.
In Ask HN: What's the best implementation of Conway's Game of Life?

Showing the 15 most recent of 27 sources. Enable JavaScript to search and browse every indexed mention.

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.