Anton Shestakov <engored@ya.ru>, Mon, 03 Mar 2014 20:00:26 +0900
Move parse_rules and winning_hand to rps_rules.
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))