artvinn

artvinn

Elixir for game server with simple physics calculations

Hi guys! I’ve been thinking about making a multiplayer(I think 50-150 concurrent players per server) web game as a side project, similar to currently popular .io games. Initially I wanted to do it with Node.js due to my experience with it and ecosystem maturity, but now thinking to implement it in Elixir, as I’ve been learning it for some time and haven’t used for any serious project. The server will need to handle calculations like players bounding, velocity, acceleration and simple gravity. I’ve read that elixir is not very good for high CPU computations and I couldn’t find any physics libraries. Would it be too much to calculate all this in elixir? Or it would be a better idea to do it through NIFs or it is very slow?

Thanks in advance :slight_smile:

Most Liked

idi527

idi527

The server will need to handle calculations like players bounding, velocity, acceleration and simple gravity.

I think elixir/erlang would be able to calculate that. But something more involved would require using a NIF probably.

I would model each player as a process (maybe a gen_statem) that would keep all information about itself (its position, current velocity and acceleration, life-cycle status). Gravity could probably be expressed as some callback functions acting on these processes’ states called after each process action.

I think it’ll mostly be simple arithmetics, so erlang should do fine.

btw, I think the miniclips’ ios app for agar.io used erlang on the backend, but c++ for the original browser version. Don’t remember how I learned this, but after a little bit of googling I found these “proofs”:

easco

easco

Not to put too fine a point on it, but I recommend that you try it in Elixir, run some timing tests, then optimize with a NIF if you find performance lags.

Qqwy

Qqwy

TypeCheck Core Team

Indeed, @easco has the right idea.

when you find out that you need NIFs, Rustler nowadays works really well and makes it very clear what is going on.

Where Next?

Popular in Questions Top

lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
nobody
How to bind a phoenix app to a specific ip address? could not find anything about that, nowhere, unfortunately, but for me this is quite...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

Other popular topics Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

We're in Beta

About us Mission Statement