GithubHelp home page GithubHelp logo

uriopass / egregoria Goto Github PK

View Code? Open in Web Editor NEW
1.4K 23.0 47.0 10.83 MB

3D City Builder without a grid

Home Page: http://douady.paris/blog/

License: GNU General Public License v3.0

Rust 95.42% Shell 0.01% WGSL 3.50% Lua 1.06%
society simulation rust-lang emergent-behavior gamedev wgpu 3d city-builder game rust

egregoria's People

Contributors

oberien avatar pracplayopen avatar salzian avatar shika-blyat avatar sirpalee avatar skairunner avatar uriopass avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

egregoria's Issues

Cannot move the camera

Neither moving the mouse to the screen edges nor arrow keys worked. Restarting the game solved the issue. One thing I noticed was that the screen pivot point was located at 0,0.

Add building interior

Buildings need to have an interior with different rooms and furnitures. The pedestrians need to be able to move in it.

Introduction guide

Some kind of introduction guide that helps a new player to create a small city like in the youtube demo.

Can be hosted on github's wiki and linked somewhere at the start.

Gridlocks

Currently, cars can get stuck in a 3-way (or more) gridlock since the priority system only looks at couples.
So if cars A, B and C each want to let another car go in cycle, a gridlock happens.

This is a very hard problem though, since some global authority (intersection based ? Cluster based ?) Need to be put in place (or maybe not, see comment).

Wondering how to contribute?

Hi, I was toying with the idea of making a traffic simulator in Rust, and I was trawling the web trying to figure out which graphics library or game engine to use (Amethyst, ggez, gfx, wgpu, vulkano, glium, gd, the list goes on and on), or whether I should be using 2D or 3D, and I found Egregoria, which seems to have things in common with what I wanted to make.

I'm wondering how best to talk to you or other people working on this about what's going on?

Water shader

Water is currently represented by just blue terrain, nice water can give a cool vibe.

Unify cars and pedestrians (single human controlling both)

At the moment, pedestrian entities and car entities are very different, and a pedestrian cannot "hop into" a parked car.

Parked car just randomly unpark and start to drive around.

Ideally, there would be some way of seeing the interior of a car but maybe not for now.

See building state

Inspect different informations about a building.

Steps:

  • Allow buildings to be selected, can be queried from the Map::query function.
  • Display various info in an egui panel for the buildings (such as information from the BuildingInfos resource), their recipe for a GoodsCompany...

Add roofs

Buildings roofs are a bit weird right now being all gray. Maybe keep the gray roofs for the supermarkets/companies (with an outline) but make actual "3D" roofs for the buildings.
I've tried coding the straight skeleton algorithm in Rust but I gave up. Might try again some day.

Dynamic link wgpu_engine for dev

Bevy did it, there's probably a way to do it too, could speed up iterative compile time quite a bit. Would be cool to dynamic link winit there too.

Move wgpu engine to its own crate

So that when modifying the game logic, the rendering doesn't get recompiled.

Currently blocked by: Color/LinearColor in egregoria::rendering and
KeyCode/KeyboardInfo/MouseButton/MouseInfo

Audio support

Sounds and music greatly improve immersion. There needs to be a sound layer someday.
Rodio is good and compatible with winit now. There's also 2 musics ready for release in resources/music{1,2}.ogg

Cargo run crashes on macOS / M1

Just calling cargo run using the latest stable rust compiler crashes on macOS / M1 MacBook.

Environment:

  • OS: macOS Monterey 12.4
  • Rust version: rustc 1.61.0 (fe5b13d68 2022-05-18)
  • Hardware: MacBookPro18,2 / Apple M1 Max

Stacktrace:

❯ cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.13s
     Running `target/debug/native_app`
