removed output
This commit is contained in:
parent
0c340f95d2
commit
5620b67c34
9 changed files with 138 additions and 30 deletions
|
@ -1 +1 @@
|
|||
Subproject commit 00312859714bef6e9a4fdb9931a41fef56eeb89a
|
||||
Subproject commit 030e0ecafff27fff8e6918add47dfcdeec363e7c
|
|
@ -17,8 +17,8 @@ class PongBot
|
|||
@send_start = false
|
||||
|
||||
@ggs_network = GGSNetwork.new(self)
|
||||
#@ggs_network.connect("10.42.43.1")
|
||||
@ggs_network.connect()
|
||||
@ggs_network.connect("192.168.0.1")
|
||||
#@ggs_network.connect()
|
||||
end
|
||||
|
||||
def ggsNetworkReady(ggs_network, ready)
|
||||
|
|
|
@ -123,7 +123,7 @@ handle_call({join_table, Table}, From, State) ->
|
|||
% PN when (PN >= 2) -> {reply, {error, table_full}, State} % TODO: Fix this limit!!
|
||||
% end;
|
||||
{TableNum,_} = string:to_integer(Table),
|
||||
erlang:display(State#co_state.players),
|
||||
%erlang:display(State#co_state.players),
|
||||
CurrentPlayers = length(State#co_state.players),
|
||||
SmallestTable = case (CurrentPlayers rem 2) of
|
||||
0 -> CurrentPlayers / 2;
|
||||
|
@ -156,7 +156,7 @@ handle_call(get_all_players, _From, State) ->
|
|||
%% Conversion tools
|
||||
handle_call({table_token_to_pid, Token}, _From, State) ->
|
||||
Tables = State#co_state.tables,
|
||||
erlang:display("Pre-keyfind"),
|
||||
%erlang:display("Pre-keyfind"),
|
||||
{_, Pid} = lists:keyfind(Token, 1, Tables),
|
||||
{reply, Pid, State};
|
||||
|
||||
|
|
64
src/ggs_dispatcher_backup.erl
Normal file
64
src/ggs_dispatcher_backup.erl
Normal file
|
@ -0,0 +1,64 @@
|
|||
-module(ggs_dispatcher_backup).
|
||||
|
||||
-behaviour(gen_server).
|
||||
|
||||
%% API Exports
|
||||
-export([start_link/0, stop/1]).
|
||||
-export([back_up/1, retrieve/0]).
|
||||
|
||||
%% gen_server callback exports
|
||||
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2,
|
||||
code_change/3]).
|
||||
|
||||
-define(SERVER, ?MODULE).
|
||||
%% @doc This module is responsible for keeping a backup of the coodinator
|
||||
%% at all times. At any point in time a backup can be restored from this
|
||||
%% module.
|
||||
%% This module is started by the root supervisor, and is restarted when it
|
||||
%% crashes. Upon a crash, the backup state is lost in this module, and must
|
||||
%% be filled in from the ggs_coordinator.
|
||||
|
||||
%% @doc Start a new ggs_coordinator backup instance, and register it under
|
||||
%% this name. This means that there can only be one instance of this module
|
||||
%% running.
|
||||
start_link() ->
|
||||
gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
|
||||
|
||||
%% @doc Stops the server with the specified reason.
|
||||
%% @spec stop(Reason) -> ok.
|
||||
%% Reason = String
|
||||
stop(_Reason) -> ggs_logger:not_implemented().
|
||||
|
||||
%% API
|
||||
back_up(State) ->
|
||||
gen_server:cast(?SERVER, State).
|
||||
|
||||
%% @doc Retrieve the state stored in this server. If there is a state stored
|
||||
%% here, it is returned to the caller. If the backup server does not have a
|
||||
%% state stored, it will return the no_state_stored atom.
|
||||
retrieve() ->
|
||||
gen_server:call(?SERVER, retrieve).
|
||||
|
||||
%% gen_server callbacks
|
||||
|
||||
%% @doc Initiate the server. This is called from gen_server
|
||||
init([]) ->
|
||||
{ok, no_state_stored}.
|
||||
|
||||
handle_call(retrieve, _From, State) ->
|
||||
{reply, State, State}.
|
||||
|
||||
handle_cast(NewState, _State) ->
|
||||
{noreply, NewState}.
|
||||
|
||||
handle_info(Msg, State) ->
|
||||
io:format("Received out of bounds message! "),
|
||||
erlang:display(Msg),
|
||||
io:format("~n"),
|
||||
{noreply, State}.
|
||||
|
||||
terminate(normal, _State) ->
|
||||
ok.
|
||||
|
||||
code_change(_OldVsn, State, _Extra) ->
|
||||
{ok, State}.
|
|
@ -118,21 +118,21 @@ intern_player_command(Table, Player, Command, _Args) ->
|
|||
intern_add_player(Table, Player) ->
|
||||
{ok, PlayerList} = ggs_table:get_player_list(Table),
|
||||
case length(PlayerList) of
|
||||
1 ->
|
||||
erlang:display("A player joined");
|
||||
1 -> ok;
|
||||
%erlang:display("A player joined");
|
||||
2 ->
|
||||
erlang:display("Player 2 joined"),
|
||||
%erlang:display("Player 2 joined"),
|
||||
[P1,P2] = PlayerList,
|
||||
erlang:display(PlayerList),
|
||||
erlang:display("P1: joining"),
|
||||
%erlang:display(PlayerList),
|
||||
%erlang:display("P1: joining"),
|
||||
ggs_db:setItem(Table, local_storage, P1, player1),
|
||||
erlang:display(ggs_db:getItem(Table, local_storage, P1)),
|
||||
%erlang:display(ggs_db:getItem(Table, local_storage, P1)),
|
||||
ggs_db:setItem(Table, local_storage, player1_y, 50),
|
||||
ggs_table:send_command(Table, P1, {"welcome", int2str(1)}),
|
||||
ggs_table:notify_all_players(Table, {"player1_y", int2str(50)}),
|
||||
erlang:display("P2: joining"),
|
||||
%erlang:display("P2: joining"),
|
||||
ggs_db:setItem(Table, local_storage, P2, player2),
|
||||
erlang:display(ggs_db:getItem(Table, local_storage, P2)),
|
||||
%erlang:display(ggs_db:getItem(Table, local_storage, P2)),
|
||||
ggs_db:setItem(Table, local_storage, player2_y, 50),
|
||||
ggs_table:send_command(Table, P2, {"welcome", int2str(2)}),
|
||||
ggs_table:send_command(Table, P2, {"player1_y", int2str(50)}),
|
||||
|
@ -145,7 +145,7 @@ intern_add_player(Table, Player) ->
|
|||
intern_up(Table, Player) ->
|
||||
case ggs_db:getItem(Table, local_storage, Player) of
|
||||
player1 ->
|
||||
erlang:display("P1: command up"),
|
||||
%erlang:display("P1: command up"),
|
||||
Y = ggs_db:getItem(Table, local_storage, player1_y),
|
||||
NewY = Y - 10,
|
||||
case NewY >= 0 of
|
||||
|
@ -156,7 +156,7 @@ intern_up(Table, Player) ->
|
|||
ggs_table:send_command(Table, Player, {"notice", "Already on top"})
|
||||
end;
|
||||
player2 ->
|
||||
erlang:display("P2: command up"),
|
||||
%erlang:display("P2: command up"),
|
||||
Y = ggs_db:getItem(Table, local_storage, player2_y),
|
||||
NewY = Y - 10,
|
||||
case NewY >= 0 of
|
||||
|
@ -171,7 +171,7 @@ intern_up(Table, Player) ->
|
|||
intern_down(Table, Player) ->
|
||||
case ggs_db:getItem(Table, local_storage, Player) of
|
||||
player1 ->
|
||||
erlang:display("P1: command down"),
|
||||
%erlang:display("P1: command down"),
|
||||
Y = ggs_db:getItem(Table, local_storage, player1_y),
|
||||
NewY = Y + 10,
|
||||
case NewY =< 100 of
|
||||
|
@ -182,7 +182,7 @@ intern_down(Table, Player) ->
|
|||
ggs_table:send_command(Table, Player, {"notice", "Already on bottom"})
|
||||
end;
|
||||
player2 ->
|
||||
erlang:display("P2: command down"),
|
||||
%erlang:display("P2: command down"),
|
||||
Y = ggs_db:getItem(Table, local_storage, player2_y),
|
||||
NewY = Y + 10,
|
||||
case NewY =< 100 of
|
||||
|
@ -195,21 +195,21 @@ intern_down(Table, Player) ->
|
|||
end.
|
||||
|
||||
intern_start(Table, Player) ->
|
||||
erlang:display(Player),
|
||||
erlang:display(ggs_db:getItem(Table, local_storage, Player)),
|
||||
%erlang:display(Player),
|
||||
%erlang:display(ggs_db:getItem(Table, local_storage, Player)),
|
||||
case ggs_db:getItem(Table, local_storage, Player) of
|
||||
player1 ->
|
||||
ggs_db:setItem(Table, local_storage, player1_ready, true),
|
||||
ggs_db:setItem(Table, local_storage, player1_points, 0),
|
||||
case ggs_db:getItem(Table, local_storage, player2_ready) of
|
||||
true ->
|
||||
erlang:display("P1 ready, start game."),
|
||||
%erlang:display("P1 ready, start game."),
|
||||
ggs_table:notify_all_players(Table, {"game", "start"}),
|
||||
ggs_db:setItem(Table, local_storage, ball, {50,50,1,1}),
|
||||
Pid = spawn(fun() -> game_loop([Table]) end),
|
||||
Pid ! tick;
|
||||
_Other ->
|
||||
erlang:display("P1 ready, waiting."),
|
||||
%erlang:display("P1 ready, waiting."),
|
||||
ggs_table:send_command(Table, Player, {"game", "wait"})
|
||||
end;
|
||||
player2 ->
|
||||
|
@ -217,17 +217,18 @@ intern_start(Table, Player) ->
|
|||
ggs_db:setItem(Table, local_storage, player2_points, 0),
|
||||
case ggs_db:getItem(Table, local_storage, player1_ready) of
|
||||
true ->
|
||||
erlang:display("P2 ready, start game."),
|
||||
%erlang:display("P2 ready, start game."),
|
||||
ggs_table:notify_all_players(Table, {"game", "start"}),
|
||||
ggs_db:setItem(Table, local_storage, ball, {50,50,-1,-1}),
|
||||
GameLoop = spawn(fun() -> game_loop([Table]) end),
|
||||
GameLoop ! tick;
|
||||
_Other ->
|
||||
erlang:display("P2 ready, waiting."),
|
||||
%erlang:display("P2 ready, waiting."),
|
||||
ggs_table:send_command(Table, Player, {"game", "wait"})
|
||||
end;
|
||||
Other ->
|
||||
erlang:display(Other)
|
||||
ok
|
||||
%erlang:display(Other)
|
||||
end.
|
||||
|
||||
game_loop([Table]) ->
|
||||
|
|
|
@ -30,20 +30,20 @@ start(Socket) ->
|
|||
join_table(Num) ->
|
||||
case ggs_coordinator:join_table(integer_to_list(Num)) of
|
||||
{ok, T} ->
|
||||
io:format("Joining existing table: ~p~n", [T]),
|
||||
%io:format("Joining existing table: ~p~n", [T]),
|
||||
T;
|
||||
{error, no_such_table} ->
|
||||
case ggs_coordinator:create_table({force, integer_to_list(Num)}) of
|
||||
{ok, TBToken} -> ok
|
||||
end,
|
||||
case ggs_coordinator:join_table(integer_to_list(Num)) of
|
||||
{ok, T} -> io:format("Creating new table: ~p~n", [T]),
|
||||
{ok, T} -> %io:format("Creating new table: ~p~n", [T]),
|
||||
T;
|
||||
{error, E} -> erlang:display(E),
|
||||
{error, E} -> %erlang:display(E),
|
||||
join_table(Num+1)
|
||||
end;
|
||||
{error, table_full} ->
|
||||
erlang:display("Table full!"),
|
||||
%erlang:display("Table full!"),
|
||||
join_table(Num+1)
|
||||
end.
|
||||
|
||||
|
|
BIN
tests/current_counterexample.eqc
Normal file
BIN
tests/current_counterexample.eqc
Normal file
Binary file not shown.
22
tests/ggs_db_quickcheck_test.erl
Normal file
22
tests/ggs_db_quickcheck_test.erl
Normal file
|
@ -0,0 +1,22 @@
|
|||
-module(ggs_db_quickcheck_test).
|
||||
|
||||
-include_lib("eqc/include/eqc.hrl").
|
||||
|
||||
-compile(export_all).
|
||||
|
||||
|
||||
%prop_delete() ->
|
||||
% ?FORALL({X, Xs}, {int(), list(int())},
|
||||
% not lists:member(X, lists:delete(X, Xs))).
|
||||
|
||||
%test_delete() ->
|
||||
% quickcheck(prop_delete()).
|
||||
|
||||
|
||||
prop_getitem ->
|
||||
ggs_db:init(),
|
||||
?FORALL({}).
|
||||
|
||||
|
||||
|
||||
|
21
texput.log
Normal file
21
texput.log
Normal file
|
@ -0,0 +1,21 @@
|
|||
This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian) (format=latex 2011.3.22) 22 MAR 2011 15:09
|
||||
entering extended mode
|
||||
restricted \write18 enabled.
|
||||
%&-line parsing enabled.
|
||||
**Hej
|
||||
|
||||
! Emergency stop.
|
||||
<*> Hej
|
||||
|
||||
End of file on the terminal!
|
||||
|
||||
|
||||
Here is how much of TeX's memory you used:
|
||||
3 strings out of 495062
|
||||
104 string characters out of 1182644
|
||||
45108 words of memory out of 3000000
|
||||
3282 multiletter control sequences out of 15000+50000
|
||||
3640 words of font info for 14 fonts, out of 3000000 for 9000
|
||||
28 hyphenation exceptions out of 8191
|
||||
0i,0n,0p,6b,6s stack positions out of 5000i,500n,10000p,200000b,50000s
|
||||
No pages of output.
|
Reference in a new issue