-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhint_cb.m
37 lines (36 loc) · 862 Bytes
/
hint_cb.m
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
function hint_cb()
%show a random cell as a hint
%
global matrix_game;
global matrix_flags ;
global number_of_tiles_col;
global number_of_tiles_row;
global start
% the number of cols and rows
m = number_of_tiles_row;
n = number_of_tiles_col;
rows = [];
cols = [];
% start game if hint pressed for first time
if start == false
StartTimer();
start = true;
end
% find all unclicked number cell
for x = 1:m
for y = 1:n
if ( matrix_game(x,y)> 0 && matrix_flags(x,y)==0)
rows(end + 1) = x;
cols(end + 1) = y;
end
end
end
% find a random hint
if(size(rows,2)>0)
i = randi([1,size(rows,2)],1);
x = rows(i);
y = cols(i);
c = (x-1)*(n)+y;
hit_number(x,y,c);
end
end