Anton Shestakov <engored@ya.ru>, Sun, 02 Mar 2014 18:00:14 +0900
Bots must know rules of current room (only rps3 at the moment).
src/rps_bots.erl
Permissions: -rw-r--r--
-import(rps3, [get_rules/0]). -export([fool/0, copycat/0, gambler/0]). Room ! {nickname, self(), "fool"}, Hand = lists:nth(random:uniform(length(get_rules())), get_rules()), Room ! {nickname, self(), "copycat"}, copycat(Room, hd(get_rules())) {winner, {NewHand, _}} -> Room ! {nickname, 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))