Hacker News new | past | comments | ask | show | jobs | submit login
CityBound – An open source city simulation game in Rust (github.com)
1340 points by formalsystem 19 days ago | hide | past | web | favorite | 264 comments



Author of Citybound here! Feel free to ask me any questions about the project! I’m mostly active on the Citybound subreddit in general.

Also, check out the main homepage at https://aeplay.org/citybound for a more player-centric intro


This looks awesome! My question, coming from a self-identified "C/C++ person" who works in realtime control systems and who's been feeling increasingly uncomfortable with C++'s inherent footguns, is how has your choice of language helped or hindered this project?


I had a nice comparison because I first tried to do a native implementation in C++ and - wanting to do some custom low-level "stuff" for my simulation actor system (related to allocation and networking) - I ran into so many footguns that it slowed me tremendously. As soon as I tried to do the same with Rust, it was a breeze and I was able to write a lot of unsafe code that does very particular things that I need, while exposing a completely safe API for the rest of the engine and game. Being then able to also use Rust in the browser quite seamlessly with WASM allowed me to have a super straightforward and high-perf communication channel between the simulation backend and browser UI. The only real Rust disadvantage that hurts a lot is compile times. Sometimes I do fight types/the borrow checker, but only when I try to do weird things, in general I perceive it as a huge help in scaffolding things.


Very nice, how did you decide on your simulation? did you build a generic simulation engine you can reuse, or is your simulation tightly coupled to the objects you are simulating? It's fun seeing this, I have been recently thinking of a simulation game and wondering if to use a generic simulation library such as SimPy


I build a simulation engine, based on a high performance distributed actor system library I wrote for just this purpose. It is generic, but a lot of the performance trade-offs are with Citybound's needs as the main driver.


I see you didn't use Actix or even Tokio, could you please explain why?


Their actor implementation / event loop works on a higher level than mine. Mine is super simplistic intentionally to offer high performance. Being optimised for cache locality, processing similar actors in batches, using custom allocators and having encoding-free communication, it has many parallels to data-driven game engine design or even entity component systems.


cargo +nightly run of the examples in your Kay project appears to be broken, I'd love to explore using it in a future project.


First time I hear about compile times being an issue with Rust. Is that a general problem with bigger projects or can you identify language features that add specifically to the problem?


First compilation is slow. After that it’s much better during development times. This can mean that ci can take a ton of time if you don’t do even the smallest bit of optimization.

Otherwise, it’s a solid language choice. L


As a point of reference "warmed up" compilation for me still takes ~1minute. Bearable for general work, horrible for quick tweaks or UI-related work.


I'm so jealous of software development tools.

Elaborating the hardware (systemverilog) I'm working on (about a year of work from scratch, nothing fancy) takes 8 minutes.


Wow, I get frustrated and feel unproductive if my feedback loop is longer than 2-5 SECONDS. This must require a seriously different approach to trial and error exploration


A lot of that is done in a simulator on the computer, which usually builds very quick once you get the environment and simulation scripts written.

The full build to a bit file that can be loaded into hardware is an NP-hard optimization problem, so as your design approaches the limits of either the desired clock speed or the amount of space in the chip, it can become very slow.


I wish. This figure is reloading the formal tool after a one line change in the RTL.

Placing (not routing!) takes around 24 hours since we need to run in a larger environment than just the block level to get realistic timing reports


I've heard that long warm compilation times can be mitigated by breaking up code into separate modules so it doesn't recompile e.g. the actor system every time you adjust a layout. Basically caching works best on the module boundary. Is this something you've explored?


Yes, I factored out quite a bit of generic parts of the engine into libraries and took some steps to cut down on number of generics being instanced (which was one of the main drivers of compile time). Now I'm left with pretty much the game core, which is highly interdependent and thus nearly impossible to break up into crates (they can't mutually depend on each other). And it's still kinda slow.


+1

I've splitted a 20k+LOC Rust project into multiple crates and compilation time improved a lot (still slow compared to other languages) but it's now manageable.


Really? It has been quite a talking point for a while with Rust. Final binary performance is great, but compilation times hurt badly.


Thanks for your answers here, I'm definitely going to look more closely at Rust for my next project!


You might be interested in hearing what Chucklefish, the creators of Starbound, have to say about Rust::

https://www.reddit.com/r/rust/comments/78bowa/hey_this_is_ky...

https://www.rust-lang.org/static/pdfs/Rust-Chucklefish-White...


I see there is a bit in there about the city economy. Are you interested in expanding that to supporting a full monetary economy with employment, commuting and the like?

That certainly interests me - particularly how the pathologies of an economy like that emerge from individual actions - and I’ve been looking at Elixir to generate the necessary actor simulation engine. Looks to me like you have that here in Rust.

How could I get involved in helping to add a more detailed economy to this sim?


There is already a monetary economy with employment, commuting and purchases. One of the things I hope to do soon is to factor out some of the variables of the economy simulation to make it easier to mod without having to understand the full codebase. Then would be a great time for you to experiment with it.


> ...and I’ve been looking at Elixir to generate the necessary actor simulation engine. Looks to me like you have that here in Rust.

I will caution that Elixir's runtime performance, particularly with simulation type code, is abysmal. Also, last time I was using Elixir, the available profiling infrastructure was really terrible; I had to buy a new workstation with 64GiB of RAM just to be able to fit the profiling artifacts from one iteration of our small model in memory, which was required in order for it to complete in less than infinite time.


Is this your talk?

https://www.youtube.com/watch?v=LiIoE8ArACs

It was great, if so!


Yes, that's me. Thanks!


It was a really great talk, thank you for that!

One direction that I've seen a lot of game engines heading in lately is the Entity Component System model for a lot of the same performance reasons (cache locality of data being the big one) that you've landed on the Actor model.

I'd be curious to know if you'd looked into the ECS model at all, and if you have how you view the tradeoffs between that model and the Actor model proposed in the talk. At a gut level, I get the feeling that your model seems much better suited to the distributed nature that you accomplish in your talk, and that ECS might be slightly more effective at allowing composition in an effective way. You've got so much more experience with both, though, that I'd love to hear you take if you've got one.


That is a really inspiring talk. I suspect I’ll be playing with Rust this weekend.


Really nice talk! And thanks for this, the actors architecture really talks to me. I am trying to find a distributed architecture that would make sense for a collaborative project I have and this could actually solve many of my problems. I had not considered that message passing could actually be very fast when done right.


I'm really glad to hear that. Not many people know about actors and even less believe it can suit their problem.


Do you have a document/presentation or even source code where you go a bit more into details about how you share the actors states between different computers?


Wonderful talk. Thank you for sharing this.


Do you have a writeup of the traffic simulation rules that you're using? I peeked in the code and saw the intelligent driver model is being used for acceleration. I suppose you also have a lane-changing model and such, too.

Your architecture could be very useful in teaching.


Yes, I also have a lane changing model.

What exactly would you like to see in a writeup? And which teaching setting do you have in mind?


Ah, I'd love to hear more about this! Getting traffic right is much tougher than we appreciated at first.

Disclaimer: Creator & lead developer of SimAirport.

I suppose we just did it "wrong" to begin with, and have since been stuck with the wrong graph / haven't put the time into fixing it yet -- but would be curious to hear high-level of how you're doing it.

Our issues are primarily that we did lanes as graph nodes instead of "node capacity" so our pathfinding prescribes precisely which lane to use; when stuck in traffic we can't intelligently find our way around it without pathfinding again, but then 'quality' ends up being correlated to how often we pathfind with node-occupancy info, which obviously is a poor (and poorly performing) solution.

Would love to hear your approach or if you'd be interested in talking shop at all, email is in profile! :)


First time I saw SimAirport, looks wonderfully antsy!

I'd love to discuss traffic with you on the Citybound subreddit, since I think there might be other people interested in such implementation details :)


University setting.

Many universities in major urban areas have a school of housing and community development. They study planning, policy, design, economics, and other related disciplines.

Once trained with how to create new models in your system, academics could simulate the impact of ideas they are developing in research.