[    76790 INFO  instance    ] Adapter Metal AdapterInfo { name: "Apple M1 Max", vendor: 0, device: 0, device_type: DiscreteGpu, backend: Metal }
[    76991 ERROR /Users/sirpalee/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.12.0/src/backend/direct.rs:828] Error in Adapter::request_device: unsupported features were requested: SPIRV_SHADER_PASSTHROUGH
thread 'main' panicked at 'could not find device, have you installed necessary vulkan libraries?: RequestDeviceError': /Users/sirpalee/projects/Egregoria/wgpu_engine/src/gfx.rs:163
   0: backtrace::backtrace::libunwind::trace
             at /Users/sirpalee/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.65/src/backtrace/libunwind.rs:93:5
      backtrace::backtrace::trace_unsynchronized
             at /Users/sirpalee/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.65/src/backtrace/mod.rs:66:5
      backtrace::backtrace::trace
             at /Users/sirpalee/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.65/src/backtrace/mod.rs:53:14
      backtrace::capture::Backtrace::create
             at /Users/sirpalee/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.65/src/capture.rs:176:9
   1: backtrace::capture::Backtrace::new
             at /Users/sirpalee/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.65/src/capture.rs:140:22
   2: log_panics::init::{{closure}}
             at /Users/sirpalee/.cargo/registry/src/github.com-1ecc6299db9ec823/log-panics-2.0.0/src/lib.rs:52:25
   3: std::panicking::rust_panic_with_hook
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:702:17
   4: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:588:13
   5: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:138:18
   6: rust_begin_unwind
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:584:5
   7: core::panicking::panic_fmt
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/panicking.rs:143:14
   8: core::result::unwrap_failed
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/result.rs:1785:5
   9: core::result::Result<T,E>::expect
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/result.rs:1035:23
  10: wgpu_engine::gfx::GfxContext::new::{{closure}}
             at wgpu_engine/src/gfx.rs:152:31
  11: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/future/mod.rs:91:19
  12: futures_executor::local_pool::block_on::{{closure}}
             at /Users/sirpalee/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-executor-0.3.21/src/local_pool.rs:315:23
  13: futures_executor::local_pool::run_executor::{{closure}}
             at /Users/sirpalee/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-executor-0.3.21/src/local_pool.rs:90:37
  14: std::thread::local::LocalKey<T>::try_with
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/thread/local.rs:442:16
  15: std::thread::local::LocalKey<T>::with
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/thread/local.rs:418:9
  16: futures_executor::local_pool::run_executor
             at /Users/sirpalee/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-executor-0.3.21/src/local_pool.rs:86:5
  17: futures_executor::local_pool::block_on
             at /Users/sirpalee/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-executor-0.3.21/src/local_pool.rs:315:5
  18: native_app::context::Context::new
             at native_app/src/context.rs:58:19
  19: native_app::main
             at native_app/src/main.rs:27:19
  20: core::ops::function::FnOnce::call_once
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/ops/function.rs:227:5
  21: std::sys_common::backtrace::__rust_begin_short_backtrace
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:122:18
  22: std::rt::lang_start::{{closure}}
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/rt.rs:145:18
  23: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/ops/function.rs:259:13
      std::panicking::try::do_call
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:492:40
      std::panicking::try
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:456:19
      std::panic::catch_unwind
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panic.rs:137:14
      std::rt::lang_start_internal::{{closure}}
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/rt.rs:128:48
      std::panicking::try::do_call
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:492:40
      std::panicking::try
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:456:19
      std::panic::catch_unwind
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panic.rs:137:14
      std::rt::lang_start_internal
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/rt.rs:128:20
  24: std::rt::lang_start
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/rt.rs:144:17
  25: _main

Need help on anything?

@Uriopass Hi, I started using Rust a few months ago and I'm looking for an interesting project like yours to work on.

I'm really interested in human society simulations so if you need help with anything right now, I would be pleased to help.

Social network

There should exist a social network between people, which fluctuates over time. The relations between people should be taken into account when planning activities together.

Entertainment

Allow people to entertain themselves through external activities such as cinema, sport, parks, etc.

Trains and subway systems

Freight/passenger trains are undoubtedly cool looking and fun to play with. Although it might take a bit of time to implement, my experience with the road system should make it easier to build, at least for the tracks.

Also, subway make a city faster and could solve some traffic issues.

Reduce instances size

When 100k cars are in, heap exceded errors are thrown.

Currently, instances are matrix fours, whereas they should hold in vec4 (position + rotation)

Cascaded Shadow Maps

Shouldn't be that complicated, but still needs to be done. Current single shadow map is just a bit sad.

Transition to Legion ECS

Legion looks like it has all the features I want and a very nice API:

  • Systems using proc macro makes for one line changes and easy par_iter
  • Any 'static + Send + Sync struct is a component
  • Archetypes
  • Parallel and batched queries
  • UUID for Entity Ids (easy serialization!)

I haven't see integrated event management like in bevy (Deleted, Modified)
but I've seen something like maybe_changed. Need to dig deeper.

Check for cars when unparking

At the moment, when a car is unparking they just do so without checking if there's anything in the way.

Since they just follow a predefined trajectory, they end up colliding.
One could use the collision world to check that no car is nearby before unparking.

Add workplaces

Add workplaces, which means a building generator and some sort of company model.

Basic economy

From Wikipedia:

An economy is an area of the production, distribution and trade, as well as consumption of goods and services by different agents.

For the first try at economy in this project, I plan to center it about food.

I'll have as economic agents:

  • People
  • Supermarkets
  • Companies
  • Farms (?)

The food will magically appears in supermarkets, though it would be better if it came from somewhere like farms.

It will be distributed in supermarkets, and consumed by people. Money would be a good way to monitor what interactions happen and what needs balance.

People will earn money by working in companies, though those companies won't do anything interesting yet.

