Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411426 Posts in 69363 Topics- by 58416 Members - Latest Member: JamesAGreen

April 19, 2024, 10:44:15 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityDevLogsCyberpunk City Simulator
Pages: [1]
Print
Author Topic: Cyberpunk City Simulator  (Read 8390 times)
mflux
Level 0
*


View Profile
« on: December 05, 2016, 10:11:48 PM »

Hello TIGforums, this is my first time posting here.

Cyberpunk City Simulator



(Image by Klaus, un-related, using only as target images)



Procedurally Generated (and editable) Buildings
Certain buildings are procedurally generated and can be directly edited by you.

Example of live building edit in-game:


Some examples of things it can generate:







You can find a gallery here: http://imgur.com/a/BNDht



Development So Far

Work started in 2014. The very first version was a pixel-art based isometric graphics with procedurally generated buildings. It was being made in Phaser.js for web browsers and it had a THREE.js building generator built internally which rendered into sprites:




Early procedural buildings.

The next version was built entirely in 3D using WebGL / THREE.js.





Work on this version stopped after realizing that deferred lights in WebGL was simply too slow, and I needed lots of lights for the look and feel.

I then ported the entire game to Unreal Engine. The base game-core is untouched, the simulation still runs in Javascript and is fast enough to do what it needs, however all the heavy lifting for game-engine related things are passed to Unreal.




I recently buckled down and started focusing on gameplay and temporarily simplified the art so that things are clear what they are and how they work.




And finally, I have a first dev diary video here







About myself
I'm a freelance creative technologist and I make games on my free time. My last game was Blade Symphony, a mulitplayer sword fighting game released on Steam in 2013 in collaboration with Puny Human. I'm on Twitter as @mflux.





You
I'm posting because I could use your feedback. Unfortunately no build of the game is online, however I'll post as much detail on gameplay as I can as I'm trying to flesh out all the nitty gritty details of gameplay right now, starting from the most basic of things like city management, corporation management, cultures, and so on. What kind of things would you imagine being able to do in a game like this?
« Last Edit: September 07, 2017, 02:32:52 AM by mflux » Logged
mflux
Level 0
*


View Profile
« Reply #1 on: December 20, 2016, 01:56:10 AM »



I worked on "zone levels" which is a measure of a zone's desirability. These factor in things such as land scarcity, access to parks, proximity to hospitals, etc. I also did an optimization pass where by the areas covered by these amenities are draw into a bit flag map, so that zones don't need to compute their distances to those services during simulation.

This spreadsheet is interactive and describe how a zone "levels up".



You can see the actual sheet here:

https://docs.google.com/spreadsheets/d/1lCCspvPyk5wDZnesfIHlyj04SXa9NkwWoYcCeJm75ys/edit#gid=0

There was also a quality of life pass. For example the top UI now has tooltips that expand on how your income is working;



Speaking of UI, I put a lot of work into creating this "corporation HUD" where you establish new corporations to build in your city.  The "assessment" menu isn't showing anything right now but normally it would show what stats your city is missing in order to establish (too low of tech score, education, population, airport access etc).



However I think I'll change how the player actually obtains an opportunity for new corporations. Instead, the player should get an email, explaining their terms and conditions, and you have a chance to decide whether or not to work with that corporation. This would give some opportunities for proc-genned emails and goofiness.

Speaking of proc-gen content, I wanted to give everything more character, and opportunities to tell stories. So now everything has a proc-genned name of sorts. Here's the power plant:



Some factories...




And some housing...





Ofcourse who wouldn't want to live at:


I overhauled the data-visualization for pollution and commute. They were actually showing underneath the building and road models and generally being useless. Here, I'm using a stencil buffer to draw the visualization in a second pass.



And finally, I revamped pollution to not use a radial-paint algo, but instead I apply a blur-pass in order to achieve the pollution falloff. This seemed more natural.



I think for the next steps, I need to tie the upgrade route for buildings (zone levels) to the procedural building generator so it could create something sensible for its level. I have this chart...



Which is a good place to start. I'm still struggling with the right data format for proc-gen since it has so many features tying into it so the struggle is... pretty real on that front.
Logged
kinnas
Level 5
*****



View Profile WWW
« Reply #2 on: December 20, 2016, 02:09:44 AM »

Oh hello what is this, a city simulator.. but.. I'm a huge city simulator nerd! I'll be looking forward to this!

I'm also a big visuals nerd and one of the things that immediately struck me was how some of the windows on highrises feel very wide or square, to the point where they detract from the verticality of a cyberpunk cityscape and visually forze stuff down horizontally. Saying this while realizing it's all early stuff and polish will follow etc.