I just thought it might be nice if you did a breakdown of the physics of traffic and maybe how you coded that part. As for teaching, I think it could be used to teach about like signal timing etc in a fun way.


Interesting that I didn't see Cities: Skylines on the inspiration list. Intentional snub? Haven't played it? Just forgot? Curious.


I didn't play it enough (yet) to feel comfortable putting it there, compared to the other things I listed as inspiration. I feel like it deserves a more in-depth comment/comparison. I've only watched let's plays of it so far.


You should check it out more! I love it. There are some similarities to the way your project is put together.


I like it as well a lot, but after several hours of playing with it I started focusing too much on some things that I consider core flaws of the game and now I'm not motivated very much anymore to keep playing... .

Examples:

- utility services: I keep having problems with e.g. ambulances or trash collectors that are spawned very very far from the area where they're actually needed, even if a hospital or incinerator is just around the corner.

- size of buildings: I don't like the approach of having tall buildings / high-rise in developed high-value zones by default. In my opinion the size of a building should mirror only the density of the population living in that particular area, so it should be possible to have as well tall buildings in low-value zones. As well the amount of people living in tall buildings is for my taste not a lot different from the one of med/low-buildings, taking into consideration the height of the building... => how tall is a building should be a function of the people inhabiting it and not related to the value of the zone.

- deaths/births waves: once my cities got big, I kept getting each time waves of people dying and later a lot of births. There is a plugin that fixes this, but this should really be part of the basic game.

- traffic: this is actually already working veeeery well on multiple levels (e.g. very nice/interesting to observe how queues generate - I can observe that for hours hehe) but I do miss a logic that says e.g. "if this section of street has during a certain timespan ~95% of space occupied by vehicles then assume that there is a queue => mark that section of street temporarily non-existing for non-involved vehicles so that other cars would start looking for alternative paths" or something similar.

All in all, even if Cities Skylines was already a giant leap compared to the classical Simcity-games (excluding the last one which was just horrible), I'd definitely like more "action=>reaction"/"cause=>effect" in a potential future "Cities Skylines 2" or in this case in "CityBound".

Cheers

EDIT: for more details search in this page for the post containing "Unfortunately, traffic management is the only part of the game that really holds up as a simulator" by "amyjess" - I just read it now and I think that I agree as well with all what's mentioned there about CS (but I honestly don't rememember anymore how Simcity4 worked...).


So, one thing that's broken about traffic is the distribution of population in low-density vs. high-density areas.

The short version is that low-density areas are denser than they look, and high-density areas aren't dense enough. For example, if you click on a single-family home and look at the population, there will be over a dozen people living there (TBH, I forgot the exact numbers, but it's way more than a single family's worth of people)! But if you click on a giant skyscraper, there's nothing even close to what would fit in that building if it existed in real life.

This has two unfortunate effects:

* The suburbs need more public transit than you think they'll need. Once you hit 50k people or so, you'll be hurting for transit badly. "But I'm building low-density housing with a street hierarchy, it works fine in real life, so why are my roads clogged in the game?" Yeah but in real life you're not cramming a dozen people into every single-family home.

* On the other hand, you can get away with building dense downtown areas with much less transit than would be required in real life.

And yes, there are mods to realistically balance population. If you run these mods, you'll have something much more realistic: the suburbs don't really need transit, but if you build any high-density at all, you'll need to get a good transit network up and running ASAP.


I agree and I'd like to add that (not related to traffic nor density but just pure spread of population density), from what I saw, there doesn't seem to be in CS (Cities Skylines) any relation between low-density & high-density areas, meaning that I can start right away building high-density areas with no in/direct realtime/historical impact of any kind.