Might update this issue when I develop this idea further (feel free to comment with your thoughts if you're reading this though).

UI scale is too small

On a 4k monitor it's almost unreadable. On a FHD monitor it's still uncomfortably small.

Ideally a setting for UI scale would be nice, but a larger hardcoded/default value would already help a lot.

Lot generation

Making buildings is cool, but where do we put them ?

There are many approaches to partition space for construction terrain.

  1. Partition like Cities:Skylines, where the side of the roads are cut into rectangular pieces which are then used by predefined homes that occupies a certain amount of rectangles.
    image

  2. Partition the way buildings are made in Paris, where faces from the road graph are detected and extruded to form little quads or triangles which represents the buildings. No pathway needed since they are all directly on the road.

image
image

  1. Just place houses randomly and check if they don't intersect anything, which is the current approach but is not very satisfying.

  2. A mix of 1 and 2
    1 for suburbs and 2 for city center

5?) ??
I probably want to go with option 1 for Egregoria 0.2 since I got a reference (Cities Skylines) and the region where buildings are placed are rectangular which is easier to manage for buildin+pathway generation than an arbitrary convex polygon

To check out: some discussions on zoning
https://forum.paradoxplaza.com/forum/threads/my-proposal-for-a-better-zoning-system-less-gaps-bigger-plot-sizes-intuitive-usage.883848/

Weather

Rain, drought, seasons, all that. Could make some interesting economic patterns.

Day/Night cycle

Time is important, and one of the easy way to show time passing is having a day/night cycle.

What I'm thinking for a basic one is to have a post-processing shader taking a list of light sprites to multiply with the actual screen color.

image

Would look something like this.

I also need to upgrade the TimeInfo struct (rename it to GameTime probably) and add useful helpers like time-of-day, date, seconds_until etc.

Cycling

Introduce a bicycle shop and allow people to cycle to work or anywhere. I'm not entirely sure where they would park their bike though, maybe bike parkings could be alongside most roads ?

Add homes and ownership model

Once the house generator is done, and cars are unified, there needs to be some central place to associate civilian with the things it own, such as his house, cars, money .. ?

Add wildlife

Birds, cows, dolphins, whatever. Should make things more alive.

Add trees

Trees would give a lot more depth to the world but it is surprisingly complicated to make trees pretty from above.
Here's some failed attempts and references to try and think about it:

If you have an idea and want to talk about it, join the discord !

Failed attempts:

image
image

Ideas:

image
image
image
image

Car AI tests

When trying to enhance the car AI, I wish there was some sort of automated "car scenarios" test where I could check if
a) No collisions happened
b) No gridlocks happened
c) How fast they went to their objective

For example, two cars in front of each other wanting to go forward, this is tough and cannot be resolved at the moment but maybe someday they could both chose to go right to avoid each other.

Another example is two cars going perpendicular to each other, where one must stop to let the other pass, this works at the moment but if I had an automated test to prove it it would be great.

Add background

The current black/grid background is getting a bit old, maybe adding some green background with trees and lakes would make everything more coherent.

Update to wgpu 0.6

There were some breaking API changes. Need to check where it crashes or doesn't compile and fix it.

Wasm support

Eventually, I want to have an Egregoria client running on wasm, however this is currently blocked on:

  • wgpu 0.6 which should go out soon enough
  • audio which is just not working in wasm right now I think. There isnt even a audio backend in Egregoria anyway though that would be good since there's already some music.

External trading

Instead of an island, the world should be situated on a beach or something open so that the city can engage with exterior trading.

That way, a small city can still get access to goods they can't have without a lot of work like electronics, cars or petrol.

Like in cities skylines, I can imagine a sort of highway coming from infinity that has allows connection to the global market.

Add ability to drive arbitrary car

This has to be done in three steps

  • Split Car AI into AICarController and CarPhysics components and just iterate over both in vehicles/systems.rs
  • Add DriverController component which uses keyboard inputs to drive a car and move the camera accordingly (FollowEntity component)
  • Add some gui to control a car, either a tool in the toolbox or a button when a car is selected, and some gui to de-control the car, typically the escape key

First person camera

Add a first-person camera selectable in the settings.
Should not allow collision with the ground and have a speed dependent on the height of the camera.

Optimize map drawing

Currently, drawing the map is incredibly expensive, recalcuating the noise function for every pixel every frame. On mid-tier hardware this is a lot of wasted power.
Some lazy chunk based texture generation with lod would be much better.

Better Economy UI

The economy UI could probably be a bit more interesting. Currently only showing offer/demand is a bit shallow. Even some ideas about this would be cool.

Education

People have an education level and might go to school, college, universities or others to educate themselves.

Better house generation

Current house generation based on skeleton algorithm is incredibly flaky, probably something better could be done. Rather self-contained, good first issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.