-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.plt
39 lines (31 loc) · 2.69 KB
/
player.plt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
:- begin_tests(player).
:- use_module([utils, player]).
test(line_score, [nondet]) :-
line_score([(1, 2), (2, 3), (1, 1), (2, 5), (2, 4), (3, 4), (1, 4)], (2, 4), Score),
assertion(Score=:=3).
test(tile_score, [nondet]) :-
tile_score(
[ [(1, 2), (2, 3), (1, 1), (2, 5), (2, 4), (3, 4), (1, 4), (3, 5), (3, 6), (3, 3)]:table
],
(2, 4),
Score),
assertion(Score=:=6).
test(new_players, [nondet]) :-
new_players(2, Players:players),
penalization_list(P),
strategies(S),
findall(Y:Id,
( member(L:Id, Players),
member(X:strategy, L),
member(X, S),
concat([X:strategy], Y, L)
),
NewP),
assertion(NewP==[[[[[empty]:stocks, [blue, red, yellow, black, white]:valid, [blue, red, yellow, black, white]:all]:1, [[empty, empty]:stocks, [blue, red, yellow, black, white]:valid, [blue, red, yellow, black, white]:all]:2, [[empty, empty, empty]:stocks, [blue, red, yellow, black, white]:valid, [blue, red, yellow, black, white]:all]:3, [[empty, empty, empty, empty]:stocks, [blue, red, yellow, black, white]:valid, [blue, red, yellow, black, white]:all]:4, [[empty, empty, empty, empty, empty]:stocks, [blue, red, yellow, black, white]:valid, [blue, red, yellow, black, white]:all]:5]:board, P, []:table, 0:score]:1, [[[[empty]:stocks, [blue, red, yellow, black, white]:valid, [blue, red, yellow, black, white]:all]:1, [[empty, empty]:stocks, [blue, red, yellow, black, white]:valid, [blue, red, yellow, black, white]:all]:2, [[empty, empty, empty]:stocks, [blue, red, yellow, black, white]:valid, [blue, red, yellow, black, white]:all]:3, [[empty, empty, empty, empty]:stocks, [blue, red, yellow, black, white]:valid, [blue, red, yellow, black, white]:all]:4, [[empty, empty, empty, empty, empty]:stocks, [blue, red, yellow, black, white]:valid, [blue, red, yellow, black, white]:all]:5]:board, P, []:table, 0:score]:2]).
test(column_of, [nondet]) :-
column_of(4, blue, R),
assertion(R=:=4).
test(empty_board, [nondet]) :-
empty_board(Data),
assertion(Data==[[[empty]:stocks, [blue, red, yellow, black, white]:valid, [blue, red, yellow, black, white]:all]:1, [[empty, empty]:stocks, [blue, red, yellow, black, white]:valid, [blue, red, yellow, black, white]:all]:2, [[empty, empty, empty]:stocks, [blue, red, yellow, black, white]:valid, [blue, red, yellow, black, white]:all]:3, [[empty, empty, empty, empty]:stocks, [blue, red, yellow, black, white]:valid, [blue, red, yellow, black, white]:all]:4, [[empty, empty, empty, empty, empty]:stocks, [blue, red, yellow, black, white]:valid, [blue, red, yellow, black, white]:all]:5]:board).
:- end_tests(player).