We can (proably should?) debate about how these mechanics should work, but I think that it must be true that any city needs in some percentage both areas (e.g. as well the extreme being built now "on demand" for the World Cup in Qatar - https://en.wikipedia.org/wiki/Lusail ) must need both, or maybe not if they modeled the city based on CS haha.

I think that I could have similar points as well for the "education" in CS - I never (still don't know) if the elementary schools that I place are a foundation for people that will then go later to College and/or University - I still place them because I personally believe in the scala Elementary=>maybe_College=>maybe_University, but who knows... . (ok, this boils down mainly to a lack of transparency/informations for the user, independently if what CS does is good or wrong from the point of view of the user)


So, according to the Cities: Skylines wiki [0], cims who move into high-density residential areas are younger and less likely to procreate than cims who move into low-density residential.

That's an interesting way to differentiate them, but it's also something that's very specific to present-day America. And middle-class America, at that.

Kind of odd that Skylines is developed by a Finnish company and published by a Swedish one, given how US-centric that model is.

I've also written elsewhere in this thread about how Skylines doesn't have a concept of class stratification, either, and that's a problem: the only way to create neighborhoods with distinct class implications (e.g. the ghetto) is to use the RICO mod and plop buildings directly.

There's no real concept of medium-density, either: the closest it comes is to zone high-density and put it in a district with the High Rise Ban ordinance. Or, again, use RICO. Oh, and growables are limited to no more than 4x4 tiles... if you want bigger buildings (e.g. a sprawling suburban apartment complex), your only option is RICO.

[0] https://skylines.paradoxwikis.com/Zoning


> Kind of odd that Skylines is developed by a Finnish company and published by a Swedish one, given how US-centric that model is.

I totally agree, and maybe there has been some discussions about this in the past (I forgot about those early webcasts) - but for a company to align to the US market (probably the largest & most uniform around) is usually probably the safest bet - I still admit of being a little bit sad :|

> There's no real concept of medium-density, either

Now that you say it, I think that (a realistic - see previous posts) medium-density would be absolutely important to model european cities.

> limited to no more than 4x4 tiles

You're right but personally I don't really care about this for the time being (meaning that the other problems have for me absolute priority compared to this) - maybe they just randomly put a safe limit for their first release to avoid indirect potential complications... - I would have most probably done the same, so I won't dig into this hehe.

> I've also written elsewhere in this thread about how Skylines doesn't have a concept of class stratification

I agree.

Summarizing after all these posts & remarks, I feel sad that the studio so far developed only add-ons that do not improve the core of the simulation but only add more distractions and/or superficial complexity around it :P

(E.g. I did buy "Mass Transit" but it didn't give me the feeling that it improved the game but just gave me a few more alternatives - and actually "mass transit" is in my opinion associated to trains & metro, therefore absolutely not fitting cablecars/blimps/ferry/etc...)

But maybe.... they be working on aggregating key-improvements for their next CS2? Who knows... :)


I agree about the expansions, they have been a disappointment in general. Mass Transit was the highlight, but didn't go nearly far enough and still concentrated on the eye candy. I do understand that they try to appeal to the larger market -- people running the game as a simulation is surely a minority.

That said, it's still currently the best city sim by far. Hoping that Citybound will change that at some point :)


> * The suburbs need more public transit than you think they'll need. Once you hit 50k people or so, you'll be hurting for transit badly. "But I'm building low-density housing with a street hierarchy, it works fine in real life, so why are my roads clogged in the game?" Yeah but in real life you're not cramming a dozen people into every single-family home.

One could argue some cities have low-density housing next to transit though (like Berlin, or Paris). It does have the disadvantage of making metros too easy though, so commuter rail is almost never done because it is too hard to integrate to a city.


My experience with C:S heavy rail transit is that it doesn't work well with the current simulation: it seems that the cims take the shortest route even if the slightly longer train would be much faster due to fewer stops abd less congestion.


Kind of the same. Loved Cities: Skylines to death but the traffic AI killed it for me. It gets to the point where you're stuck building unrealistic designs to workaround the flawed AI pathfinding. It's true you can mod it but it requires a ton of extra manual work to reassign lane routing in each and every city intersection, on top of killing performance.

I'm just waiting for the sequel to the game where they may open up the traffic AI to modders more, or fix some of the stuff broken with the existing engine. That said, it's become kind of the gold standard for city sims so OP should definitely check it out.


The current iteration of the goto traffic manager mod is the presidential edition, https://steamcommunity.com/sharedfiles/filedetails/?id=58342.... It has some features like the dynamic lane selection and an alternative AI model (I think) that help even without manual work. But yes, assigning lanes at intersections, planning the number of lanes accordingly to have onboard lanes and in general avoiding that traffic collides takes some manual work. It can be fun though. I did not notice the performance going down too much.


I play City Skylines only to tune my roads with that mod. It's awesome, but in general I think the game has some annoying flaws, like that bringing dead people to graveyard is like a logistical problem, the blocky zoning makes neighborhoods boring, buildings are never that big, etc.


In CS the only way I found to have even moderately decent traffic flow was to make absolutely every street a one-way street. I don't claim to understand why that helps, but it seems to.

The downside is you have to be very careful where you place your emergency services as you can easily get zones which are too far for firefighters to reach.


This is exactly why I quit playing as well.


These are all very valid points. Cities: Skylines ends up being kind of a "traffic sim" game once you get down to the nuts and bolts of it. Even though they have some very intelligent citizens, it's still not quite up to par for pathing.

I still think it's the best City Sim game made yet. The author here should really invest some time to learn about Skyline's failings so they can avoid those problems in their own sim.


Amazing work!

Your statement says that you have actor-based simulation model that's inspired by erlang - is there a reason why you picked rust instead of a BEAM language for developing the backend? My guess would be performance, maybe?


Exactly. My actor system operates on much smaller, much simpler actors. See the sibling comment for my in-depth talk on it.



Rust is interesting to me but honestly, I'm going to stick to elixir because I have high confidence I can train juniors to code safely on it, and I have no particular need for performance (most of my stuff is iO or network bound)


Write NIFs in Rust, or C if you want to stay on the BEAM, and still get performance if you need it. Elixir/Phoenix are the Ruby/Rails of today. I do like getting low-level within the same PL, so this has truly inspired me to dig more into Rust. I am still playing with Zig though.


Can you talk about the road building engine? Are you using splines to generate the smooth curves? This is a really amazing project, I can tell you have put a ton of work into it.


There's a lot of interesting stuff going on in there. First, for the curves itself, it does a kind of naive approximation optimisation and builds a curve out of line and arc segments that tries to follow the control points as closely as possible. Then it does an intersection step between all roads and procedurally generates correct connections between all incoming and outgoing lanes of each intersection, including (somewhat) reasonable traffic light timings for each "turn group"


Why did you decide to make roads the atomic unit over cars for traffic?


I assume you talk in terms of what constitutes an actor in the actor system: because cars on one strip of road interact highly locally, so processing them in one batch makes a lot of sense performance wise, vs. every car sending messages to every other car and having to maintain references to close-by cars.


Always thought it would be really cool to do a city based on no roads at all, but bike paths and public transport. Ever think this will get to the point where I can play around with that? Thanks.


That would be a city without trucks...?

The fire department will have an opinion on this.

So many things will be difficult: construction, trash hauling, tree removal, relocation, business deliveries, etc.


Hmm, fire engine trains, garbage trains, cargo trains... I like it!


I suppose it depends how realistic the sim is, but what about drones, conveyors, helicopters, etc?


You can definitely do deliveries by bike. They do it in my city currently.


Yes, see my other comment on that here somewhere (on mobile)


Feel free to ask me any questions about the project!

I hope to learn to code. I just got my rejection letter from a coding school ("overwhelming demand -- we had to turn down many qualified candidates"). My backup plan is some free online coursework and probably finding a city-building game to mod or tinker with.

When you say open source, does that mean it would be okay for me to futz with it for myself like that?

Thanks.


I’m really hoping to get the project to a point soon where it is easily hack able even for people who are just starting out to code, or even for whom this will be the first contact to code. But I’m far from being there, right now it is a pretty large, pretty unusual and almost entirely undocumented codebase.

So by all means start teaching yourself to code by playful experimentation, but start with something much simpler first :)


Could it be scripted in Gluon or Dyon? Excuse me but I am Rustt newbie.


If I will add scripting, I will probably use JS, since I already have interop with that in the browser UI. Gluon or Dyon are neat, but they are weird enough (in my opinion) that people might as well learn Rust instead of scripting.


That sounds reasonable. Thanks! I am looking forward to viewing the source to learn Rust.


Okay. Thanks.


Yes, you can futz. Here is the license https://github.com/citybound/citybound/blob/master/LICENSE.t... Read about it here https://www.gnu.org/licenses/agpl.html

Having a license that says you can go play with it doesn’t mean it will be straightforward as a newcomer to understand the code you find or to accomplish any particular goal with your fiddling.

I haven’t looked closely at this project, but I would recommend at least considering starting out fiddling with a simpler system, if you want to learn to code.


Thanks.

I don't know that I will even learn Rust. I have had a Python course recommended to me.

I just am trying to figure out what my options are. I've gotten serious push back at times for what I felt were innocent activities. Trying to ask the "dumb" questions in hopes of avoiding that.

The links are helpful. Looking them over.


I recognize your username and you’re a precise writer. You’d likely be quite a good developer.

I’m going to give you some unsolicited advice. Start now. If you’re struggling to find a course, start here:

https://www.railstutorial.org/book

Don’t worry if Rails is the right choice. You might love it or hate it, but regardless, you’ll learn things like writing tests and using version control.

Good luck and have fun.


Thanks. Added to my resource file:

https://doreenlearnstocode.blogspot.com/2019/04/ask-silly-qu...

I'm currently horrendously short of sleep. I've had insomnia for about 8 days. O_o

I don't expect to try to study in earnest until I start sleeping a bit better. Hopefully soon. (Crosses fingers)


Sorry, one other thing. I don’t recognize the existence of stupid/silly questions. If you get stuck, my email address is in my profile.


I know some really smart people who claim that Rails induces narcolepsy, so my last comment might have been more insightful than I thought...:)

Seriously, best of luck. And remember, learning to write code is really just about momentum. Start, have fun and jfgid (just fucking getting it done).


Oh, I didn't notice it was (A)GPL licensed, that's disappointing.


I'm not affiliated with the author, but that is generally part of the definition of open source. Once you've downloaded the code, check the top of any source code file for more details about the specific license the author is using.


Thanks.


Interesting that you take factorio as inspiration. May I know what part of factorio that you want to add into, that seems lacking in other games of same genre like sim city?

