https://github.com/suddi/portal
Portal game in elixir, based on https://howistart.org/posts/elixir/1
https://github.com/suddi/portal
distributed-computing elixir portal-game
Last synced: 18 days ago
JSON representation
Portal game in elixir, based on https://howistart.org/posts/elixir/1
- Host: GitHub
- URL: https://github.com/suddi/portal
- Owner: suddi
- License: mit
- Created: 2017-01-16T10:22:14.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-18T17:22:44.000Z (over 9 years ago)
- Last Synced: 2025-01-11T19:12:37.450Z (over 1 year ago)
- Topics: distributed-computing, elixir, portal-game
- Language: Elixir
- Size: 5.86 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Portal
Portal game in Elixir following the guide in [How I Start.](https://howistart.org/posts/elixir/1).
## Usage
To open an Elixir process to communicate through:
````sh
iex --sname room1 --cookie secret -S mix
````
A second process:
````sh
iex --sname room2 --cookie secret -S mix
````
In `room1`:
````elixir
iex(room1@zenith)1> Portal.shoot(:blue)
{:ok, #PID<0.118.0>}
````
In `room2`:
````elixir
iex(room2@zenith)1> Portal.Door.get({:blue, :"room1@zenith"})
[]
iex(room2@zenith)2> Portal.shoot(:orange)
{:ok, #PID<0.124.0>}
iex(room2@zenith)3> orange = {:orange, :"room2@zenith"}
{:orange, :room2@zenith}
iex(room2@zenith)4> blue = {:blue, :"room1@zenith"}
{:blue, :room1@zenith}
iex(room2@zenith)5> portal = Portal.transfer(orange, blue, [1, 2, 3, 4])
#Portal<
{:orange, :room2@zenith} <=> {:blue, :room1@zenith}
[1, 2, 3, 4] <=> []
>
iex(room2@zenith)6> Portal.push_right(portal)
#Portal<
{:orange, :room2@zenith} <=> {:blue, :room1@zenith}
[1, 2, 3] <=> [4]
>
````
In `room1`:
````elixir
iex(room1@zenith)2> orange = {:orange, :"room2@zenith"}
{:orange, :room2@zenith}
iex(room1@zenith)3> blue = {:blue, :"room1@zenith"}
{:blue, :room1@zenith}
iex(room1@zenith)4> Portal.Door.get(orange)
[3, 2, 1]
iex(room1@zenith)5> Portal.Door.get(blue)
[4]
````