Jump to content

Client or server side simulating?

Hello people!

 

I have a little question regarding economy/city building simulators. So in a game such as Cities Skylines, the city is real-time simulated by the computer. All the data that is being simulated is written to a save file, when the game is saved.

 

Now, imagine one would make an in-browser, multi-player economy simulator. So basically, you run the nation from an in browser interface. Different people make accounts, and trade with each other. That way, you basically get a multi-player economy simulator.

 

Now I have some questions on how to go about and do this.

 

- I can't use Javascript to simulate the economy, because you can easily cheat via inspect element. Basically, client side simulating seems like a bad idea.

- If I would simulate all economies on the back-end (server-side), that would mean, depending on the amount and size of economies, I need huge servers to do the simulations.

 

- I can, to some extent, decrease the amount of things that have to be simulated in real-time. Just a little example:

 

Bad idea:

An entity has to pay a loan. The server updates the database every second, telling how much money is paid, and and how much money is left to pay, and due to which date.

Obviously updating a huge database every second with data is a terrible idea.

 

Good idea:

The database tells how much money has to be paid in total, due to which date, how much money per time unit is being paid, ... When information about the loan is needed, the amount of money already paid will be calculated when request using the current date, and the information in the database.

 

 

So, I hope you understand my thought process. I'm not struggling with the programming aspect, just with the architecture, which is a pretty important thing.

This is my first serious project, I don't expect it to be easy, or have a good end result. But I'm just making this because I want to try.

 

Any ideas, help or suggestions on how to limit the amount of simulating done by the server, or how the do safe client side simulating. Or just help on the architecture would be nice.

 

Thanks in advance!

(If I'm not clear on what I'm asking, please tell me)

Link to comment
Share on other sites

Link to post
Share on other sites

You can't trust the client side, any verification you do there must be redone on the server. In addition the server should do all the simulating. Typically in games what happens is the client also has to apply client side latency hiding techniques such that grenades and bullets appear to leave the moment you press the button and not when the server actually agrees it happens which is quite a few frames later, but I don't think you have this particular problem.

 

You may be underestimating just how much simulation a modern CPU can do. You will no doubt be familiar with game shards or instances as its in all games and while for real time we typically see 16-64 players for lower update games like MMORPG's a shard is going to typically be just a few servers including a database server and the application server and they can potentially support thousands of players.

 

One of the few companies that puts everyone into the same world is Eve, and it has a economic simulation built into it. Thankfully in the past Eve's developers have spoken at length about their development including stackless python and how they shard worlds across servers. There might be architectural principles in that which may help you decide roughly how to approach the problem for scaling to 10's of thousands of players.

Link to comment
Share on other sites

Link to post
Share on other sites

You can move some calculations to the front end, just like in your example. However, there can be only data visualisation of sorts, and not data manipulation. You will still need to have pretty beefy servers that would handle the economy.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×