6 ms·
Show HN: Micropolis/SimCity Clone in Emacs Lisp
This is a little game implemented over a week of tinkering and targeting Emacs.
The point is both to have fun with this kind of simulations, and also explore the "functional core / imperative shell" approach to architecture. I also developed a tile and tile effect definition DSL, which makes this even easier to extend. From this point of view it's a success: easy testing, easy extension,
Gameplay-wise the simulation is too simplistic, and needs input from people interested in this kind of toys. The original Micropolis/SimSity is the last time I built a virtual city.
- boxed 9mo agoYou should have a screenshot.
- jdboyd 9mo agoThere is a screenshot in the README, and according to the github timestamp, the project hasn't been changed since you write this to add such a screen shot. Search for the section labeled: Visual Demo
- agumonkey 9mo agoI thought it was a ssh key fingerprint at first
- PurpleRamen 9mo agoIs this technically a screenshot? I mean its text, not a picture, so more of an output-example.
- apgwoz 9mo agoCan text be put on a screen? And can you take a picture of it when it is? Well, you might have a screenshot of text.
- PurpleRamen 9mo agoThat wasn't done here.
- DonHopkins 8mo agoHow does a text representation of an Emacs screen snapshot look any better than a pixel representation of that same screen snapshot? It's much more flexible, more compact, and qualitatively better, since you can change the font size, and it's still crisp, and you can even copy and paste the text. It makes perfect sense to use compact flexible text instead of a fatter fixed resolution image to screen shot Emacs.
- Tiberium 9mo agoIt seems like it was added by an LLM since it says "This is a simplified snapshot to show the general layout." Notice how it says "simplified snapshot","general layout". I don't think this is the actual representation of how the game looks like :)
- vkazanov 9mo agoActually, this is a copy of the older version of interface with a few lines dropped. I failed to generate a decent gif last night, will add a screenshot. Admittedly, while working on this, I did consult my LLMs advisor through gptel(https://github.com/karthink/gptel https://github.com/karthink/gptel) with a few custom tools setup, which I cannot recommend enough.
- vkazanov 9mo agoThere you go!
- michaelanckaert 9mo agoThis is great! We need more ASCII games/simulations and it's only a bonus if it's in Emacs :-)
- brimtown 9mo agoThis is wonderful. Consider decoupling the core from Emacs, or packaging in a way that doesn’t require it as heavily. I’ve been doing my own exploration of terminal ASCII games via Dwarf Fortress instead of SimCity. I’ve learned that letting a coding agent play is an interesting way to get feedback as well :) https://github.com/brimtown/claude-fortress https://github.com/brimtown/claude-fortress
- hrmtst93837 9mo ago[flagged]
- larsbrinkhoff 9mo agoHow would it be run without Emacs? You might point out that there are things like elisp.lisp that purports to run Emacs Lisp in Common Lisp, but I'm not sure that's viable for anything but trivial programs. There's also something for Guile, but I remain unconvinced.
- notpushkin 9mo agoMaybe a Common Lisp core with an Emacs frontend running it in https://www.gnu.org/software/emacs/manual/html_mono/cl.html https://www.gnu.org/software/emacs/manual/html_mono/cl.html?
- mickeyp 9mo agoWhy not just use the best known emacs lisp core, then? Like say emacs.
- notpushkin 9mo agoTo allow it to run on other lisp dialects as well. (I’m just trying to defend GP’s point – I’m not a heavy lisp user myself, tbh.)
- larsbrinkhoff 9mo ago
- morkalork 9mo agoCongrats on your Seventh Sally!
- DonHopkins 9mo agoFantastic! Can you make Emacs shake the screen by scrolling vertically and horizontally whenever there's an earthquake? Finally RMS can play SimCity.
- yuppiepuppie 9mo agoAmazing! I have added this to the HN Arcade https://hnarcade.com/games/games/micropolis-simcity-clone-in-emacs-lisp https://hnarcade.com/games/games/micropolis-simcity-clone-in...
- Keyframe 9mo agoah, shame it's for Show HN only. I am too embarrassed to Show HN anything I used AI for/with, like: https://www.susmel.com/stacky/ https://www.susmel.com/stacky/ or https://susmel.com/rolly/ https://susmel.com/rolly/ (which isn't a game yet - you can use shift for speed and it has a double jump though!)
- aed 9mo agoThese are both amazing! And I want to encourage you to do a Show HN. I think showcasing things people are building with AI is good. I'm actually very close and putting the polishing touches on something I'm building that will allow people to play Micropolis over API/MCP so you can watch agents build cities (mostly terribly, but it's quite fun).
- Keyframe 9mo agoThanks man, I appreciate the encouragement. As a (really) long-time programmer it just feels all wrong. I understand it was all my input and that without me it would come out like that at all, but still by not touching code much or at all feels just bizarre and wrong to take credit for any of it, let alone "i did dis".
- yuppiepuppie 9mo agoLove the music! Don't be afraid of putting them up and showing them off if that's something you want to do. They look great!
- mghackerlady 9mo agoThis may be unrelated but I swear emacs has a color tile library for games, it's used in tetris iirc
- mickeyp 9mo agoIt does indeed. It's used in several games. https://www.masteringemacs.org/article/fun-games-in-emacs https://www.masteringemacs.org/article/fun-games-in-emacs
- vkazanov 9mo agoI completely forgot about Tetris and its nice visuals! Thanks, will see if I can use the library for ElCity.
- larsbrinkhoff 9mo agoI think misinterpreting the "el" as Spanish is fun. In that vein, your game could be called ElCiudad.
- vkazanov 9mo agoSomebody somewhere suggested doing a clone of Tropico called ElPresidente, which is even cooler. Btw, Lars, you have endlessly more experience in Elisp than I do. Do you maybe have any ideas/directions on how to make the graphical mode look... A bit more decent and snappy?
- larsbrinkhoff 9mo agoSorry, I don't know anything about Emacs graphics. Some people confuse me with larsi, but I'm not that guy.
- devcraft_ai 9mo ago[flagged]
- iLemming 9mo agoRelated: Doom in Emacs https://github.com/minad/doom-on-emacs https://github.com/minad/doom-on-emacs
- zackmorris 9mo agoI believe that "functional core / imperative shell" (FCIS) is the future of programming: https://medium.com/ssense-tech/a-look-at-the-functional-core-and-imperative-shell-pattern-be2498da153a https://medium.com/ssense-tech/a-look-at-the-functional-core... The idea being that business logic gets written in synchronous blocking functional logic equivalent to Lisp, which is conceptually no different than a spreadsheet. Then real-world side effects get handled by imperative code similar to Smalltalk, which is conceptually similar to a batch file or macro. A bit like pure functional executables that only have access to STDIN/STDOUT (and optionally STDERR and/or network/file streams) being run by a shell. I think of these like backend vs frontend, or nouns vs verbs, or massless waves like photons vs massive particles like nucleons. Basically that there is no notion of time in functional programming, just state transitions where input is transformed into output (the code can be understood as a static graph). While imperative programming deals with state transformation where statically analyzing code is as expensive as just running it (the code must be traced to be understood as a graph). In other words, functional code can be easily optimized and parallelized, while imperative code generally can't be. So in model-view-controller (MVC) programming, the model and view could/should be functional, while the controller (event handler) could/should be imperative. I believe that there may be no way to make functional code handle side effects via patterns like monads without forcing us to reason about it imperatively. Which means that impure functional languages like Haskell and Scala probably don't offer a free lunch, but are still worth learning. Why this matters is that we've collectively decided to use imperative code for almost everything, relegating functional code to the road not taken. Which has bloated nearly all software by perhaps 10-100 times in terms of lines of code, conceptual complexity and even execution speed, making perhaps 90-99% of the work we do a waste of time or at least custodial. It's also colored our perception of what programming is. "Real work" deals with values, while premature optimization deals with references and pointers. PHP (which was inspired by the shell) originally had value-passing semantics for arrays (and even subprocess fork/join orchestration) via copy-on-write, which freed developers from having to worry about efficiency or side effects. Unfortunately it was corrupted through design by committee when PHP 5 decided to bolt-on classes as references rather than unifying arrays and objects by making the "[]" and "." operators largely equivalent like JavaScript did. Alternative implementations like Hack could have fixed the fundamentals, but ended up offering little more than syntactic sugar and the mental load of having to consider an additional standard. To my knowledge there has never been a mainstream FCIS language. ClojureScript is maybe the closest IMHO, or F#. Because of that, I mostly use declarative programming in my own work (where the spec is effectively the behavior) so that the internals can be treated as merely implementation details. Unfortunately that introduces some overhead because technical debt usually must be paid as I go, rather than left for future me. Meaning that it really only works well for waterfall, not agile. I had always hoped to win the internet lottery so that I could build and test some of these alternative languages/frameworks/runtimes and other roads not taken by tech. The industry's failure to do that has left us with effectively single-threaded computers which run around 100,000 times slower today (at 100 times the cores per decade) than they would have if we hadn't abandoned true multicore superscalar processing and very large scale integration (VLSI) in the early 2000s when most R&D was outsourced or cancelled after the Dot Bomb and the mobile/embedded space began prioritizing lower cost and power usage. GPUs kept going though, which is great for SIMD, but doesn't help us as far as getting real work done. AI is here and can recruit them, which is great too, but I fear that they'll make all code look like its been pair-programmed and over-engineered, where the cognitive load grows beyond the ability of mere humans to understand it. They may paint over the rot without renovating it basically. I hope that there's still time to emulate a true multiple instruction multiple data (MIMD) runtime on SIMD hardware to run fully-parallelized FCIS code potentially millions of times faster than anything we have now for the same price. I have various approaches in mind for that, but making rent always comes first, especially in inflationary times. It took me over 30 years to really understand this stuff at a level where I could distill it down to these (inadequate) metaphors. So maybe this is TMI, but I'll leave it here nonetheless in the hopes that it helps someone manifest the dream of personal supercomputing someday.
- vkazanov 9mo agoAuthor here. I never intended this project be something like a wonder of 3dfx or something. In fact, the hope was to discuss implementation details. Either way, for those interested: screenshots of both the terminal and graphical version are now included in the README.org.
- DonHopkins 8mo agoRMS asks: >Is the Emacs Lisp version fun enough to be worth adding to Emacs?
- vkazanov 8mo agoFor real? I think I could make this work I mean, this version is a boring, I was just looking into architecure and visuals, and how these could be structured in Emacs Lisp. I never expected people to be so curious about it. But I think it should be possible to port the whole thing with some limitations (turn-based, as emacs is not really good for live rendering and simulation).
- DonHopkins 8mo agoOnce you have it polished with a readme and GPL license send him an email at rms@gnu.org -- but remember he hates github, don't mention "open source", do say "free software", don't buy him a parrot, and don't call the operating system Linux without saying "Gnu/" before it, and you'll be fine! Don> Do you abstain from web browsers still, or do you have a good way to read web pages without using non-free software? rms> I can view many web sites with IceCat, but some sites refuse to work since I have enabled LibreJS and am connecting via the Tor network. Don> PS: Could you please verify this stolen sperm quote? >"If I'm the father of Open Source, it was conceived through artificial insemination using stolen sperm without my knowledge or consent." — RMS (2016, Web Summit) rms> I really said that, probably several times. Alas, I don't remember when or where. https://news.ycombinator.com/item?id=3159210 https://news.ycombinator.com/item?id=3159210 https://github.com/ddol/rre-rms/blob/master/rider.txt#L652 https://github.com/ddol/rre-rms/blob/master/rider.txt#L652
- somalihoaxes 9mo agoOf course. Emacs. Soon: Playing pool and poker in Emacs. Because why not? Everything is a nail, right?