Anyways, looking forward to more updates and good luck on the project  Hand Thumbs Up Right
Logged

Fat Pug Studio
Level 2
**


View Profile WWW
« Reply #3 on: December 20, 2016, 02:23:13 AM »

This really looks great. I love cyberpunk and i'm a huge fan of SimCity for more than 20 years Gentleman

The corporation stuff is promising, i hope you will pull it off good Smiley
Logged

doihaveto
Level 2
**



View Profile
« Reply #4 on: December 25, 2016, 06:58:59 PM »

This looks amazing!

I'll be following your development for sure Smiley 
Logged

mflux
Level 0
*


View Profile
« Reply #5 on: January 05, 2017, 04:51:10 AM »

Oh hello what is this, a city simulator.. but.. I'm a huge city simulator nerd! I'll be looking forward to this!

I'm also a big visuals nerd and one of the things that immediately struck me was how some of the windows on highrises feel very wide or square, to the point where they detract from the verticality of a cyberpunk cityscape and visually forze stuff down horizontally. Saying this while realizing it's all early stuff and polish will follow etc.

Anyways, looking forward to more updates and good luck on the project  Hand Thumbs Up Right

Hells, Kinnas, your game's art looks amazing. Thank you for the feedback, I'll be working on that some more once I get skyscrapers again.

This really looks great. I love cyberpunk and i'm a huge fan of SimCity for more than 20 years Gentleman

The corporation stuff is promising, i hope you will pull it off good Smiley

Thanks! I won't let you down.

Where to start...

The foundations
I started designing a lot more than implementing and realized that many of my game systems are connected to core "city building" stuff that isn't done yet. For example, Corporations can screw people out of a fair wage, or they can harm the environment so much that their life expectancy drops simply by working at their factories. These all depend on "wage", "life expectancy", "security", "desirability", "pollution", "taxes" etc etc... endless lists of features that just aren't complete or even started yet. So I took a step back and I'm pausing the Corporation and Culture arcs and saving that for later.

Now... on to the good stuff.

Terrain Elevation


This is important! Without terrain variations building location becomes a meaningless decision. Should I build north? east? west? south? It doesn't matter at all on flat terrain. At its core, a city building game needs elevation and terrain details to force meaningful decisions about where to build. Should luxury condos occupy that hill over there? Or should it be reserved for wind power plants?

Well, I've only built out the visuals so far and incongruous terrain for zones are "evened out" at the highest elevation by building a foundation. It doesn't look great right now but that's alright, we can work on the visuals for that later.

More importantly, I need to figure out what to do with the elevation next. Should there be some kind of bonus to desirability for zones based on elevation? Maybe that's the simplest, dumbest thing to do right now and it'll be good enough.

Also an obvious thing that's missing is water, and trees. Oh and cliffs. My terrain generation is piss poor right now, three octaves of perlin noise. It's bad, and I'll need to work on it later. Maybe water first.

Lighting

The day-time lighting you've seen before was all for debugging. I want to get back into the mood of "cyberpunk city" building so I turned back off the directional light and ...



Also gave the residential housing window lights...



And the most fun to work on was the factory lighting...



What's really cool is that I'm exploiting Unreal's socket system. Each socket has a name, position, and rotation. If the name has the word "light" in it, then the mesh generator will spawn a light there. It'll use the scale for brightness and falloff, and rotation for color... I'm quite proud of this hacky solution because you can author light locations directly in Unreal's model setup editor.


Zone Parceling


This step was an important one because zone upgrades grow outwards first, consuming nearby zones so as to get bigger surface area, before they can grow upwards. The way I had zoning set up before was that each click and drag created a zone, which can be quite arbitrarily big. This zone parceling uses roads to determine their parcel direction. As a side-effect, residential zones can only be painted next to roads now.

This applies only to residential and commercial zones. Industrial, power, hospital, parks and everything else are just blobs of zones still and I think that's fine for now.


Health and Wealth

Factories have "salary" now. If a resident works there then they will get the equivalent amount of wealth.


Health is now calculated based on an 80 year base life span. Pollution, commute, and your work place can decrease your life span. Access to hospitals would increase it by a lot. If you walk to work, you'll also increase your life span for a bit.

The actual health metric isn't used in any other game system right now so I'll need to plug that in somewhere later. I'm not sure how yet.


Game Optimization for Bigger Cities


As I started building bigger cities, I noticed the simulation was lagging the game a lot. Like 80 to 120 milliseconds a lot. That is extremely unacceptable since it causes huge choppy motions, especially when you're panning around the game world.

