Download:
child 29:0f29304f36f4
parent 27:19ca2615be8f
28:44aa20fdf779
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).

2 файлов изменено, 4 вставок(+), 4 удалений(-) [+]
src/rps_bots.erl file | annotate | diff | comparison | revisions
src/rps_room.erl file | annotate | diff | comparison | revisions
--- a/src/rps_bots.erl Sun Mar 02 17:58:19 2014 +0900
+++ b/src/rps_bots.erl Sun Mar 02 18:00:14 2014 +0900
@@ -16,7 +16,7 @@
fool(Room) ->
receive
- start ->
+ {start, _Rules} ->
Hand = lists:nth(random:uniform(length(get_rules())), get_rules()),
Room ! {Hand, self()},
fool(Room);
@@ -37,7 +37,7 @@
copycat(Room, Hand) ->
receive
- start ->
+ {start, _Rules} ->
Room ! {Hand, self()},
copycat(Room, Hand);
{winner, {NewHand, _}} ->
@@ -58,7 +58,7 @@
gambler(Room, Wins) ->
receive
- start ->
+ {start, _Rules} ->
F = fun({_, A}, {_, B}) -> A =< B end,
{Hand, _} = hd(lists:sort(F, dict:to_list(Wins))),
Room ! {Hand, self()},
--- a/src/rps_room.erl Sun Mar 02 17:58:19 2014 +0900
+++ b/src/rps_room.erl Sun Mar 02 18:00:14 2014 +0900
@@ -26,7 +26,7 @@
end.
room(Players) when is_list(Players) ->
- lists:foreach(fun(Player) -> Player ! start end, Players),
+ lists:foreach(fun(Player) -> Player ! {start, rps3} end, Players),
room(#state{players=Players});
room(#state{players=Players, choices=Choices}) when length(Players) =:= length(Choices) ->