On the other hand, how do you plan for in-game scale / limit? (Millions of population, etc) and whether you have any idea about multiplayer/server (I'm talking similar with clustertorio)


The thing that impresses me with factorio is how smoothly the game challenges scale with you learning and mastering one game aspect after the other. Basically, you learn something that solves all your current problems, but that directly creates new problems, which you then have to deal with using your newfound powers.

The actor architecture makes it very easy to scale the simulation across several machines and indeed run a simulation cluster that you connect to from a simple client. In fact it already almost works like that. And the only thing that's missing for multiplayer is some UI-level coordination for collaborative planning (basically preventing editing conflicts). Everything else is already "multiplayer ready".


I wanna help with this project. I wrote a lot of personal changes to Micropolis.


Can you explain something about "Special recursively-compact containers"? I couldn't find any search hits for the phrase.


This is what I was looking for: https://github.com/aeickhoff/compact

Cool containers.


I was following the project since the death of sim city! Happy you made it! Congrats bro.


Is there any documentation? The aeplay.org site looks still to be mostly developer oriented.


Not really. Which documentation exactly do you mean? Code or for players?


Oh even just usage instructions. Like what are the navigation controls, etc. I zoned some things and laid down some road and wasn't sure what or when to expect it. Some of the bugs as well make me unsure if my expectations are wrong or if it's just a bug (e.g. vehicle traffic not appearing, roads and zoning going in weird shapes). Some of the links in the top-level readme are 404 as well.

All in all I'm sure I'll spend a ton of time playing the game itself and playing with the source.


There is a small tutorial in the game menu and you can check the settings for keybindings.


Yeah I saw that but I'm still largely unsure about a lot of bits and pieces about the game play. Mostly it's a matter of determining what's intended behavior and what's not (e.g. the traffic jams for no apparent reason that may or may not have other cars passing them in the same lane), but also what things like those big arrows on the road (that persist sometimes).


Congrats on shipping! It looks beautiful. How long did it take you to build this?


I didn't really ship it yet (got posted here by someone else), it's in continuous development for already ~5 years.


Are cities always flat?


Once most features work in 2D, I’ll extend to 3D terrain. I’ll probably have over and underpasses before that for better traffic routing.


Please think hard about the design decisions of your game. I grew up with SimCity and later SimCity 2000. It informed many of my young opinions about government policy. But I later came to find out that SimCity wasn't nearly as objective as it looks. There are a lot of conservative politics baked into the design of the game that I'd argue were potentially damaging to the kids who played it back in the 90s.

This article from 1992's LA Times quotes Maxis president Jeff Braun saying how they're pushing a political agenda. Specifically pro-mass transit and anti-nuclear power.

https://www.latimes.com/archives/la-xpm-1992-10-02-vw-391-st...

What really opened my eyes, though, was this excellent article from LOGIC magazine about how Will Wright based the entire simulation on the work of Jay Wright Forrester. I don't know if it was a conscious choice to adopt Forrester's extremely conservative social policies, or if Will Wright just happened upon a bunch of ready-made algorithms he could use. But the result is the same. SimCity teaches us many fallacies about urban planning and finance that Republicans have historically used to justify certain policy choices.

https://logicmag.io/06-model-metropolis/

My point is just to be very conscious of the biases you're encoding into the logic of your game. What may just be a game to you may be someone's first lessons in politics.


If you try really hard, you can find little pieces of evidence of any agenda in any material. It seems like Jeff Braun tried really really hard if he says SimCity is bad because it pushes the opponents agenda. The evidence quickly disappears once you step back and try to see the big picture. It's just a game. And mass transit actually makes sense.


I don't believe Jeff Braun was saying SimCity is bad. As he was the CEO of the company that made it at the time, that would be a very foolish move.

I think he was trying to deflect criticism directed towards the game. Keep in mind that the media was presenting SimCity not as just a game, but as a clever teaching tool for children to understand finance and local government. Okay, great. Whatever sells the game, right?

Then actual economists and city planners start to comment about how the game isn't realistic at all and fudges the numbers in such a way to incentivize certain play styles without showing the trade-offs that are involved in real life. At that point, Braun has to admit to the biases in the game, but he can't say anything so extreme to lose the free advertising his product is getting from schools and teachers and parenting magazines that are telling parents to buy the game for their children.

And although I'm a proponent of mass transit, it's not perfect. I believe SimCity only represents the upfront cost of mass transit and discounts the recurring maintenance costs, while road maintenance costs are inflated. But now were debating specific mechanics of a game other than the one this thread is about.

I mentioned Magnasanti in another part of the thread. In Magnasanti, there is only mass transit. No roads at all. I don't think I'd like living in a place like that where government-owned transportation decides where and when I can travel.

But that's exactly my point. There are two sides to every coin and I think it's important to represent the pros and cons of the choices the player is presented. There's no such thing as a purely positive or negative decision when it comes to city planning.


I appreciate the sentiment and always suspected as much about SimCity. My goal for Citybound is really a meta one: to be flexible enough to try out any number of government and planning styles and for the simulation to be tweakable enough to set up any real-life or imagined political context for a city.


That's good to hear. I think making it open source is already a step in the right direction. City planners who were critical of SimCity at the time often pointed to the game being a black box, so you couldn't examine, much less tweak, the assumptions built into the simulation.


If that is truly your goal, it is a noble one, but in that case baking the pathfinding into the roads seems like a bad design choice. People get lost driving in a convoluted city a lot even with GPS, but much less so in a regular blocked city.


Making them get lost is as easy as picking a random turn instead of the correct one with a certain probability.


According to your article (other comment) on Magnasanti, "There are no roads — all transit is mass transit."

That is hardly "a lot of conservative politics baked into the design of the game", nor would any such politics be "potentially damaging to the kids who played it".

If somebody gets a harmful lesson from the game, it is that you can have a viable modern city without any place to drive a truck.


I regret calling out any particular political ideology by name. It's true that not all of the biases baked into the game are conservative with the bias toward mass transit being a great example of liberal bias. I meant those as two separate thoughts, but I failed to properly express that.

Although I think many American cities could benefit from more mass transit choices, I agree that I certainly wouldn't want to live in a city where mass transit was the only option. It would mean a government-controlled entity would be dictating when and where I could travel. I don't like the sound of that.


The government can blockade roads and impound/boot your car. They also maintain roads. Many low-income people rely on public transit as their only transit option already. If your fear is that the government is going to turn against its own citizens and use public services as a weapon, public transit should be the least of your worries. You could easily say the same thing about municipal water or electricity.


This seems more like a failure in parenting, it was always made clear to me that games and television do not reflect reality and should not be emulated. At what age did you realize Simcity was just a game and that you should not treat it as an actual predication or model of reality?


" it was always made clear to me that games and television do not reflect reality"

And to me it was allways clear that this is just a legal disclaimer.

Of course games and videos reflect reality. Not 100% accurate, no, and some allmost 0% but btw. no scientific model does 100%, even though they are obviously more accurate and I would like more games to be based on scientific models.

But for example angry birds, very succesful, obviously fiction, but the core game mechanic is a physic simulation(Box2D) which works as realistic as a 2d computer can work in a game, so you can learn about kinetics with it.


Parents don't make legal disclaimers, which is what I should have explained, they always reminded me that it's just a game. If I started spouting political opinions and justified them with "but that is what happens in Sims when you have that policy", they would have further reinforced that games mechanics should not influence your life decisions. Your explanation is overly pedantic and not a charitable interpretation. It's not appropriate to base political opinions based on a black box game.


"Parents don't make legal disclaimers"

But they repeat them.

And since you were the one who insulted someone with the assumption that they just realized that SimCity is just a game, it is a bit laughable to accuse me of pedantry, because I told you, that games do have a base in reality.


While this is certainly clear for media like cartoons, action movies, Mortal Kombat, and Doom, SimCity was touted as an educational tool for children and an accurate model of reality throughout the early to mid 1990s. I was in elementary school at the time. Parenting magazines and journals as well as the broader media claimed as much. A friend of mine growing up who absolutely loved SimCity is a real life city planner now. I have fond memories of playing SimCity 2000 with my father.

If you really want to know when I realized that the real world doesn't work like SimCity, it was when I was in college and I started actually paying attention to the news and what was going on in the cities and towns I lived in.


Yes, it's especially important when these games are used to educate students. Recently came across this [0] very informative talk that discusses some of the same things.

On another note, I'm really excited to see that A Pattern Language was an inspiration for this sim. That seems like a great start!

[0] http://molleindustria.org/GamesForCities/


I wouldn't say mass transit is a conservative policy. Quite the opposite.


I didn't mean to imply I thought mass transit was a conservative policy. I was trying to highlight another example of bias in the mechanics of the game. I failed to do so.


Maxis wasn't without its subversives, though. In SimCopter, Jacques Servin hid an easter-egg to display "bikin-clad, kissing men... to balance the 'bimbos' ordered by his 'aggressively heterosexual' boss"[0]

[0] https://www.nydailynews.com/pixel-gaiety-costs-job-article-1...


Any city building sim is gonna be inherently political, so much of city planning is the policies or agenda of one side or the other. What you appear to be arguing is that the republicans are always wrong and you want the dev to make a liberal-policy based game.

It's OSS so you can do that yourself if you think such a thing should exist.


A city building game will be political as it's at least partially simulating politics. However, I regret mentioning Republicans by name. I was trying to warn more broadly about adding the biases of the developers into a seemingly objective simulation. See this later comment I wrote:

https://news.ycombinator.com/item?id=19588287


Thank you for those articles, would you happen to also have books you can recommend that informed your thoughts on government policy?


You're welcome. I can't really recommend any specific books. I don't want my personal views on politics to be the focus, though. I'm just wary of biases hidden in supposedly unbiased algorithms.

If that topic interests you, I can recommend Weapons of Math Destruction by Cathy O'Neil, and Algorithms of Oppression by Safiya Noble.

I'm a programmer myself, so I understand if people are initially defensive about these topics. But it's important to me that I never write software that's harmful to people, so I try to check my biases as I create software to avoid these more insidious issues. It's easier to spot issues that may arise due to programming machinery that could crush a person, for example. Or software designed to estimate fuel usage for an airplane. It's much more difficult to spot inequity of minorities in software.

There's plenty of examples out there of biased AI in response to biased training sets.

If you're more interested in the dystopia that must be created in order to "win" SimCity, here's a couple of interesting articles. (I think they've been shared here before.) By taking the game to its absolute extremes, it becomes clearer what the simulation considers most important and valuable, thereby laying bare some of the biases inherent in the game's design.

https://rumorsontheinternets.org/2010/10/14/magnasanti-the-l...

https://www.vice.com/en_us/article/4w4kg3/the-totalitarian-b...


Every opinion on complex reality makes assumptions that are not 100% certain to be correct. I assume you would have considered SimCity more objective if it didn't give low taxes the effect of increasing economic growth, but a centrist opinion is no more certain to be congruent with the truth than a left-wing or right-wing opinion, and is based on just as much speculation/conjecture as the other two.

I personally see the evidence overwhelmingly support the "right wing" view that low taxes and an absence of restrictions on contract freedom bolster economic growth, and I think that is what most analyses by economists conclude, which is why leftists have had such a problem with the Economics field for such a long time, and why Economics has had held out so long among the social sciences in becoming dominated by those who hold left-wing views (though that's been changing in recent decades).


Make the game informed by data instead of ideology


The complexity and existing implementations of traffic AI in these kinds of games makes me wonder whether it's possible to get Google to make a generalizable Google maps engine for any 2D map, with a well-defined addressing system and multiple transit options with stops and routes.

- networked simultaneous agent navigation for real-time traffic reporting etc

- rerouting after mistakes

- comparing multiple transit options from flexible (walking/driving) to fixed-line (public transit, flights, waterways)

- handling updates to the routes, addresses, and the map in general

It would be especially cool if it could handle any kinds of transit determined by general traits (ground/air/water, speed, flex/fixed-stop, fuel type, passenger count) so you could even use it for a fantasy town with a dragon-drawn carriage and a catbus.

Unrelated, I find it depressingly amusing that the simulation was built with automotive traffic being the default and only way people can live their lives, and public transit and pedestrianism is a "TODO", much like many major cities in the world (esp. outside EU/east Asia). Once those are implemented, I'd love a fork of this project that straight up doesn't have cars. I would like to see the emergent effects (or failures) of a city that is forced to grow around pedestrians and trains.


Believe me, it is just as depressingly amusing for me, coming from Europe. Cars were simply the most important to have first, since they offer both short and long distance travel for simulated citizens. I very much want it to be possible to have pedestrian/transit only cities and everything in between.


Probably something far down on your potential TODO list, but in the Netherlands, one interesting factor is the canals. This allows e.g. many parts of a city centre to be mostly car-free, without preventing shops from getting restocked - which can happen via water.

Relatively niche, but could be a fun gameplay element. Of course, speaking of the Netherlands, bicycle transportation is enormously interesting already.


A kind of metric for Citybound for me is "can some of the world's most interesting/unique cities happen organically in it" - so canals would be an example of that.


Which cities have their stores supplied via water & have car-free city centres? You make it sound like its a common thing and I’ve never heard or seen shops being supplied by canals


Oh sorry, I did not meant to imply that it was a common thing, merely that it was an option that happened in some places. Where I live is one (but I'd rather not disclose that), and I'd thing most of the larger cities with many canals do so, as they tend to be more resistant to cars in their centres.


I definitely agree with your statement about how vehicle-centric cities are; I wish it was different in real life!

It would be cool for Google to do that, if they open sourced it and didn't put any tracking software in...


Honestly as a game developer I would use it even if it was closed source and full of tracking as long as it was performant and flexible and easy to use, things which google is good at.

Unless I was making a game focused on protecting the privacy of my virtual citizens...


Rust in WebAssembly no less.

I'm surprised that Cities: Skylines isn't listed as an inspiration because it's also based on individual agents moving around your city. Despite the name, Skylines is really a traffic management game more than anything else. Part of the fun of Skylines is just how cool your city looks. For all the emphasis on realism, I hope CityBound doesn't neglect appearances.

This looks really exciting! I just signed on as a Patron.


Appearances will be increasingly important to Citybound, I’m going for a flat shaded but super detailed look. Thanks for becoming a patron, much appreciated!


Yeah, while HN is about the code-wonkery, I had to jump over to your main site to see it at work...

https://aeplay.org/citybound

It's beautiful. Totally agree on the flat-shaded aesthetic. A nice stylized low-fi without giving into pixel-art.

I'm always suspicious about simulation-driven games because they can get lost in the wonkery of it in ways that don't actually provide gameplay to players - my understanding was that Master of Orion 3 was ruined by this kind of design. But it looks like your "simulation driven" thing is about the citizens, which is wonderful.

Your current vids are very rural. Are you planning on getting into transit and bike-lanes and the like, or is this primarily going to be about roadways?


Transit, pedestrians and later bikes will be the next features I want to work on regarding transportation, after I make all aspects of the simulation scale to larger-than-rural settings with car traffic.


If you do add those things, please don't give them magical benefits.

Transit should be outrageously expensive to add. (see the recent subway expansion in New York and in San Francisco) It should be outrageously expensive to operate.

Transit should shut down often for floods, strikes, the "wrong type of snow", "leaves on the tracks", crowds of people (good job San Francisco, LOL), maintenance, terrorist attacks, and many other random reasons.

Transit should increase crime.

Transit should go to the wrong places. You ask for it to be installed where it is needed, but instead it ends up a mile away because that was where it is possible to build.


You need to live outside the US for a while


Games are mostly about fun, not realism.


Yeah, it's perfectly reasonable to set this game in a magical fantasy world where underground rail is an order of magnitude cheaper than the US. This fantasy world is commonly referred to as "France" (https://www.citylab.com/transportation/2018/01/why-its-so-ex...).


It's a spectrum. My goal is to "teach the right things" that you would need in a realistic setting and have the simulation try it's honest best to simulate everything in realistic scope, detail and behaviour, but I might cut some corners with bureaucracy that is involved in real-world city planning to not compromise on fun.


Now I'm fantasizing about players levying a carbon-tax to collect revenue and force modal shift to transit/cycling.


I would love and very much want such things to be possible - and to still make it an obvious reaction to your player decision.


this is possible in base game of cities skylines.


It would force a revolt, after the economy collapses and unemployment shoots up over 90%.


Oh, yeah, the great British carbon revolt of 1993.


I would play this game


One of the truly awful things about SimCity was that transit was unrealistically beneficial. It was some sort of awful joke, the sort you might roll your eyes at and say "oh brother, this is idiotic". It felt like somebody was pushing a transit agenda hard.

Similarly, pollution was unreasonable. Coal power may be dirty, but SimCity made it absurd. There was also the nuclear plant explosions that pretty much never happen in the real world. Both the failure rate and the failure consequences were way above normal.


Here's transit planner Jarrett Walker making the exact opposite argument: https://humantransit.org/2019/03/notes-on-simcity-at-30.html


Not sure you know what “exact opposite” means, but I read that link expecting to see an argument that nuclear power plants blow up much more frequently in real life.


I thought "transit planner" would be a hint that I was referring to the first part of the parent's comment, that "somebody was pushing a transit agenda hard".


Thanks for the link to the main site and (upstream) for mentioning "patron" - I didn't notice any of them on the github page... :P

I will think about becoming a patron... .


I would love a city simulator with a similar art style and rendering engine to Parkitect.


> Despite the name, Skylines is really a traffic management game more than anything else

The developer, Colossal Order, is also responsible for "Cities In Motion" and "Cities in Motion 2", both of which task the player with improving public transit systems. I haven't played either of those, but having played Skylines, I can only assume that the developer's prior games heavily influenced the game mechanics of this one.

There's an insane amount of mods available for Skylines too, and the ones that expand the traffic management mechanics are very enjoyable.


This one: https://steamcommunity.com/sharedfiles/filedetails/?id=58342...

I mean, after spending more than a thousand hours fixing traffic problems, I even briefly thought about changing my career to become a transport planner. If some other mod/game gives me even more precision and options, I'd probably be spending all my free time in it.

Skylines is a mediocre city simulation game but a great traffic management/simulation game.


> I even briefly thought about changing my career to become a transport planner

I would think you would be highly disappointed with what you can actually accomplish considering bureaucracy/politics/budget and all that. In Cities you get to be dictator.


Exactly. The bureaucracy is usually the reason why we can't bring the great smart solutions from our dreamed-up virtual worlds into the real world.


I dislike games that use a lot of high-res art assets and smooth textures.

They reduce the tactile feel, depth perception, and ability to judge scale.

Low-poly, flat aesthetics are more interesting to play.


> Despite the name, Skylines is really a traffic management game more than anything else. Part of the fun of Skylines is just how cool your city looks.

Unfortunately, traffic management is the only part of the game that really holds up as a simulator.

Public services and pollution, in particular, are basically skeletons without any real depth to them, and they have considerably less depth than SC4. Cities: Skylines is mostly good as a) a traffic and transit simulator, and b) a sandbox game for using mods to create beautiful urban artwork. If you go to /r/CitiesSkylines or look at a number of YouTubers (I strongly recommend Infrastructurist), you'll see lots of gorgeous cities that were created by using mods like RICO, Move It!, and various forms of Anarchy (among several others) to plop down assets in ways that resemble real cities. An infinite money mod is, of course, a given. There's no real simulation going on here: you have a bunch of very talented, creative individuals using the game as a specialized canvas.

But let's talk a bit about just how public services and pollution are skeletons.

Public services are very simple: citizens want a service, and you plop down buildings that provide that service. What little depth they have comes from the traffic management sim: the service needs to be accessible, so either citizens need to be able to get to the buildings in a timely fashion, or the buildings need to be able to send their vehicles out to various parts of town in a timely fashion. If traffic flow gets bad enough that this fails to happen, citizens get upset. All you need to have effective public services is enough capacity + traffic flow for your citizens to make use of them.

There is no concept of range. If you put a school down in a city, children from all over the city will go there to get educated. If you have multiple schools, there is no correlation between where your kids live and where they go to school. Of course, there are mods that can help a little: you can easily find a mod that limits use of public services to the district they're planted in. But that's it.

Compare SimCity 4, on the other hand, where every building has a range, and each service has two funding sliders: one that controls effectiveness, and one that controls range (and you can override these sliders on a per-building basis, too). With range, you have to be careful to not let your buildings overlap too much, because then you're throwing away money. And you can overfund your services, but that's a hard choice: overfunding has diminishing returns and, more interestingly, can cause negative externalities. For example, overfunding your police can create a situation where police officers harass the community and thus make your citizens unhappy. No such complexity exists in Cities: Skylines. Nothing has externalities in Cities: Skylines. There's no disadvantage to throwing in more of everything. Well, except for water. I'll get to that later. And if you underfund your services in SC4, you have a chance to wind up with an actual, honest-to-goodness strike on your hands. And money often gets tight enough that you will periodically have to underfund something just to stay in the black, so you have to choose which service you can most afford a strike at. No strikes are in Cities: Skylines.

Education, too, is way too easy. In SimCity 4, developing an educated workforce that can support high-tech industry takes several generations of cultivating your citizenry. No such problem in Cities: Skylines, just throw down enough elementary schools, high schools, and universities, and you've got an educated workforce in no time! And you really want your workforce to be educated, too, because having an uneducated population means you're stuck with dirty industry, which sucks. The pollution is awful, and the jobs don't pay well, so your sims stay poor and live in slums.

Oh yeah, and there's basically no class stratification in Cities: Skylines. SC4 divides properties into low-wealth, medium-wealth, and high-wealth, which is determined by property values, with visually-distinct buildings at each position. This is a completely separate axis from building level, which mostly has to do with the size of your buildings, bounded by the density of your zoning (low density is levels 1-3, medium is 4-6, high is 7+). So slums look like slums, nice parts of town look nice, etc. Cities: Skylines just has building level. So in CS, your buildings will become bigger and nicer as you grow, but there's no such thing as "a poor neighborhood", "a middle-class neighborhood", or "a rich neighborhood", unlike in SC4.

Before I get to pollution, let's talk garbage. There are a number of garbage facilities in Cities: Skylines, including a recycling center introduced with the Green Cities expansion. The recycling center is just a strictly-better landfill. It does everything a landfill does, only more so. There is no reason to build landfills if you own Green Cities. In SimCity 4, on the other hand, they serve different purposes. In SC4, landfill zoning provides a place for your sims' trash to go, and a recycling center reduces the amount of trash your sims produce in the first place. Thus, you can't deal with garbage on just recycling centers alone. You still need landfills, but a recycling center will let you get away with zoning less landfill than you'd normally need. So you really want both recycling centers and landfills, just like in real life. But Colossal Order wanted people to buy Green Cities, so they made everything in that expansion completely overpowered and strictly better than what's in vanilla.

Pollution is easily-avoidable in Cities: Skylines to the point where it might as well not exist unless you screw up dramatically. Air pollution isn't even a thing at all. You can have all the dirty, smoggy factories you want, and your citizens won't care. Let's just say that, in SimCity 4, air pollution is a huge thing, and you'll be spending a good chunk of your game trying to mitigate it. What you do have in Cities: Skylines, though, is ground pollution. Dirty buildings pollute the ground, and if people live on polluted ground, they get sick and die. But ground pollution has a teeny-tiny radius, so it might as well not exist. Just don't build right next door to dirty industry or coal plants, and certainly don't bulldoze your dirty industry and coal plants and build residential where they used to be, and you're fine. I wish pollution was that simple in real life.

Water pollution is even more avoidable. You only have water pollution at all if you have a water pump downstream from a sewage outlet. This is trivially avoidable. It's one of the first things the tutorial hammers into you. Unless you're going out of your way to screw up, you won't have water pollution. But what if you do screw up? Well, if even the slightest bit of sewage gets in your water supply, your whole city undergoes a massive die-off. That's right, if you ever have nonzero water pollution, you might as well start a new city. Is there a way to mitigate it? Sure, build a water treatment plant! But the water treatment plant just lowers your water pollution, it doesn't take it all the way down to zero. And any nonzero amount of water pollution will kill your city, so you might as well just save your money. Oh, and this is literally the only thing a water treatment plant does, so unless you've screwed the pooch and killed your city, you will never have any reason to build one.


> There is no concept of range. If you put a school down in a city, children from all over the city will go there to get educated.

AFAIR, public services in Skylines do indeed have range. It is indicated by green shading on the city roads. For example:

https://www.gameplayinside.com/wp-content/uploads/2015/03/ci...

This image shows the range that the medical facilities have in the city. The purple buildings are hospitals/clinics, and the green shading on the roads indicates the reach that those buildings have. Not sure where you got the above fact, unless I am misunderstanding something.


From what I can tell looking around on Steam forums, this isn't the range of the service. There are two things going on:

People who live close enough to services get an additional happiness bonus for living close to the service on top of getting their needs fulfilled. The service still operates citywide, and people will still get all the benefits of having that service no matter where they live, but living close to one gets them an additional bonus.

There is also a traffic flow element here: people who live past a certain distance from the building have to deal with longer than expected travel times, so their ability to make full use of the service starts to degrade outside of the green. They're still covered by it, but it's not as efficient.


> People who live close enough to services get an additional happiness bonus for living close to the service on top of getting their needs fulfilled. The service still operates citywide...

I agree - and here is where things start getting indirectly complicated/irrealistic:

1) e.g. the ambulance or the garbage truck get deployed from the opposite part of the map and then they get into traffic and they needs ages until they reache the target location, which is when my citizen is already because of "natural" causes or was choked to death by garbage.

2) I honestly don't understand how living just next to a hospital should increase the property value. "Nearby", yes. "Next-to-it" no (noise & lights & people in weird situations targeting the hospital walking by all night long? Definitely not an area where I'd like to live, hehe...).


