--- a/rps.erl Sun Feb 23 00:29:31 2014 +0900
+++ b/rps.erl Sun Feb 23 15:02:21 2014 +0900
--export([lobby/0, room/1, beats/1, winner/1, go/0, fool/0]).
+-export([lobby/0, counter/2, printer/0, room/1, beats/1, winner/1, go/0, fool/0]).
-define(RULES, [rock, paper, scissors]).
-define(BOTS, [fool, fool, fool]).
register(lobby, spawn(rps, lobby, [])),
+ register(counter, spawn(rps, counter, [[], []])),
+ register(printer, spawn(rps, printer, [])),
[spawn(rps, Bot, []) || Bot <- ?BOTS].
+ %io:format("draw: ~w.~n", [Choices]),
+ counter([Choices|Draws], Wins);
+ %io:format("the winner is ~w.~n", [Winner]),
+ counter(Draws, [Winner|Wins]);
+ Pid ! {stats, {draws, length(Draws), wins, length(Wins)}},
+ io:format("Stats: ~w.~n", [Stats])
+ counter ! {sendstats, self()}
lists:foreach(fun(Player) -> Player ! start end, Players),
Winner = winner(Choices),
- io:format("draw: ~w.~n", [Choices]),
- io:format("the winner is ~w.~n", [Winner]),
lists:foreach(fun(Player) -> Player ! Msg end, Players),