Here is the puzzle whose solution I am trying to simulate. It is a very famous puzzle. If you like puzzles, you should definitely try to solve it.
Anyhow, the program I write should do the following:
Create the required number of prisoners. (Each prisoner will have a role, either an ordinary prisoner, or the leader. In advanced versions of the solution, there will be other roles, but that is for later.)
Assign prisoner #1 as leader.
And the rest as per the “basic” solution.
The original puzzle has 100 prisoners, but let us start with 10. So we need 10 prisoners and a light bulb. Each of these entities is mutable. (Each prisoner will have an internal knowledge about whether he visited the bulb room or not. In advanced versions, prisoners will/may change roles.)
If I were to code this simulation the Elixir way, I would need to assign a process for the light bulb and each prisoner?
How do I automate “creating” prisoners, each with a process? (When there are 100 of them, one cannot do it by hand.)
What exactly is the difference between the concept of genserver and actors? Once a prisoner assigned a process, does he become an actor?
Thank you for any help.