-
Notifications
You must be signed in to change notification settings - Fork 0
/
game_of_life_tests.pl
65 lines (58 loc) · 1.54 KB
/
game_of_life_tests.pl
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
:- load_files(game_of_life).
:- use_module(library(plunit)).
:- begin_tests(game_of_life_tests).
test(world_Print_TEST):-
world_Print([
[0,0,0,0,0],
[0,0,0,0,0],
[0,0,0,0,0],
[0,0,0,0,0],
[0,0,0,0,0]
]).
test(cell_current_state_TEST):-
World = [[0,0,0,0,0],
[0,0,0,0,0],
[0,0,0,0,0]],
cell_current_state(World, 1, 2, State),
!,
State = 0.
test(neighbours_counter_TEST):-
World = [[0,0,0,0,0],
[0,0,1,1,0],
[0,0,1,0,0]],
neighbours_counter(World,1,2,Amount),
!,
Amount = 2.
%%NewState is equal to 1 and remains 1 in a new generation.
test(cell_new_state_TEST1):-
World = [[0,0,0,0,0],
[0,0,1,1,0],
[0,0,1,0,0]],
cell_new_state(World,1,2,1,NewState),
!,
NewState = 1.
%%NewState is equal to 0 and becomes 1 in a new generation.
test(cell_new_state_TEST2):-
World = [[0,0,0,0,0],
[0,1,0,1,0],
[0,0,1,0,0]],
cell_new_state(World,1,2,0,NewState),
!,
NewState = 1.
%%NewState is equal to 1 and becomes 0 in a new generation.
test(cell_new_state_TEST3):-
World = [[0,0,0,0,0],
[0,0,1,0,0],
[0,0,0,0,0]],
cell_new_state(World,1,2,1,NewState),
!,
NewState = 0.
test(state_controller_TEST):-
World = [[0,0,0,0,0],
[0,0,1,0,0],
[0,0,0,0,0]],
cell_current_state(World,1,2,State),
cell_new_state(World,1,2,State,NewState),
!,
NewState = 0.
:- end_tests(game_of_life_tests).