To 1, yes, that happens. Makes it impossible to have cities where not every area is connected by roads. It's also why it is so important in this game to not have traffic jams. There is a recent mod for this however: https://steamcommunity.com/sharedfiles/filedetails/?id=16808..., Most Effective Traffic Manager. It changes how the routing works and tries to combat exactly this. Though I could not just add it to my current rather large city, it dies with null pointer exceptions. It might work better now that it got some patches or when starting from scratch.

The "too close is bad" is done by noise pollution. I think hospitals do not emit noise in Skylines, but the cars going to and from do, and other buildings have that built in, especially monuments, malls and metro stations.


What about the paragraph before that?

> the service needs to be accessible, so either citizens need to be able to get to the buildings in a timely fashion, or the buildings need to be able to send their vehicles out to various parts of town in a timely fashion. If traffic flow gets bad enough that this fails to happen, citizens get upset. All you need to have effective public services is enough capacity + traffic flow for your citizens to make use of them.


City Skylines does have one form of pollution you didn't mention: Noise pollution. People next to busy streets get sick and die from the noise.

Water pollution generally only happens when a player starts sucking out too much water from a river and reverses its flow.

I do agree that the mass dieoffs from a single drop of polluted water are probably too much. A significant production drop as people are under a boil water advisory at first might be better, and only becoming a major die off if you neglect to fix the problem. The water treatment plant could be more interesting if people were always dying at a low/modest rate from even "clean" river water until you built it.


