Anton Shestakov <engored@ya.ru>, Mon, 03 Mar 2014 15:09:55 +0900
Make rps_nickserv a gen_server.
src/rps_bots.erl
Permissions: -rw-r--r--
-import(rps3, [get_rules/0]). -export([fool/0, copycat/0, gambler/0]). rps_nickserv:nick(self(), "fool"), Hand = lists:nth(random:uniform(length(get_rules())), get_rules()), rps_nickserv:nick(self(), "copycat"), copycat(Room, hd(get_rules())) {winner, {NewHand, _}} -> rps_nickserv:nick(self(), "gambler"), Wins = dict:from_list([{C, 0} || C <- get_rules()]), F = fun({_, A}, {_, B}) -> A =< B end, {Hand, _} = hd(lists:sort(F, dict:to_list(Wins))), gambler(Room, dict:update_counter(Hand, 1, Wins))