--- a/src/rps_bots.erl Sun Mar 02 17:39:33 2014 +0900
+++ b/src/rps_bots.erl Sun Mar 02 17:58:19 2014 +0900
+ Room ! {nickname, self(), "fool"},
+ Room ! {nickname, self(), "copycat"},
copycat(Room, hd(get_rules()))
+ Room ! {nickname, self(), "gambler"},
Wins = dict:from_list([{C, 0} || C <- get_rules()]),
--- a/src/rps_room.erl Sun Mar 02 17:39:33 2014 +0900
+++ b/src/rps_room.erl Sun Mar 02 17:58:19 2014 +0900
-import(rps3, [get_rules/0, winning_hand/1]).
--record(state, {players=[], choices=[]}).
+-record(state, {players=[], choices=[], nicknames=dict:new()}).
% winner for 3 players is:
% rock, rock, rock -> undefined
lists:foreach(fun(Player) -> Player ! Msg end, Players),
-room(State=#state{choices=Choices}) ->
+room(State=#state{choices=Choices, nicknames=Nicknames}) ->
+ {nickname, Who, Nickname} ->
+ room(State#state{nicknames=dict:store(Who, Nickname, Nicknames)});
ObjectIsOk = lists:any(fun(X) -> X =:= Hand end, get_rules()),
ChoiceMade = lists:keymember(Who, 2, Choices),