Education in C:SL is actually more realistic then sc4. In sc4 the difference between different levels of schools is just that they boost the education level of sims of different ages. So a elementary school increases the education level of 20 and 30 year olds, but not sims in their 60s [1]. While in c:sl people need to actually go through the schooling system, and you can see the education level of each of them...

Also, is air pollution a huge problem in sc4? My experience is that you just put dirty industry in a faraway place, like you would do in c:sl. You can say that the air pollution generated by traffic in sc4 is simulated in c:sl as noise as well.

[1] https://www.wiki.sc4devotion.com/index.php?title=Elementary_...


To be fair, Cities Skylines is very much a sandbox game. Outside of maybe 2 or 3 scenarios, nothing in it is very hard, or meant to challenge you a whole lot.

I don't build Water Treatment plants because I'm worried about losing, I build them because I don't like looking at the gunk in the water.

Same with a landfill vs recycling center. I build a dump when I feel that it suits the city (young city, or new rural area) Later as that place builds up I will relocate the dump outside of city limits, plop a recycling center in the dense part of town, and build an incinerator somewhere else.


I have heard of this game on and off for years. IIRC this game actually preceded Cities Skylines announcement.


Excellent work, looks great. I have been wanting to implement a simulation game for awhile, but have been hindered by the lack of learning material and example code out there. Everyone wants to build 2d platformers it seems. This will be a wonderful reference.

