1340 points · by formalsystem · 7y ago · 264 comments
Also, check out the main homepage at https://aeplay.org/citybound for a more player-centric intro
https://www.reddit.com/r/rust/comments/78bowa/hey_this_is_ky...
https://www.rust-lang.org/static/pdfs/Rust-Chucklefish-White...
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?
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.
https://www.youtube.com/watch?v=LiIoE8ArACs
It was great, if so!
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.
Your architecture could be very useful in teaching.
What exactly would you like to see in a writeup? And which teaching setting do you have in mind?
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! :)
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.
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?
The fire department will have an opinion on this.
So many things will be difficult: construction, trash hauling, tree removal, relocation, business deliveries, etc.
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.
So by all means start teaching yourself to code by playful experimentation, but start with something much simpler first :)
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.
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.
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 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".
Cool containers.
All in all I'm sure I'll spend a ton of time playing the game itself and playing with the source.
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.
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.
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.
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.
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.
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.
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] https://www.nydailynews.com/pixel-gaiety-costs-job-article-1...
It's OSS so you can do that yourself if you think such a thing should exist.
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...
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).
- 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.
Relatively niche, but could be a fun gameplay element. Of course, speaking of the Netherlands, bicycle transportation is enormously interesting already.
It would be cool for Google to do that, if they open sourced it and didn't put any tracking software in...
Unless I was making a game focused on protecting the privacy of my virtual citizens...
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.
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?
I will think about becoming a patron... .
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.
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 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.
They reduce the tactile feel, depth perception, and ability to judge scale.
Low-poly, flat aesthetics are more interesting to play.
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.
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.
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.
> 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.
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.
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_...
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.
Change:
font-family: Worksans, sans-serif;
To: font-family: 'Work Sans', sans-serif;Setting "letter-spacing: -0.02em !important" fixes it (which is what the strong tags have, hence them not being affected).
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?
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)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.
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.)
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
https://github.com/citybound/citybound/wiki/Development-Hist...
It sure beats swapping SC4 files on file sharing services for “region play”.
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.)
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.
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!
Certainly this has pricked my interest.
Like, think how non-square zoning would work.
Is that named after Alan Kay?
Thanks so much for making this open source. I'll be contributing on Patreon.