game speed - how to maximize it

Game development with Board Game Arena Studio
User avatar
developgame
Posts: 107
Joined: 15 June 2020, 20:56

game speed - how to maximize it

Post by developgame »

Hello Everyone:
just another newbie question,
I am trying to create a realtime game. I hope to have the game speed or user actions processed by the game quick enough so it is possible for players to beat the game.

BGA server can often be very busy ,
I thought it would be fastest to do much processing on the client side and limit server side processing to moving through states and database access.

I have most of the necessary database game information stored in arrays in javascript
I am realizing that many javascripts array methods are very slow. for example findIndex

How would you maximize the game speed and minimize the amount of time spent on each user action .



thanks for any suggestions!
User avatar
tsaunat
Posts: 30
Joined: 28 April 2020, 05:10

Re: game speed - how to maximize it

Post by tsaunat »

Is it multiplayer? Do players interact? If so find a way to use websocket I would assume, but BGA might not be your best choice for that style game.

If it's limited interaction and you don't need to use the server to keep them (perfectly) synced so you are doing client processing. I'm certainly not an expert in optimization, but you should be able to get the data structure to a speed that should work great. Current clients are ridiculously speedy.
User avatar
tchobello
Posts: 693
Joined: 18 March 2012, 13:19

Re: game speed - how to maximize it

Post by tchobello »

BGA server in the Studio is not optimized...
you'll get better results in Production.
User avatar
robinzig
Posts: 459
Joined: 11 February 2021, 18:23

Re: game speed - how to maximize it

Post by robinzig »

developgame wrote: 14 July 2021, 23:45 I am realizing that many javascripts array methods are very slow. for example findIndex
I'm not easily able to say whether you're better off doing things on the client-side or not in this situation (although in general I'm a fan of not involving the server where it's not necessary) - but this sentence seems off to me. Modern JS implementations are pretty fast, and array methods like this shouldn't take any noticeable time until you get to arrays with tens of thousands of elements (maybe more). If you're experiencing noticeable delays in client-side code there's likely some performance issues with your code (eg doing something expensive in the function you're passing to findIndex), rather than it being the fault of the language itself!
Last edited by robinzig on 15 July 2021, 17:49, edited 2 times in total.
User avatar
robinzig
Posts: 459
Joined: 11 February 2021, 18:23

Re: game speed - how to maximize it

Post by robinzig »

tsaunat wrote: 15 July 2021, 07:40 Is it multiplayer? Do players interact? If so find a way to use websocket I would assume, but BGA might not be your best choice for that style game.
You certainly need websockets to do any kind of real-time interaction over the web - but BGA handles that already in the framework. I may be missing something but I don't see why developers on BGA would want to reinvent this themselves, and I certainly wouldn't be advising this!
User avatar
Victoria_La
Posts: 665
Joined: 28 December 2015, 20:55

Re: game speed - how to maximize it

Post by Victoria_La »

I agree with previous posts, here is my summary:
* BGA is not a real time framework, there would be never gurantee that players action will reach the server in certain time, in certain order or anything like this, so you cannot rely on this at all
* If game relies on "who acts first" like rcochet robots - it will always favor people with faster internet, unless you do some kind of complecated alanysis on imestamps from client (which is not reliable either)
* if you CAN do processing on client side - do it, it will save everybody time, unload the server, etc. But you cannot rely on that entirily - server have to validate all data assuming everything you get from the client can be manually entered
* if you see perfomance issues on client side - it not js, its your algorithms, unless you doing sophistcated AI mini-max optimizations problems - there is no way it can be noticible slow if its done right. Browser comes now days with lots of profiling tool - use it.
User avatar
Idsky
Posts: 132
Joined: 16 April 2020, 16:49

Re: game speed - how to maximize it

Post by Idsky »

I was just thinking about this. When doing this.ajaxcall(…), set lock:false, so that the client is not paused while the full round-trip server response takes place. This means the client can run at full speed with no delays. The client needs to check that all actions sent are valid so that hopefully they will all be accepted by the server.

It will get ahead of the server (which must still check all actions in case of cheaters or conflicts with other player actions). On the client, knowledge of what other players are doing will always be delayed, so it can get a bit complicated.
User avatar
tsaunat
Posts: 30
Joined: 28 April 2020, 05:10

Re: game speed - how to maximize it

Post by tsaunat »

robinzig wrote: 15 July 2021, 10:13
tsaunat wrote: 15 July 2021, 07:40 Is it multiplayer? Do players interact? If so find a way to use websocket I would assume, but BGA might not be your best choice for that style game.
You certainly need websockets to do any kind of real-time interaction over the web - but BGA handles that already in the framework. I may be missing something but I don't see why developers on BGA would want to reinvent this themselves, and I certainly wouldn't be advising this!
my point I was suggesting was finding a way to tap into BGA's websocket as far as I know we don't necessarily have direct access to it, also BGA uses it to pass notification traffic to the client, but this is not the way moves are summited to the server which would not result in realtime network layer . I was not suggesting the developer should try to implement their own web socket on BGA. If realtime traffic is actually needed (due to player direct interaction) I was suggesting BGA might not be the place for that. Websockets are not particularly difficult, but don't try to implement your own websocket on BGA --it's not going to work.
User avatar
robinzig
Posts: 459
Joined: 11 February 2021, 18:23

Re: game speed - how to maximize it

Post by robinzig »

tsaunat wrote: 16 July 2021, 05:03
robinzig wrote: 15 July 2021, 10:13
tsaunat wrote: 15 July 2021, 07:40 Is it multiplayer? Do players interact? If so find a way to use websocket I would assume, but BGA might not be your best choice for that style game.
You certainly need websockets to do any kind of real-time interaction over the web - but BGA handles that already in the framework. I may be missing something but I don't see why developers on BGA would want to reinvent this themselves, and I certainly wouldn't be advising this!
my point I was suggesting was finding a way to tap into BGA's websocket as far as I know we don't necessarily have direct access to it, also BGA uses it to pass notification traffic to the client, but this is not the way moves are summited to the server which would not result in realtime network layer . I was not suggesting the developer should try to implement their own web socket on BGA. If realtime traffic is actually needed (due to player direct interaction) I was suggesting BGA might not be the place for that. Websockets are not particularly difficult, but don't try to implement your own websocket on BGA --it's not going to work.
Thanks for clarifying. I did say "I may be missing something" and it seems indeed I was (about your intended meaning) - but I probably wasn't the only one so it's all good that you've come back and explained what you actually meant. Which sounds sensible :)

(It's interesting what you say - which I've noticed too but not thought too much about before - that BGA only appears to use websockets for transmitting notifications from the server to players/spectators, and not for the actual game moves on the client, which use standard HTTP/Ajax. I'm not sure why this is, but also completely ignorant of what the effects on performance might be. I'm sure it's something the BGA developers must have thought about however!)
User avatar
developgame
Posts: 107
Joined: 15 June 2020, 20:56

Re: game speed - how to maximize it

Post by developgame »

tsaunat wrote: 15 July 2021, 07:40 Is it multiplayer? Do players interact? If so find a way to use websocket I would assume, but BGA might not be your best choice for that style game.

If it's limited interaction and you don't need to use the server to keep them (perfectly) synced so you are doing client processing. I'm certainly not an expert in optimization, but you should be able to get the data structure to a speed that should work great. Current clients are ridiculously speedy.
Thanks robinzig for your advices. I do not know about websockets, but I will learn more.
The games is cooperative dice chucking game where I do not need the servr to keep them perfectly syn. It is a game where all the players must accomplish some feats in 10 minutes to beat the game
Post Reply

Return to “Developers”