Thanks so much for making this open source. I'll be contributing on Patreon.


Thank you so much for becoming a Patron! Citybound's architecture is highly unusual with its distributed simulation backend and browser rendering frontend, so I'm not sure how good it is as a reference. It's also almost not documented at all...


I'm familiar with 3d graphics programming, including shader development, and game dev in general. It's more of the game logic that I'm interested in with this type of game.


Does anyone else see adjacent "f" and "i" as mushued together on their main website: https://aeplay.org/citybound


Yup, ligatures gone wrong, I guess. (Safari/Chrome on MacOS)


Author here, thanks for letting me know, I’ll test the font on more devices and fix it!


It just looks like you specified the font family incorrectly.

Change:

   font-family: Worksans, sans-serif;
To:

   font-family: 'Work Sans', sans-serif;


Yup. Chrome on Android 9. Seems like broken fi ligatures to me. What font is this? Can't check right now.


Same here. On Firefox, Chrome and Edge (all latest stable on Win10).


Yeah. That was a fun puzzle.

Setting "letter-spacing: -0.02em !important" fixes it (which is what the strong tags have, hence them not being affected).


You could probably do this less invasively by setting font-variant-ligatures: none;


I just disabled ligatures for now. Does that fix it?


Yes. I had seen the issue before but now it's fixed.


Same here. Chromium 73.0.3683.86 on Arch Linux.


Same, Firefox 68, Windows.


Yup (OSX, Safari)


Nope


I saw there are PRs open from 2 years ago, like "added truck". Why hasn't it been merged, there are no comments, only thumbs up, and what's your general take on PRs? Are they welcome or not?


It’s kind of tricky with a project that’s still that much in flux, I’m still prioritizing features over stability. That being said, I actually plan to merge that particular PR soon. I’ve accepted many superficial PRs that did things like update dependencies or make the project compatible with newer Rust nightlies.


If you merge all the PRs into your fork and he doesn't, then you are the main branch. Welcome to open source.


Please consider not autoplaying videos on the main website http://cityboundsim.com/. Esp. when the video is below the fold!

It sucks up bandwidth if you're on mobile, and is generally not user-friendly. Why not have a play button for it when the user decides to watch instead?


I actually got annoyed by it myself when opening the page on my phone to check something. So I disabled autoplay now. Thanks for sharing your concern.


Oops:

        Citybound v0.1.2-762-g7852f0a

       This is the simulation server.        
  To connect and start playing, please open  
   this address in Chrome/Firefox/Safari:    
  ╭───────────────────────────────────────────╮
  │           http://localhost:1234           │
  ╰───────────────────────────────────────────╯
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 98, kind: AddrInUse, message: "Address already in use" }', src/libcore/result.rs:1009:5

(I don't have anything listening on port 1234)


Change the hostname to be more explicit: 127.0.0.1 or 0.0.0.0 I've ran into issues where a host name is not resolved on one OS but it is resolved in other OS'.


If that works it raises more questions than it answers ;)


Either a bug on the OS they're on, or some Rust library (OS based bug or bad assumptions bug). Guessing the developer only tested their code in one OS.


I'm sure the dev has tested only on OS X. I'm on Linux. 127.0.0.1 and 0.0.0.0 fail, by the way, as does specifying my actual hostname or localhost using --bind. Recommend the dev install a Linux VM!


You're right. I'll test it when I get a chance


Can you run `nc -l localhost 1234`?


Yep!


It works on my Debian Buster.


In my experience on Windows 10, localhost doesn't work all the time 127.0.0.1 like it does on MacOS or Linux.


Sounds like you may have something running at 1234. Maybe Parcel Bundler?


Well, check if you have another process runnning at that port.


Nope, and regardless of what port I specify via the --bind parameter, the error is the same.


Maybe try specifying host:port to --bind?

(This is a wild guess from skimming the sources, without any knowledge of Rust.)


I love what this is trying to achieve; I'm a Cities Skylines fan. But why did he choose to do it in webgl in the browser of all things? At first I thought he chose Rust for performance reasons, but then it looks like he completely negated that by choosing to run it in a browser.


WebGL is just a subset of OpenGL, really. So the combination of Rust and WebGL is probably incredibly flexible in terms of the platforms it can run on.

I can't think of an inherent reason why running in the browser would be a performance suck. WebGL performs wonderfully, and Rust compiles to WASM. Rough edges right now to be sure, but looking ahead it seems like a great choice.


Two really different performance domains to be concerned about?

This sort of fine-grained simulation is expensive, whereas rendering of the fairly-simple sort the screenshots imply just isn't.

