Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function functions.check(array)
- local cont = {hor_right = 1,hor_left = 1,ver_up = 1,ver_down = 1,dia_up_inc = 1,dia_up_dec = 1,dia_down_inc = 1,dia_down_dec = 1};
- local completed = true;
- local s = "";
- for y = #array.table , 1,-1 do
- for x = 1, #array.table[y] do
- if array.table[y][x] == "" then completed = false; end --board completed
- if array.table[y][x] != "" then
- s = array.table[y][x]
- for i = 1, array.n-1 do
- if fb(array,x+i,y) and array.table[y][x+i] == s then cont.hor_right = cont.hor_right+1 end
- if fb(array,x,y+i) and array.table[y+i][x] == s then cont.ver_down = cont.ver_down+1 end
- if fb(array,x-i,y) and array.table[y][x-i] == s then cont.hor_left = cont.hor_left+1 end
- if fb(array,x,y-i) and array.table[y-i][x] == s then cont.ver_up = cont.ver_up+1 end
- if fb(array,x+i,y-i) and array.table[y-i][x+i] == s then cont.dia_up_dec = cont.dia_up_dec + 1 end
- if fb(array,x-i,y-i) and array.table[y-i][x-i] == s then cont.dia_up_inc = cont.dia_up_inc + 1 end
- if fb(array,x+i,y+i) and array.table[y+i][x+i] == s then cont.dia_down_inc = cont.dia_down_inc + 1 end
- if fb(array,x-i,y+i) and array.table[y+i][x-i] == s then cont.dia_down_dec = cont.dia_down_dec+1 end
- end
- if cont.hor_right >= array.n then return s end cont.hor_right = 1;
- if cont.hor_left >= array.n then return s end cont.hor_left = 1;
- if cont.ver_up >= array.n then return s end cont.ver_up = 1;
- if cont.ver_down >= array.n then return s end cont.ver_down = 1;
- if cont.dia_up_inc >= array.n then return s end cont.dia_up_inc = 1;
- if cont.dia_down_inc >= array.n then return s end cont.dia_down_inc = 1;
- if cont.dia_up_dec >= array.n then return s end cont.dia_up_dec = 1;
- if cont.dia_down_dec >= array.n then return s end cont.dia_down_dec = 1;
- cont = {hor_right = 1,hor_left = 1,ver_up = 1,ver_down = 1,dia_up_inc = 1,dia_up_dec = 1,dia_down_inc = 1,dia_down_dec = 1};
- end
- end
- end
- return completed;
- end
Add Comment
Please, Sign In to add comment