Re: game speed - how to maximize it
Posted: 19 July 2021, 18:12
Thanks robinzig for checking my code. I was also using the more expensive findIndex rather than indexof.robinzig wrote: ↑15 July 2021, 10:10I'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!developgame wrote: ↑14 July 2021, 23:45 I am realizing that many javascripts array methods are very slow. for example findIndex
Thanks Victoria_La for summarizing what has been posted, and for sharing your knowledge about programming on BGA. Your summary is very helpful and I will refer to it often.Victoria_La wrote: ↑15 July 2021, 14:32 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.
Thanks Idsky for your thoughts on how to develop real time games so they work on BGA. I will try setting lock to falseIdsky wrote: ↑15 July 2021, 23:05 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.