clear all
clc
close all
xlim([0 10]);
ylim([0 10]);
grid('on');
alpha26 = {'A','B','C','D','E','F','G','H','I','J','K','L',...
'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
word1 = {'A','L','P','A','C','A'};
word2 = {'A','R','M','A','D','I','L','L','O'};
word3 = {'B','A','B','O','O','N'};
word4 = {'S','N','A','K','E'};
lo = randi(10)-0.5;
po = randi(5) - 0.5;
lo1 = randi(10) - 0.5;
po1 = randi(2) - 0.5;
if lo1 == lo
lo1 = randi(10) - 0.5;
elseif po1 == po
po1 = randi(2) - 0.5;
end
lo2 = randi(10) - 0.5;
po2 = randi(5) - 0.5;
lo3 = randi(10)-0.5;
po3 = randi(5) - 0.5;
if lo2 == lo1 || lo
lo2 = randi(10) - 0.5;
elseif po2 == po1 || po
po2 = randi(5) - 0.5;
end
chance= randi(2);
chance1 = chance;
chance2 = chance;
for i = 1:10
for j = 1:10
ws{i,j} = alpha26{randi([1,26],1)};
if chance==1
for mo=po+0.5:po + length(word1)
ws{(lo+0.5),mo}=('');
for mo1=po1+0.5:po1 + length(word2)
ws{(lo1+0.5),mo1}=('');
for mo2 = po2+0.5: po2 + length(word3)
ws{mo2,(lo2+0.5)} = ('');
for mo3 = po3+0.5: po3 + length(word4)
ws{mo3,(lo3+0.5)} = ('');
end
end
end
end
elseif chance==2
for mo=po+0.5:po + length(word1)
ws{mo,(lo+0.5)}=('');
for mo1=po1+0.5:po1 + length(word2)
ws{mo1,(lo1+0.5)}=('');
for mo2 = po2 + 0.5: po2 + length(word3)
ws{(lo2 + 0.5),mo2} = ('');
for mo3 = po3 + 0.5: po3 + length(word4)
ws{(lo3 + 0.5),mo3} = ('');
end
end
end
end
end
end
end
search = 10;
for p=1:search
for n = 1:search
te1 = text(p-0.5, n-0.5 , ws{p,n}, ...
'fontsize', 20, 'horizontalalignment', 'center');
set(te1, 'color', 'k')
end
end
search = 10;
for p=1:search
for n = 1:search
te1 = text(p-0.5, n-0.5 , ws{p,n}, ...
'fontsize', 20, 'horizontalalignment', 'center');
set(te1, 'color', 'k')
end
end
search = 10;
for p = 1:1
for n = 1:length(word1)
if chance==1
te1 = text(lo,po,word1(p,n), ...
'fontsize', 20, 'horizontalalignment', 'center');
set(te1, 'color', 'k')
elseif chance==2
te1 = text(po,lo,word1(p,n), ...
'fontsize', 20, 'horizontalalignment', 'center');
set(te1, 'color', 'k')
end
po = po + 1;
end
end
for p = 1:1
for n = 1:length(word2)
if chance1==1
te1 = text(lo1,po1,word2(p,n), ...
'fontsize', 20, 'horizontalalignment', 'center');
set(te1, 'color', 'k')
elseif chance1==2
te1 = text(po1,lo1,word2(p,n), ...
'fontsize', 20, 'horizontalalignment', 'center');
set(te1, 'color', 'k')
end
po1 = po1 + 1;
end
end
for p = 1:1
for n = 1:length(word3)
if chance1==2
te1 = text(lo2,po2,word3(p,n), ...
'fontsize', 20, 'horizontalalignment', 'center');
set(te1, 'color', 'k')
elseif chance1==1
te1 = text(po2,lo2,word3(p,n), ...
'fontsize', 20, 'horizontalalignment', 'center');
set(te1, 'color', 'k')
end
po2 = po2 + 1;
end
end
for p = 1:1
for n = 1:length(word4)
if chance1==2
te1 = text(lo3,po3,word4(p,n), ...
'fontsize', 20, 'horizontalalignment', 'center');
set(te1, 'color', 'k')
elseif chance1==1
te1 = text(po3,lo3,word4(p,n), ...
'fontsize', 20, 'horizontalalignment', 'center');
set(te1, 'color', 'k')
end
po3 = po3 + 1;
end
end