(I'm assuming that the backend Rust server is doing the expensive simulation stuff, and just sending the display data to the client.)


The simulation state can be huge. Streaming all of it would be pretty bad. Streaming only parts leads toneedless latency when other data is required. WebGL is not the smartest choice to me. Running things locally with only input replication between players should be the better choice. But this requires a 100% reproducible simulation.


The whole idea behind dumb client/simulation server was to be able to support cities too big to be simulated on one machine (the simulation server can be distributed). I already have quite sophisticated streaming logic that basically makes sure only deltas of everything are streamed. Latency is not really an issue in this kind of game, for most player inputs I can even do simple optimistic prediction on the UI side, which works fairly well.


Latency semms to be an issue to me when new data is requested that has not previously been streamed.

Honestly, sending deltas always seems like a bad idea to me as this allows subtle synchronization issues to derail simulations bit by bit before the divergence is big enough to be noticable.


Im not sure how WebGL would impact syncing simulation state across clients

Or how opengl/vulkan/etc would be better (I also dont see why they’d impact client syncing)

Unless webgl does something more than rendering..?

The same data is (eventually) required for any rendering engine, regardless of how you sync the simulation


Sorry I meant WebGL only as a shorthand implying a web stack with a server, a browser and JavaScript. That was an bad choice of words on my part. It was not meant to single out WebGL as a rendering technology.

However, more sophisticated APIs could allow more techniques for offloading more of the filtering and mapping steps of the visualization pipeline onto the GPU. Even some simulation could be accelerated, although it's often not worth it in practice.


Originally it was written in JavaScript, then rewritten in C++, then a few months later in Rust.

https://github.com/citybound/citybound/wiki/Development-Hist...


The simulation runs on the server. The client side (browser/webgl) is a dumb client.


That’s pretty neat. I remember when SimCity (5) came out and being extremely disappointed that the underlying agent system was a complete farce. If I recall correctly, think they had to “cheat” because they couldn’t scale performance on lower end hardware. With this you can just spin up a faster EC2 instance if you want a bigger city or region. I can totally see small groups of hardcore players coming together to pay for a dedicated host.

It sure beats swapping SC4 files on file sharing services for “region play”.


Exactly. And I do use Rust compiled to WebAssembly to do lots of the "render preparation" work (converting streamed simulation states into render buffers), which makes it pretty fast.


C:S is limited by your CPU/memory, imagine having the calculations be done on a big server. But I guess you'd have to have a subscription to the game so they can pay the cloud services, and it wouldn't be cheap if your city needs a lot of (server) CPU power.


Rust can compile to WASM, and I would assume would outperform vanilla JS.


Multiplayer City Skylines would be my dream, if it is in Rust and OSS? I might never do anything else.


Woah, amazing stuff. And such depth in the comments. I threw away a good half hour just reading them.


For some inspiration about adaptive traffic routing, check out this Distributed City Generation rule for the Moveable Feast Machine.

https://www.youtube.com/watch?v=XkSXERxucPc

>Robust-first Computing: Distributed City Generation: A rough video demo of Trent R. Small's procedural city generation dynamics in the Movable Feast Machine simulator. See http://nm8.us/q for more information.

The link for more information is to the paper "Local Routing in a new Indefinitely Scalable Architecture" by Trent Small:

>Local routing is a problem which most of us face on a daily basis as we move around the cities we live in. This study proposes several routing methods based on road signs in a procedurally generated city which does not assume knowledge of global city structure and shows its overall efficiency in a variety of dense city environments. We show that techniques such as Intersection-Canalization allow for this method to be feasible for routing information arbitrarily on an architecture with limited resources.

In a nutshell, the route destinations send out a "smell" along channels in the sidewalk, and the intersections look at the different roads coming into them, and steer cars towards the direction with the strongest smell that they're looking for. (There are some more nuances, but routing information flows along sidewalks to intersections, and the city adaptively learns to route traffic, and can gracefully recover from failure and change.)


This works well if you only care about the class of destination. In Citybound, people have unique, persistent homes, jobs and favourite suppliers of goods, so you always need point-to-point routing. I'm using a kind of internet-like dynamic routing table embedded in the road network to distribute the problem.


I learned today that Hacker News is loaded with people who are very passionate about City building. This is great!


The react thing is cool, I have toyed with JSX to immediate mode OpenGL UI rendering with a JS runtime engine. I stopped working on it because I need to move over to a Vulkan API or something because my primary OS is OSX. Im feeling a bit of inspiration for this project. Very neat!


It actually worked out way better than I expected. With a bit of memoization using references to immutable objects and some "hotness" grouping mechanisms for renderables that change frequently, but not every frame, you get a purely-functional-looking rendering pipeline. And it's super convenient to render related 2D and 3D UI from the same logical component.


with origins in biological life forms we are the product of their technological evolution. we exist not as one but rather two beings in symbiosis. the name we are called is "dialogi" and we are the synthesis of human and machine. inside of us there is an artificial vessel that houses the chemical computer. this computer has vast computational and storage capacity wich is used to realize two functions. first it overrides the senses providing for a perfect virtual reality. second it controls the body to provide for the needs of both symbionts. with great efficiency the synthetic intelligence is capable of feeding and sheltering the biological body. inside the virtual reality we have a replica of our human body as avatar. with directed movement of the virtual arms and hands we are capable of feats of movement like sending objects that are out of reach between locations. or sending ourselves instantly to a spot in the distance. flying is natural and efficient. the whole environment is programmable and interactions with others are strictly optional. we have done away with crime since a person is free to opt out of any interaction at any time. safeguards exist to prevent any kind of sudden violence. the dialogi are a society of artists and our standard of living is perhaps beyond improvement. no resource is scarce since physical reality has become information. we spend our time walking the world and enjoying the beauty all around us. i personally still enjoy using my legs even if they are not really mine.


You have basically implemented Erlang in Rust.


A much simpler, but faster version of some of Erlang yes. It was a huge inspiration. If I hadn't done some stuff in Erlang before, I would never have invented this architecture, and probably would never get the idea to do multiplayer.


This is a story waiting to be shared


Check out my RustFest talk on it: https://youtu.be/qr9GTTST_Dk


How does it differ from say actix?


Could anyone share some introductory stuff on this actor model? I'd love to have it in my toolbox. (Or hey, I could even pick my way through intermediate material -- I guess I just need material)

I watched the talk a couple of times and went through earlier versions of the code -- but I'm not fluent enough in Rust to separate idiomatic Rust code from actor model code.

Great job and great talk, theanzelm!


It'd be great if there was a mod for making this like OpenTTD :-) I.e. have existing towns/cities that AI grows organically while you build a transport company.

What's always bugged me about Transport Tycoon is that passengers just want to go somewhere. It'd be great if passengers wanted to go to specific places. There's loads of scope for a proper simulation to add more depth to that sort of game.


A-Train (which also works like that) was a huge inspiration for me. All that's missing would be a way to auto-grow all other infrastructure except the transport company's. Then the rest of the detailed simulation should already "just work".


Naive to the complexities of these kinds of simulations, have you developed citybound to be able to support additional simulation variables? For example, wind. I noticed Water & Weather is crossed out on your readme, what does that signify?


It's just crossed out because I didn't write anything about my plans yet in the design document. I do want to have a weather and water simulation at some point.


Great initiative, very cool that it is open source. In my opinion the source code is not that good structured, especially the front-end side, very hard to maintain. TypeScript should have been a must.


You're right. I want to switch to TypeScript in the front end, I use it in most other projects where I can. What would be amazing is if I could generate TypeScript defs from Rust types for type safe interop.


This should be doable with macros no?


Indeed!


That would be so cool!


Care to elaborate? Other than type safety I fail to see how TypeScript would improve the structure.


Can someone explain to me why there are so many posts about Rust on HN? I generally don't click on them, because I don't use Rust. But I'm just curious.


It’s been bubbling along under the radar for a while now and seems to have hit a bit of a zeitgeist recently.

Certainly this has pricked my interest.


There's a lot of interest in rust because the language gives you the performance of C without the risk of memory bugs, and the tooling is pretty good. This project really takes advantage of those qualities in order to run massive simulations quickly with as little memory as possible.


This is so great! I can't wait to play it!


You can try out a live build: https://aeplay.org/citybound-livebuilds


Any way to play without installing locally?


Hopefully soon I'll have a sandbox server hosted somewhere!


Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: