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

chokchit
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2733ms. You can configure how long re...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
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
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: The documentation above suggests that while ...
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

Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
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
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
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

We're in Beta

About us Mission Statement