(speaking of which, maybe I should just disable simulation while the player is panning.. has any game ever done that?).

I know I know... you really shouldn't optimize so early in a project. However I needed to know *now* whether the problem is systemic -- if it's something I'm doing totally wrong with Javascript, or my ECS is doing something highly inefficient. I also wanted to look for low hanging fruits, anything that can give me some more speed back.

The first thing I did was write a profiler for my game rules. Each game rule is a JSON loaded from a file (for easy modding) and some take longer to finish than others. Optimizing requires you to know if you've made speed improvements, so seeing the numbers was really important.

Next, I re-did my entity evaluation that was used in the rules. Basically, each JSON rule is evaluated using an abstract syntax tree. However, that AST needed a lot of custom game-logic code to be useful (like collecting all components of type "maintenance" to get an expense report). Unfortunately I was rebuilding this custom logic every single time I wanted to evaluate an entity. This caused a lot of waste in JS and garbage collection. The solution was simply performing this construct once, and pass in the entity just before evaluating. Unfortunately this also made the game rules slightly uglier (instead of jobs.value, it's now e.jobs.value). This gave a global speed up in simulation time.

Looking at the profiler, I saw the game was spending a lot of time performing "consumption". Meaning, every tick the laborers were looking for jobs they already had, and power consumers were looking for power plants all over the map. Even though I had cached the pathfinding and "island" lookups, the step for performing these checks shouldn't be necessary at all.

Instead, I wrote a "production cache" that each consumer had to go to before consuming a resource. Every time a resource is consumed, a "receipt" is given to the entity. Upon the next tick, all the consumer has to do is check with the production cache if its receipt is still valid. A receipt can be invalidated in any number of ways: the road paths have changed, the previous office you worked at got demolished, the power plant is exploding... etc. In this way, the consumption search is only ever performed once and never again until it needs to.

Doing all of the above got the game simulation time to under 16ms even for a wide-ish city. I think that's all the optimization I'll do for the time being... there's probably tons of other things I can do but for now I'm keeping all the "could be optimized" stuff in "simulation cache" which is great because when time comes to optimize, I really shouldn't have to touch any of the actual game logic, just the parts that are built for optimization.

A future optimization could be for consumers that keep looking for resources (like laborers hunting for jobs) should be given a delay on when the next time they can search, so that it doesn't spam up the update tick.

The build as of Jan 2017




So what's next on my agenda?

I feel like I have a near infinite number of "basic" stuff I need to do before getting to the fun parts.

  • Residents with 0 employment should start losing wealth (do they even start with wealth?)
  • Design and implement an education system. In this game it's called "tech" and your tech level determines the type of jobs you can get
  • Start adding some kind of commercial zone. Perhaps retail stores? I also worry about the art...
  • I need a way to differentiate between different types of demand for different industries. Right now demand is universal across their own zone type (all industrial has the same demand).
  • Right now zone upgrading is kind of broken and buggy. Zones don't upgrade properly.
  • I need a procedural model data format to describe the lots (parking lot, swimming pool, garden, factory space tiles) and the actual procedural structure itself. And I need to do so by keeping the Wealth (quality of building) and Desirability (how wide and tall to build). This is going to be hard to solve all at once and I'll need to start fresh somewhere. Perhaps on a proc-gen test bed map or something.

Anyway, if you sat through this rant, happy new years!
Logged
mflux
Level 0
*


View Profile
« Reply #6 on: September 07, 2017, 02:16:29 AM »

Updated since... 9 months ago? Here's an update video.

https://www.youtube.com/watch?v=shJzUpEeLns&feature=youtu.be

What the game looks like now


Still running at 60+ fps (90 zoomed in).


New and Improved Building Generator

It's now way more feature rich, including generating slum skyscrapers and hipped roofs.





Neighborhoods

Procedurally generated neighborhoods emerge.



As a collective they have opinions about their living conditions. These accumulate into points called Initiative which you can spend to construct neighborhood improvements such as walls, checkpoints, parkways, sky-bridges, etc.

The purpose of this mechanic is to more easily grok and upgrade huge swathes of your city because the cities will become quite big and difficult to manage. Instead of worrying about every tiny individual zone, it's better to group them into bigger chunks for gameplay.

Improved Simulation


Residential zones now compute happiness based off of various quality of life factors such as air quality, commute time, education, wealth, security, etc... Residential zones grow when happiness (essentially demand for the zone) increases well past its holding capacity. This is affected by overall residential demand in the city which is dependent on available jobs.

Visualized in red is the "security" rating of zones. Currently the red building is a very dangerous place to live in.

Industries "Tech Tree"


Many zones and features in the game are unlocked through the "Industries" tech tree. Many of these cost Influence points which is a measure of how well known and influential your city is throughout the world. By spending influence, you get foreign corporations to invest which is the in-game fiction to explain why you are unlocking certain industries like "manufacturing" all of a sudden. Future industries involve biotech, cybernetics, etc, it should be a fun tree to explore.

Overall game dev
I took a huge detour on making the procedural building generator more robust and built a custom tool and scripting system that helps me generate tons of buildings in real time. It's only in the past two months that I finally got back into gameplay dev and it feels good because I'm finally making progress again.

I think I've finally settled on the goal of this game. Instead of making you care about people who live down there, I want you to experience the joys of world-building. You build the city, and the game fills it in with details. What kind of drinks do this bar have? Does it have birth control pills as part of the drinks' ingredients? What dance moves do people do in these night clubs? What are the streets named? What are the local attractions and strange tourist traps?  What are the cultures, cultural artifacts, strange things that I can find when I explore a new city?

Towards this effort, my next step is to build some kind of "world building" AI helper. As you play the game and work on your city, it begins filling it with randomly generated, initially trivial detail about the world like names of places. It should then start generating stuff like foreign nations, corporations, where people come from, and begin linking these threads throughout your city. I can't compete on making a super deep simulation, however I can make something that plays the "world building" game along with you.
Logged
s0
o
Level 10
*****


eurovision winner 2014


View Profile
« Reply #7 on: September 07, 2017, 03:13:34 AM »

this is looking nice. following.
Logged
Zireael
Level 4
****


View Profile
« Reply #8 on: September 07, 2017, 03:28:26 AM »

I already saw it, I think on the UE4 forums, it's amazing what you pulled off.

I can understand how you did the basic building shapes, but how did you pull off the textures for them?
Logged
aDFP
Level 0
***



View Profile
« Reply #9 on: September 10, 2017, 06:56:03 AM »

This is looking gorgeous, thanks for sharing your progress!
Logged
kinnas
Level 5
*****



View Profile WWW
« Reply #10 on: September 11, 2017, 08:09:04 AM »

Keep on truckin'! I'm excited to see progress on this
Logged

Romain Rope
Level 0
**


Game Audio SwissArmy Knife


View Profile WWW
« Reply #11 on: September 12, 2017, 03:31:35 AM »

Love the Akira-ish traffic light stream.
Logged

ROMAIN ROPE

Sound Designer / Composer
ROMAINROPE.COM
@RomainRope

Zombie Night Terror @ZN_Terror
Wanderer @Wanderer_Game
mflux
Level 0
*


View Profile
« Reply #12 on: April 25, 2018, 11:50:44 PM »

It's been what, seven months?

I've been in heavy duty game design mode trying to make the game interesting, dynamic, readable...

But certainly you were here for shiny gifs, correct?

Procedural Building Construction


Zone Highlight










On the game design front:

  • Corporate Contracts: Corporations will ask you to sign contracts to use your land and build in your city. Sewage processing, scrap yards, chemical plants, horrible stuff. Eventually the contracts will get better.
  • Moods: Zones can have moods like living in fear of crime, poverty, or simply drunk (due to depression?)
  • Land Value vs Density: Sort of basing this on Mazlow's pyramid of needs. Buildings upgrade in dual axis and it's possible to have high-rise slum towers.

Still game-designing this contract system as it can get pretty complex. Moods will have long lasting effect on the culture of your people.

Till next time!

Logged
nkm
Level 1
*


Ludere ergo sum


View Profile WWW
« Reply #13 on: April 26, 2018, 01:25:01 AM »

Looks really good!

The procedural building generation especially looks very inspiring. I've done some myself for my own game (Hypertrain), which generates buildings in low poly style. I might borrow some of your ideas if you don't mind.

Definately following this!
Logged

GPawley
Level 0
**


View Profile
« Reply #14 on: April 27, 2018, 08:21:44 AM »

You've nailed the visual style, well done!  I'll echo the chap above and say that it loses some of it's punch at the "early stages" of the city.  I suppose even cyberpunk cities start off from smallish towns, but it's a little bit inconsistent with the imagery everyone is used to.  Have you considered changing the typical arc of a city builder so that instead of going from nothing to a full blown city you're perhaps going from a crap rundown city to a shiny megacity?

Anyway, this looks like it's going to be fun.  When do you think you'll have a version you'll let people play?
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic