Anton Shestakov <engored@ya.ru>, Thu, 06 Mar 2014 19:38:46 +0900
Get win stats by nicknames, not pids.
src/rps_bots.erl
Permissions: -rw-r--r--
-export([fool/0, copycat/0, gambler/0]). rps_nickserv:nick(self(), "fool"), Hands = apply(Rules, get_hands, []), Hand = lists:nth(random:uniform(length(Hands)), Hands), rps_nickserv:nick(self(), "copycat"), copycat(Room, hd(apply(Rules, get_hands, []))) {winner, {NewHand, _}} -> rps_nickserv:nick(self(), "gambler"), Hands = apply(Rules, get_hands, []), Wins = dict:from_list([{Hand, 0} || Hand <- Hands]), F = fun({_, A}, {_, B}) -> A =< B end, {Hand, _} = hd(lists:sort(F, dict:to_list(Wins))), gambler(Room, dict:update_counter(Hand, 1, Wins))