Download:
child 4:c9defefe5dd9
parent 2:ecb57261bc30
3:8bbf038c39cc
Anton Shestakov <engored@ya.ru>, Sun, 23 Feb 2014 00:23:54 +0900
Define bots.

1 файлов изменено, 3 вставок(+), 2 удалений(-) [+]
rps.erl file | annotate | diff | comparison | revisions
--- a/rps.erl Sun Feb 23 00:19:13 2014 +0900
+++ b/rps.erl Sun Feb 23 00:23:54 2014 +0900
@@ -2,6 +2,7 @@
-export([lobby/0, room/1, beats/1, winner/1, go/0, fool/0]).
-define(RULES, [rock, paper, scissors]).
+-define(BOTS, [fool, fool, fool]).
beats(C) ->
beats(C, ?RULES).
@@ -39,12 +40,12 @@
go() ->
register(lobby, spawn(rps, lobby, [])),
- [spawn(rps, fool, []) || _ <- lists:seq(1, 3)].
+ [spawn(rps, Bot, []) || Bot <- ?BOTS].
lobby() ->
lobby([]).
-lobby(Players) when length(Players) =:= 3 ->
+lobby(Players) when length(Players) =:= length(?BOTS) ->
Room = spawn(rps, room, [Players]),
lists:foreach(fun(Player) -> Player ! {room, Room} end, Players),
lobby([]);