AlecHsueh
I’m learning Elixir by myself for fun now. I have basic Python knowledge before. I think the best way to learn a new programming language is to do some real projects. I’m try to create a web based poker game. The basic unit of the game is the table. Different tables have different game rules. e.g. Texas Hold’em table, Omaha table. etc. But as a functional programming language, Elixir has no class no object no inheritance. My question is how to implement a structure that can associate with different game rules?
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Hello,
I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter).
The diffic...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
I think I’ve found a small improvement I could contribute to <%= web_namespace %>.CoreComponents (installer/templates/phx_web/compo...
New
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
ICal is a library for interacting with iCalendar data. It parses iCalendars into typed Elixir structs via ICal.from_ics, and can prepare ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #phoenix_html
- #elixirconf-us
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 6- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
kelvinst
Just use different modules for different games. Maybe also create a basic module with
@callbacks and use it as a@behaviouron the implementation modules, to define a common interface for them, and ensure they have the functions the base game module calls.younes-alouani
I think that you could dive straight into a project if Elixir was Object-Oriented (Python). The patterns used to design a game using functional programming are different. In my opinion start by studying the basics of Elixir (Syntax + Project organisation using Mix).
Reading this documentation will be a good starting point.
Good luck.
kokolegorille
If You like Poker with Elixir, there is an old post about it here https://tokafish.com/playing-poker-with-elixir-part-1/ You might need to adapt for newer version, but the post is nice.
Other games I often saw, Tic Tac Toe, Tetris…
I wrote a little game engine for go here elixir_go | Hex
For a more complete example, there is this video
Eiji
@AlecHsueh: I don’t exactly know about rules that you need to implement, but here is my idea:
Firstly declare your configuration with some raw data that you will process in game:
Secondly create a
GenServer-based module:Finally for each table you need to start a new server like:
and call your server public API like:
Note: You can also use DynamicSupervisor for your table server processes.
axelson
I would take care not to link the game implementation (e.g.
:card_played) to a GenServer. You can implement all of the logic with pure modules and functions.To Spawn, or not to Spawn? by Saša Jurić gives a good overview about when and how to reach for processes and even talks about an implementation of a card game to boot (Blackjack).
Eiji
This comment:
does not mean that you need to write login directly in this place.
I believe that this is easiest example for board games (as far as I remember table in each game have only one event like card played) at same time + time for players in their rounds to think about next move.