function dummy = connect4()
% This file performs the famous game of Connect FOUR
% The rules of the Game are:
% Two players may participate
% The board is shown in the figure window
% Every player has his own tile colour
% Every player drops his tile in his turn by Clicking on the desired Column
% The two players go on trying to connect Four tiles of one Colour
% Horizontally, Vertically or in any diagonal
% The player who manages to do so first in his own Colour
% IS THE WINNER
% Programmed by: Mina Ayman (mina_ayman@yahoo.com)
% Using MATLAB R12 on 14/11/2003
% Enjoy Your Play !!!
% Getting the tiles for the play
tile = imread('btile.bmp');
p1t = imread('p1.bmp');
p2t = imread('p2.bmp');
wint = imread('win.bmp');
% Getting the board for the play
board = [tile tile tile tile tile tile tile;
tile tile tile tile tile tile tile;
tile tile tile tile tile tile tile;
tile tile tile tile tile tile tile;
tile tile tile tile tile tile tile;
tile tile tile tile tile tile tile];
% Sound Generator for the winner
[win,y,z] = wavread('winner.wav');
winning = [win; win; win; win];
% Sound Generator for the hit sound
[hit,b,c] = wavread('hit3.wav');
% Sound Generator for the drop tile sound
[tdrop,bb,cc] = wavread('boing.wav');
% Initialization of the players
fprintf('\n\t\t\t Welcome to The Game Of CONNECT FOUR')
st = 'Your Turn! ';
con = 'Congratulations! ';
wins = ' Wins';
% Player 1
fprintf('\n Entering the Name of Player (1)')
player1 = input('\nYour Name is : ','s');
fprintf('\n Welcome %s',player1)
fprintf('\n You will get the Red Tile')
id1 = [st player1];
con1 = [con player1 wins];
% Player 2
fprintf('\n\n\n Entering the Name of Player (2)')
player2 = input('\nYour Name is : ','s');
fprintf('\n Welcome %s',player2)
fprintf('\n You will get the Yellow Tile')
id2 = [st player2];
con2 = [con player2 wins];
fprintf('\n\n\n Now Let''s Begin Our Game')
fprintf('\n Press (Enter) when READY')
pause;
% Plotting the board
u = figure;
set(gcf,'Color',[0 0.7 0])
imshow(board)
% Introduction
p = title('**Welcome to CONNECT FOUR**');
set(p,'Color',[0.8 0 0.8])
set(p,'FontWeight','bold')
set(p,'FontSize',19)
pause(4);
% Displaying Rules of the game
set(p,'Color',[0.5 0 0.5])
set(p,'String','Drop Your Tile in Your Turn!!!')
set(p,'FontSize',18)
pause(3);
set(p,'String','With a Right Click on the Column')
pause(3);
set(p,'String','Where You Want to Drop Your Tile')
pause(4);
game = zeros(6,7);
% The Beginning of the Play
for n = 1 : 22
p1x = 0;
a = title(id1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
pause(1.2);
% Get the play of Player 1
while(p1x == 0);
[c1,r1,pp1] = impixel(board);
p1y = ceil(c1(1)/50);
col1 = game(:,p1y);
if (all(col1) == 0)
p1x = max(find(col1 == 0));
game(p1x,p1y) = 11;
end
end
board1 = board;
% Perform Play
for m = 1 : p1x
board1((m-1)*50+1 : (m-1)*50+50 , (p1y-1)*50+1 : (p1y-1)*50+50 , :) = p1t;
imshow(board1)
sound(tdrop,bb,cc)
pause(0.1)
board1 = board;
end
sound(hit,b,c)
pause(0.3)
board((p1x-1)*50+1 : (p1x-1)*50+50 , (p1y-1)*50+1 : (p1y-1)*50+50 , :) = p1t;
% Check for a winning condition
if (game(6,1)==11 & game(6,2)==11 & game(6,3)==11 & game(6,4)==11)
pause(1);
board(251:300 , 1:50 , :) = wint;
board(251:300 , 51:100 , :) = wint;
board(251:300 , 101:150 , :) = wint;
board(251:300 , 151:200 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,2)==11 & game(6,3)==11 & game(6,4)==11 & game(6,5)==11)
pause(1);
board(251:300 , 51:100 , :) = wint;
board(251:300 , 101:150 , :) = wint;
board(251:300 , 151:200 , :) = wint;
board(251:300 , 201:250 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,3)==11 & game(6,4)==11 & game(6,5)==11 & game(6,6)==11)
pause(1);
board(251:300 , 101:150 , :) = wint;
board(251:300 , 151:200 , :) = wint;
board(251:300 , 201:250 , :) = wint;
board(251:300 , 251:300 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,4)==11 & game(6,5)==11 & game(6,6)==11 & game(6,7)==11)
pause(1);
board(251:300 , 151:200 , :) = wint;
board(251:300 , 201:250 , :) = wint;
board(251:300 , 251:300 , :) = wint;
board(251:300 , 301:350 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,1)==11 & game(5,2)==11 & game(5,3)==11 & game(5,4)==11)
pause(1);
board(201:250 , 1:50 , :) = wint;
board(201:250 , 51:100 , :) = wint;
board(201:250 , 101:150 , :) = wint;
board(201:250 , 151:200 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,2)==11 & game(5,3)==11 & game(5,4)==11 & game(5,5)==11)
pause(1);
board(201:250 , 51:100 , :) = wint;
board(201:250 , 101:150 , :) = wint;
board(201:250 , 151:200 , :) = wint;
board(201:250 , 201:250 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,3)==11 & game(5,4)==11 & game(5,5)==11 & game(5,6)==11)
pause(1);
board(201:250 , 101:150 , :) = wint;
board(201:250 , 151:200 , :) = wint;
board(201:250 , 201:250 , :) = wint;
board(201:250 , 251:300 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,4)==11 & game(5,5)==11 & game(5,6)==11 & game(5,7)==11)
pause(1);
board(201:250 , 151:200 , :) = wint;
board(201:250 , 201:250 , :) = wint;
board(201:250 , 251:300 , :) = wint;
board(201:250 , 301:350 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,1)==11 & game(4,2)==11 & game(4,3)==11 & game(4,4)==11)
pause(1);
board(151:200 , 1:50 , :) = wint;
board(151:200 , 51:100 , :) = wint;
board(151:200 , 101:150 , :) = wint;
board(151:200 , 151:200 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,2)==11 & game(4,3)==11 & game(4,4)==11 & game(4,5)==11)
pause(1);
board(151:200 , 51:100 , :) = wint;
board(151:200 , 101:150 , :) = wint;
board(151:200 , 151:200 , :) = wint;
board(151:200 , 201:250 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,3)==11 & game(4,4)==11 & game(4,5)==11 & game(4,6)==11)
pause(1);
board(151:200 , 101:150 , :) = wint;
board(151:200 , 151:200 , :) = wint;
board(151:200 , 201:250 , :) = wint;
board(151:200 , 251:300 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,4)==11 & game(4,5)==11 & game(4,6)==11 & game(4,7)==11)
pause(1);
board(151:200 , 151:200 , :) = wint;
board(151:200 , 201:250 , :) = wint;
board(151:200 , 251:300 , :) = wint;
board(151:200 , 301:350 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(3,1)==11 & game(3,2)==11 & game(3,3)==11 & game(3,4)==11)
pause(1);
board(101:150 , 1:50 , :) = wint;
board(101:150 , 51:100 , :) = wint;
board(101:150 , 101:150 , :) = wint;
board(101:150 , 151:200 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(3,2)==11 & game(3,3)==11 & game(3,4)==11 & game(3,5)==11)
pause(1);
board(101:150 , 51:100 , :) = wint;
board(101:150 , 101:150 , :) = wint;
board(101:150 , 151:200 , :) = wint;
board(101:150 , 201:250 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(3,3)==11 & game(3,4)==11 & game(3,5)==11 & game(3,6)==11)
pause(1);
board(101:150 , 101:150 , :) = wint;
board(101:150 , 151:200 , :) = wint;
board(101:150 , 201:250 , :) = wint;
board(101:150 , 251:300 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(3,4)==11 & game(3,5)==11 & game(3,6)==11 & game(3,7)==11)
pause(1);
board(101:150 , 151:200 , :) = wint;
board(101:150 , 201:250 , :) = wint;
board(101:150 , 251:300 , :) = wint;
board(101:150 , 301:350 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(2,1)==11 & game(2,2)==11 & game(2,3)==11 & game(2,4)==11)
pause(1);
board(51:100 , 1:50 , :) = wint;
board(51:100 , 51:100 , :) = wint;
board(51:100 , 101:150 , :) = wint;
board(51:100 , 151:200 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(2,2)==11 & game(2,3)==11 & game(2,4)==11 & game(2,5)==11)
pause(1);
board(51:100 , 51:100 , :) = wint;
board(51:100 , 101:150 , :) = wint;
board(51:100 , 151:200 , :) = wint;
board(51:100 , 201:250 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(2,3)==11 & game(2,4)==11 & game(2,5)==11 & game(2,6)==11)
pause(1);
board(51:100 , 101:150 , :) = wint;
board(51:100 , 151:200 , :) = wint;
board(51:100 , 201:250 , :) = wint;
board(51:100 , 251:300 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(2,4)==11 & game(2,5)==11 & game(2,6)==11 & game(2,7)==11)
pause(1);
board(51:100 , 151:200 , :) = wint;
board(51:100 , 201:250 , :) = wint;
board(51:100 , 251:300 , :) = wint;
board(51:100 , 301:350 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(1,1)==11 & game(1,2)==11 & game(1,3)==11 & game(1,4)==11)
pause(1);
board(1:50 , 1:50 , :) = wint;
board(1:50 , 51:100 , :) = wint;
board(1:50 , 101:150 , :) = wint;
board(1:50 , 151:200 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(1,2)==11 & game(1,3)==11 & game(1,4)==11 & game(1,5)==11)
pause(1);
board(1:50 , 51:100 , :) = wint;
board(1:50 , 101:150 , :) = wint;
board(1:50 , 151:200 , :) = wint;
board(1:50 , 201:250 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(1,3)==11 & game(1,4)==11 & game(1,5)==11 & game(1,6)==11)
pause(1);
board(1:50 , 101:150 , :) = wint;
board(1:50 , 151:200 , :) = wint;
board(1:50 , 201:250 , :) = wint;
board(1:50 , 251:300 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(1,4)==11 & game(1,5)==11 & game(1,6)==11 & game(1,7)==11)
pause(1);
board(1:50 , 151:200 , :) = wint;
board(1:50 , 201:250 , :) = wint;
board(1:50 , 251:300 , :) = wint;
board(1:50 , 301:350 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,1)==11 & game(5,1)==11 & game(4,1)==11 & game(3,1)==11)
pause(1);
board(251:300 , 1:50 , :) = wint;
board(201:250 , 1:50 , :) = wint;
board(151:200 , 1:50 , :) = wint;
board(101:150 , 1:50 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,1)==11 & game(4,1)==11 & game(3,1)==11 & game(2,1)==11)
pause(1);
board(201:250 , 1:50 , :) = wint;
board(151:200 , 1:50 , :) = wint;
board(101:150 , 1:50 , :) = wint;
board(51:100 , 1:50 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,1)==11 & game(3,1)==11 & game(2,1)==11 & game(1,1)==11)
pause(1);
board(151:200 , 1:50 , :) = wint;
board(101:150 , 1:50 , :) = wint;
board(51:100 , 1:50 , :) = wint;
board(1:50 , 1:50 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,2)==11 & game(5,2)==11 & game(4,2)==11 & game(3,2)==11)
pause(1);
board(251:300 , 51:100 , :) = wint;
board(201:250 , 51:100 , :) = wint;
board(151:200 , 51:100 , :) = wint;
board(101:150 , 51:100 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,2)==11 & game(4,2)==11 & game(3,2)==11 & game(2,2)==11)
pause(1);
board(201:250 , 51:100 , :) = wint;
board(151:200 , 51:100 , :) = wint;
board(101:150 , 51:100 , :) = wint;
board(51:100 , 51:100 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,2)==11 & game(3,2)==11 & game(2,2)==11 & game(1,2)==11)
pause(1);
board(151:200 , 51:100 , :) = wint;
board(101:150 , 51:100 , :) = wint;
board(51:100 , 51:100 , :) = wint;
board(1:50 , 51:100 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,3)==11 & game(5,3)==11 & game(4,3)==11 & game(3,3)==11)
pause(1);
board(251:300 , 101:150 , :) = wint;
board(201:250 , 101:150 , :) = wint;
board(151:200 , 101:150 , :) = wint;
board(101:150 , 101:150 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,3)==11 & game(4,3)==11 & game(3,3)==11 & game(2,3)==11)
pause(1);
board(201:250 , 101:150 , :) = wint;
board(151:200 , 101:150 , :) = wint;
board(101:150 , 101:150 , :) = wint;
board(51:100 , 101:150 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,3)==11 & game(3,3)==11 & game(2,3)==11 & game(1,3)==11)
pause(1);
board(151:200 , 101:150 , :) = wint;
board(101:150 , 101:150 , :) = wint;
board(51:100 , 101:150 , :) = wint;
board(1:50 , 101:150 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,4)==11 & game(5,4)==11 & game(4,4)==11 & game(3,4)==11)
pause(1);
board(251:300 , 151:200 , :) = wint;
board(201:250 , 151:200 , :) = wint;
board(151:200 , 151:200 , :) = wint;
board(101:150 , 151:200 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,4)==11 & game(4,4)==11 & game(3,4)==11 & game(2,4)==11)
pause(1);
board(201:250 , 151:200 , :) = wint;
board(151:200 , 151:200 , :) = wint;
board(101:150 , 151:200 , :) = wint;
board(51:100 , 151:200 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,4)==11 & game(3,4)==11 & game(2,4)==11 & game(1,4)==11)
pause(1);
board(151:200 , 151:200 , :) = wint;
board(101:150 , 151:200 , :) = wint;
board(51:100 , 151:200 , :) = wint;
board(1:50 , 151:200 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,5)==11 & game(5,5)==11 & game(4,5)==11 & game(3,5)==11)
pause(1);
board(251:300 , 201:250 , :) = wint;
board(201:250 , 201:250 , :) = wint;
board(151:200 , 201:250 , :) = wint;
board(101:150 , 201:250 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,5)==11 & game(4,5)==11 & game(3,5)==11 & game(2,5)==11)
pause(1);
board(201:250 , 201:250 , :) = wint;
board(151:200 , 201:250 , :) = wint;
board(101:150 , 201:250 , :) = wint;
board(51:100 , 201:250 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,5)==11 & game(3,5)==11 & game(2,5)==11 & game(1,5)==11)
pause(1);
board(151:200 , 201:250 , :) = wint;
board(101:150 , 201:250 , :) = wint;
board(51:100 , 201:250 , :) = wint;
board(1:50 , 201:250 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,6)==11 & game(5,6)==11 & game(4,6)==11 & game(3,6)==11)
pause(1);
board(251:300 , 251:300 , :) = wint;
board(201:250 , 251:300 , :) = wint;
board(151:200 , 251:300 , :) = wint;
board(101:150 , 251:300 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,6)==11 & game(4,6)==11 & game(3,6)==11 & game(2,6)==11)
pause(1);
board(201:250 , 251:300 , :) = wint;
board(151:200 , 251:300 , :) = wint;
board(101:150 , 251:300 , :) = wint;
board(51:100 , 251:300 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,6)==11 & game(3,6)==11 & game(2,6)==11 & game(1,6)==11)
pause(1);
board(151:200 , 251:300 , :) = wint;
board(101:150 , 251:300 , :) = wint;
board(51:100 , 251:300 , :) = wint;
board(1:50 , 251:300 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,7)==11 & game(5,7)==11 & game(4,7)==11 & game(3,7)==11)
pause(1);
board(251:300 , 301:350 , :) = wint;
board(201:250 , 301:350 , :) = wint;
board(151:200 , 301:350 , :) = wint;
board(101:150 , 301:350 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,7)==11 & game(4,7)==11 & game(3,7)==11 & game(2,7)==11)
pause(1);
board(201:250 , 301:350 , :) = wint;
board(151:200 , 301:350 , :) = wint;
board(101:150 , 301:350 , :) = wint;
board(51:100 , 301:350 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,7)==11 & game(3,7)==11 & game(2,7)==11 & game(1,7)==11)
pause(1);
board(151:200 , 301:350 , :) = wint;
board(101:150 , 301:350 , :) = wint;
board(51:100 , 301:350 , :) = wint;
board(1:50 , 301:350 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,4)==11 & game(5,5)==11 & game(4,6)==11 & game(3,7)==11)
pause(1);
board(251:300 , 151:200 , :) = wint;
board(201:250 , 201:250 , :) = wint;
board(151:200 , 251:300 , :) = wint;
board(101:150 , 301:350 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,4)==11 & game(4,5)==11 & game(3,6)==11 & game(2,7)==11)
pause(1);
board(201:250 , 151:200 , :) = wint;
board(151:200 , 201:250 , :) = wint;
board(101:150 , 251:300 , :) = wint;
board(51:100 , 301:350 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,4)==11 & game(3,5)==11 & game(2,6)==11 & game(1,7)==11)
pause(1);
board(151:200 , 151:200 , :) = wint;
board(101:150 , 201:250 , :) = wint;
board(51:100 , 251:300 , :) = wint;
board(1:50 , 301:350 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,3)==11 & game(5,4)==11 & game(4,5)==11 & game(3,6)==11)
pause(1);
board(251:300 , 101:150 , :) = wint;
board(201:250 , 151:200 , :) = wint;
board(151:200 , 201:250 , :) = wint;
board(101:150 , 251:300 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,3)==11 & game(4,4)==11 & game(3,5)==11 & game(2,6)==11)
pause(1);
board(201:250 , 101:150 , :) = wint;
board(151:200 , 151:200 , :) = wint;
board(101:150 , 201:250 , :) = wint;
board(51:100 , 251:300 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,3)==11 & game(3,4)==11 & game(2,5)==11 & game(1,6)==11)
pause(1);
board(151:200 , 101:150 , :) = wint;
board(101:150 , 151:200 , :) = wint;
board(51:100 , 201:250 , :) = wint;
board(1:50 , 251:300 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,2)==11 & game(5,3)==11 & game(4,4)==11 & game(3,5)==11)
pause(1);
board(251:300 , 51:100 , :) = wint;
board(201:250 , 101:150 , :) = wint;
board(151:200 , 151:200 , :) = wint;
board(101:150 , 201:250 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,2)==11 & game(4,3)==11 & game(3,4)==11 & game(2,5)==11)
pause(1);
board(201:250 , 51:100 , :) = wint;
board(151:200 , 101:150 , :) = wint;
board(101:150 , 151:200 , :) = wint;
board(51:100 , 201:250 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,2)==11 & game(3,3)==11 & game(2,4)==11 & game(1,5)==11)
pause(1);
board(151:200 , 51:100 , :) = wint;
board(101:150 , 101:150 , :) = wint;
board(51:100 , 151:200 , :) = wint;
board(1:50 , 201:250 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,1)==11 & game(5,2)==11 & game(4,3)==11 & game(3,4)==11)
pause(1);
board(251:300 , 1:50 , :) = wint;
board(201:250 , 51:100 , :) = wint;
board(151:200 , 101:150 , :) = wint;
board(101:150 , 151:200 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,1)==11 & game(4,2)==11 & game(3,3)==11 & game(2,4)==11)
pause(1);
board(201:250 , 1:50 , :) = wint;
board(151:200 , 51:100 , :) = wint;
board(101:150 , 101:150 , :) = wint;
board(51:100 , 151:200 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,1)==11 & game(3,2)==11 & game(2,3)==11 & game(1,4)==11)
pause(1);
board(151:200 , 1:50 , :) = wint;
board(101:150 , 51:100 , :) = wint;
board(51:100 , 101:150 , :) = wint;
board(1:50 , 151:200 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,4)==11 & game(5,3)==11 & game(4,2)==11 & game(3,1)==11)
pause(1);
board(251:300 , 151:200 , :) = wint;
board(201:250 , 101:150 , :) = wint;
board(151:200 , 51:100 , :) = wint;
board(101:150 , 1:50 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,4)==11 & game(4,3)==11 & game(3,2)==11 & game(2,1)==11)
pause(1);
board(201:250 , 151:200 , :) = wint;
board(151:200 , 101:150 , :) = wint;
board(101:150 , 51:100 , :) = wint;
board(51:100 , 1:50 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,4)==11 & game(3,3)==11 & game(2,2)==11 & game(1,1)==11)
pause(1);
board(151:200 , 151:200 , :) = wint;
board(101:150 , 101:150 , :) = wint;
board(51:100 , 51:100 , :) = wint;
board(1:50 , 1:50 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,5)==11 & game(5,4)==11 & game(4,3)==11 & game(3,2)==11)
pause(1);
board(251:300 , 201:250 , :) = wint;
board(201:250 , 151:200 , :) = wint;
board(151:200 , 101:150 , :) = wint;
board(101:150 , 51:100 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,5)==11 & game(4,4)==11 & game(3,3)==11 & game(2,2)==11)
pause(1);
board(201:250 , 201:250 , :) = wint;
board(151:200 , 151:200 , :) = wint;
board(101:150 , 101:150 , :) = wint;
board(51:100 , 51:100 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,5)==11 & game(3,4)==11 & game(2,3)==11 & game(1,2)==11)
pause(1);
board(151:200 , 201:250 , :) = wint;
board(101:150 , 151:200 , :) = wint;
board(51:100 , 101:150 , :) = wint;
board(1:50 , 51:100 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,6)==11 & game(5,5)==11 & game(4,4)==11 & game(3,3)==11)
pause(1);
board(251:300 , 251:300 , :) = wint;
board(201:250 , 201:250 , :) = wint;
board(151:200 , 151:200 , :) = wint;
board(101:150 , 101:150 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,6)==11 & game(4,5)==11 & game(3,4)==11 & game(2,3)==11)
pause(1);
board(201:250 , 251:300 , :) = wint;
board(151:200 , 201:250 , :) = wint;
board(101:150 , 151:200 , :) = wint;
board(51:100 , 101:150 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,6)==11 & game(3,5)==11 & game(2,4)==11 & game(1,3)==11)
pause(1);
board(151:200 , 251:300 , :) = wint;
board(101:150 , 201:250 , :) = wint;
board(51:100 , 151:200 , :) = wint;
board(1:50 , 101:150 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,7)==11 & game(5,6)==11 & game(4,5)==11 & game(3,4)==11)
pause(1);
board(251:300 , 301:350 , :) = wint;
board(201:250 , 251:300 , :) = wint;
board(151:200 , 201:250 , :) = wint;
board(101:150 , 151:200 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,7)==11 & game(4,6)==11 & game(3,5)==11 & game(2,4)==11)
pause(1);
board(201:250 , 301:350 , :) = wint;
board(151:200 , 251:300 , :) = wint;
board(101:150 , 201:250 , :) = wint;
board(51:100 , 151:200 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,7)==11 & game(3,6)==11 & game(2,5)==11 & game(1,4)==11)
pause(1);
board(151:200 , 301:350 , :) = wint;
board(101:150 , 251:300 , :) = wint;
board(51:100 , 201:250 , :) = wint;
board(1:50 , 151:200 , :) = wint;
imshow(board)
a = title(con1);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','r')
sound(winning,y,z)
pause(6)
close
break;
end
% End of Player 1 Turn
p2x = 0;
a = title(id2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
pause(1.2);
% Get the play of Player 2
while(p2x == 0);
[c2,r2,pp2] = impixel(board);
p2y = ceil(c2(1)/50);
col2 = game(:,p2y);
if (all(col2) == 0)
p2x = max(find(col2 == 0));
game(p2x,p2y) = 22;
end
end
board2 = board;
% Perform Play
for m = 1 : p2x
board2((m-1)*50+1 : (m-1)*50+50 , (p2y-1)*50+1 : (p2y-1)*50+50 , :) = p2t;
imshow(board2)
sound(tdrop,bb,cc)
pause(0.1)
board2 = board;
end
sound(hit,b,c)
pause(0.3)
board((p2x-1)*50+1 : (p2x-1)*50+50 , (p2y-1)*50+1 : (p2y-1)*50+50 , :) = p2t;
% Check for a winning condition
if (game(6,1)==22 & game(6,2)==22 & game(6,3)==22 & game(6,4)==22)
pause(1);
board(251:300 , 1:50 , :) = wint;
board(251:300 , 51:100 , :) = wint;
board(251:300 , 101:150 , :) = wint;
board(251:300 , 151:200 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,2)==22 & game(6,3)==22 & game(6,4)==22 & game(6,5)==22)
pause(1);
board(251:300 , 51:100 , :) = wint;
board(251:300 , 101:150 , :) = wint;
board(251:300 , 151:200 , :) = wint;
board(251:300 , 201:250 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,3)==22 & game(6,4)==22 & game(6,5)==22 & game(6,6)==22)
pause(1);
board(251:300 , 101:150 , :) = wint;
board(251:300 , 151:200 , :) = wint;
board(251:300 , 201:250 , :) = wint;
board(251:300 , 251:300 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,4)==22 & game(6,5)==22 & game(6,6)==22 & game(6,7)==22)
pause(1);
board(251:300 , 151:200 , :) = wint;
board(251:300 , 201:250 , :) = wint;
board(251:300 , 251:300 , :) = wint;
board(251:300 , 301:350 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,1)==22 & game(5,2)==22 & game(5,3)==22 & game(5,4)==22)
pause(1);
board(201:250 , 1:50 , :) = wint;
board(201:250 , 51:100 , :) = wint;
board(201:250 , 101:150 , :) = wint;
board(201:250 , 151:200 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,2)==22 & game(5,3)==22 & game(5,4)==22 & game(5,5)==22)
pause(1);
board(201:250 , 51:100 , :) = wint;
board(201:250 , 101:150 , :) = wint;
board(201:250 , 151:200 , :) = wint;
board(201:250 , 201:250 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,3)==22 & game(5,4)==22 & game(5,5)==22 & game(5,6)==22)
pause(1);
board(201:250 , 101:150 , :) = wint;
board(201:250 , 151:200 , :) = wint;
board(201:250 , 201:250 , :) = wint;
board(201:250 , 251:300 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,4)==22 & game(5,5)==22 & game(5,6)==22 & game(5,7)==22)
pause(1);
board(201:250 , 151:200 , :) = wint;
board(201:250 , 201:250 , :) = wint;
board(201:250 , 251:300 , :) = wint;
board(201:250 , 301:350 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,1)==22 & game(4,2)==22 & game(4,3)==22 & game(4,4)==22)
pause(1);
board(151:200 , 1:50 , :) = wint;
board(151:200 , 51:100 , :) = wint;
board(151:200 , 101:150 , :) = wint;
board(151:200 , 151:200 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,2)==22 & game(4,3)==22 & game(4,4)==22 & game(4,5)==22)
pause(1);
board(151:200 , 51:100 , :) = wint;
board(151:200 , 101:150 , :) = wint;
board(151:200 , 151:200 , :) = wint;
board(151:200 , 201:250 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,3)==22 & game(4,4)==22 & game(4,5)==22 & game(4,6)==22)
pause(1);
board(151:200 , 101:150 , :) = wint;
board(151:200 , 151:200 , :) = wint;
board(151:200 , 201:250 , :) = wint;
board(151:200 , 251:300 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,4)==22 & game(4,5)==22 & game(4,6)==22 & game(4,7)==22)
pause(1);
board(151:200 , 151:200 , :) = wint;
board(151:200 , 201:250 , :) = wint;
board(151:200 , 251:300 , :) = wint;
board(151:200 , 301:350 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(3,1)==22 & game(3,2)==22 & game(3,3)==22 & game(3,4)==22)
pause(1);
board(101:150 , 1:50 , :) = wint;
board(101:150 , 51:100 , :) = wint;
board(101:150 , 101:150 , :) = wint;
board(101:150 , 151:200 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(3,2)==22 & game(3,3)==22 & game(3,4)==22 & game(3,5)==22)
pause(1);
board(101:150 , 51:100 , :) = wint;
board(101:150 , 101:150 , :) = wint;
board(101:150 , 151:200 , :) = wint;
board(101:150 , 201:250 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(3,3)==22 & game(3,4)==22 & game(3,5)==22 & game(3,6)==22)
pause(1);
board(101:150 , 101:150 , :) = wint;
board(101:150 , 151:200 , :) = wint;
board(101:150 , 201:250 , :) = wint;
board(101:150 , 251:300 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(3,4)==22 & game(3,5)==22 & game(3,6)==22 & game(3,7)==22)
pause(1);
board(101:150 , 151:200 , :) = wint;
board(101:150 , 201:250 , :) = wint;
board(101:150 , 251:300 , :) = wint;
board(101:150 , 301:350 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(2,1)==22 & game(2,2)==22 & game(2,3)==22 & game(2,4)==22)
pause(1);
board(51:100 , 1:50 , :) = wint;
board(51:100 , 51:100 , :) = wint;
board(51:100 , 101:150 , :) = wint;
board(51:100 , 151:200 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(2,2)==22 & game(2,3)==22 & game(2,4)==22 & game(2,5)==22)
pause(1);
board(51:100 , 51:100 , :) = wint;
board(51:100 , 101:150 , :) = wint;
board(51:100 , 151:200 , :) = wint;
board(51:100 , 201:250 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(2,3)==22 & game(2,4)==22 & game(2,5)==22 & game(2,6)==22)
pause(1);
board(51:100 , 101:150 , :) = wint;
board(51:100 , 151:200 , :) = wint;
board(51:100 , 201:250 , :) = wint;
board(51:100 , 251:300 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(2,4)==22 & game(2,5)==22 & game(2,6)==22 & game(2,7)==22)
pause(1);
board(51:100 , 151:200 , :) = wint;
board(51:100 , 201:250 , :) = wint;
board(51:100 , 251:300 , :) = wint;
board(51:100 , 301:350 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(1,1)==22 & game(1,2)==22 & game(1,3)==22 & game(1,4)==22)
pause(1);
board(1:50 , 1:50 , :) = wint;
board(1:50 , 51:100 , :) = wint;
board(1:50 , 101:150 , :) = wint;
board(1:50 , 151:200 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(1,2)==22 & game(1,3)==22 & game(1,4)==22 & game(1,5)==22)
pause(1);
board(1:50 , 51:100 , :) = wint;
board(1:50 , 101:150 , :) = wint;
board(1:50 , 151:200 , :) = wint;
board(1:50 , 201:250 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(1,3)==22 & game(1,4)==22 & game(1,5)==22 & game(1,6)==22)
pause(1);
board(1:50 , 101:150 , :) = wint;
board(1:50 , 151:200 , :) = wint;
board(1:50 , 201:250 , :) = wint;
board(1:50 , 251:300 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(1,4)==22 & game(1,5)==22 & game(1,6)==22 & game(1,7)==22)
pause(1);
board(1:50 , 151:200 , :) = wint;
board(1:50 , 201:250 , :) = wint;
board(1:50 , 251:300 , :) = wint;
board(1:50 , 301:350 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,1)==22 & game(5,1)==22 & game(4,1)==22 & game(3,1)==22)
pause(1);
board(251:300 , 1:50 , :) = wint;
board(201:250 , 1:50 , :) = wint;
board(151:200 , 1:50 , :) = wint;
board(101:150 , 1:50 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,1)==22 & game(4,1)==22 & game(3,1)==22 & game(2,1)==22)
pause(1);
board(201:250 , 1:50 , :) = wint;
board(151:200 , 1:50 , :) = wint;
board(101:150 , 1:50 , :) = wint;
board(51:100 , 1:50 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,1)==22 & game(3,1)==22 & game(2,1)==22 & game(1,1)==22)
pause(1);
board(151:200 , 1:50 , :) = wint;
board(101:150 , 1:50 , :) = wint;
board(51:100 , 1:50 , :) = wint;
board(1:50 , 1:50 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,2)==22 & game(5,2)==22 & game(4,2)==22 & game(3,2)==22)
pause(1);
board(251:300 , 51:100 , :) = wint;
board(201:250 , 51:100 , :) = wint;
board(151:200 , 51:100 , :) = wint;
board(101:150 , 51:100 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,2)==22 & game(4,2)==22 & game(3,2)==22 & game(2,2)==22)
pause(1);
board(201:250 , 51:100 , :) = wint;
board(151:200 , 51:100 , :) = wint;
board(101:150 , 51:100 , :) = wint;
board(51:100 , 51:100 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,2)==22 & game(3,2)==22 & game(2,2)==22 & game(1,2)==22)
pause(1);
board(151:200 , 51:100 , :) = wint;
board(101:150 , 51:100 , :) = wint;
board(51:100 , 51:100 , :) = wint;
board(1:50 , 51:100 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,3)==22 & game(5,3)==22 & game(4,3)==22 & game(3,3)==22)
pause(1);
board(251:300 , 101:150 , :) = wint;
board(201:250 , 101:150 , :) = wint;
board(151:200 , 101:150 , :) = wint;
board(101:150 , 101:150 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,3)==22 & game(4,3)==22 & game(3,3)==22 & game(2,3)==22)
pause(1);
board(201:250 , 101:150 , :) = wint;
board(151:200 , 101:150 , :) = wint;
board(101:150 , 101:150 , :) = wint;
board(51:100 , 101:150 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,3)==22 & game(3,3)==22 & game(2,3)==22 & game(1,3)==22)
pause(1);
board(151:200 , 101:150 , :) = wint;
board(101:150 , 101:150 , :) = wint;
board(51:100 , 101:150 , :) = wint;
board(1:50 , 101:150 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,4)==22 & game(5,4)==22 & game(4,4)==22 & game(3,4)==22)
pause(1);
board(251:300 , 151:200 , :) = wint;
board(201:250 , 151:200 , :) = wint;
board(151:200 , 151:200 , :) = wint;
board(101:150 , 151:200 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,4)==22 & game(4,4)==22 & game(3,4)==22 & game(2,4)==22)
pause(1);
board(201:250 , 151:200 , :) = wint;
board(151:200 , 151:200 , :) = wint;
board(101:150 , 151:200 , :) = wint;
board(51:100 , 151:200 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,4)==22 & game(3,4)==22 & game(2,4)==22 & game(1,4)==22)
pause(1);
board(151:200 , 151:200 , :) = wint;
board(101:150 , 151:200 , :) = wint;
board(51:100 , 151:200 , :) = wint;
board(1:50 , 151:200 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,5)==22 & game(5,5)==22 & game(4,5)==22 & game(3,5)==22)
pause(1);
board(251:300 , 201:250 , :) = wint;
board(201:250 , 201:250 , :) = wint;
board(151:200 , 201:250 , :) = wint;
board(101:150 , 201:250 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,5)==22 & game(4,5)==22 & game(3,5)==22 & game(2,5)==22)
pause(1);
board(201:250 , 201:250 , :) = wint;
board(151:200 , 201:250 , :) = wint;
board(101:150 , 201:250 , :) = wint;
board(51:100 , 201:250 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,5)==22 & game(3,5)==22 & game(2,5)==22 & game(1,5)==22)
pause(1);
board(151:200 , 201:250 , :) = wint;
board(101:150 , 201:250 , :) = wint;
board(51:100 , 201:250 , :) = wint;
board(1:50 , 201:250 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,6)==22 & game(5,6)==22 & game(4,6)==22 & game(3,6)==22)
pause(1);
board(251:300 , 251:300 , :) = wint;
board(201:250 , 251:300 , :) = wint;
board(151:200 , 251:300 , :) = wint;
board(101:150 , 251:300 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,6)==22 & game(4,6)==22 & game(3,6)==22 & game(2,6)==22)
pause(1);
board(201:250 , 251:300 , :) = wint;
board(151:200 , 251:300 , :) = wint;
board(101:150 , 251:300 , :) = wint;
board(51:100 , 251:300 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,6)==22 & game(3,6)==22 & game(2,6)==22 & game(1,6)==22)
pause(1);
board(151:200 , 251:300 , :) = wint;
board(101:150 , 251:300 , :) = wint;
board(51:100 , 251:300 , :) = wint;
board(1:50 , 251:300 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,7)==22 & game(5,7)==22 & game(4,7)==22 & game(3,7)==22)
pause(1);
board(251:300 , 301:350 , :) = wint;
board(201:250 , 301:350 , :) = wint;
board(151:200 , 301:350 , :) = wint;
board(101:150 , 301:350 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,7)==22 & game(4,7)==22 & game(3,7)==22 & game(2,7)==22)
pause(1);
board(201:250 , 301:350 , :) = wint;
board(151:200 , 301:350 , :) = wint;
board(101:150 , 301:350 , :) = wint;
board(51:100 , 301:350 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,7)==22 & game(3,7)==22 & game(2,7)==22 & game(1,7)==22)
pause(1);
board(151:200 , 301:350 , :) = wint;
board(101:150 , 301:350 , :) = wint;
board(51:100 , 301:350 , :) = wint;
board(1:50 , 301:350 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,4)==22 & game(5,5)==22 & game(4,6)==22 & game(3,7)==22)
pause(1);
board(251:300 , 151:200 , :) = wint;
board(201:250 , 201:250 , :) = wint;
board(151:200 , 251:300 , :) = wint;
board(101:150 , 301:350 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,4)==22 & game(4,5)==22 & game(3,6)==22 & game(2,7)==22)
pause(1);
board(201:250 , 151:200 , :) = wint;
board(151:200 , 201:250 , :) = wint;
board(101:150 , 251:300 , :) = wint;
board(51:100 , 301:350 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,4)==22 & game(3,5)==22 & game(2,6)==22 & game(1,7)==22)
pause(1);
board(151:200 , 151:200 , :) = wint;
board(101:150 , 201:250 , :) = wint;
board(51:100 , 251:300 , :) = wint;
board(1:50 , 301:350 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,3)==22 & game(5,4)==22 & game(4,5)==22 & game(3,6)==22)
pause(1);
board(251:300 , 101:150 , :) = wint;
board(201:250 , 151:200 , :) = wint;
board(151:200 , 201:250 , :) = wint;
board(101:150 , 251:300 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,3)==22 & game(4,4)==22 & game(3,5)==22 & game(2,6)==22)
pause(1);
board(201:250 , 101:150 , :) = wint;
board(151:200 , 151:200 , :) = wint;
board(101:150 , 201:250 , :) = wint;
board(51:100 , 251:300 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,3)==22 & game(3,4)==22 & game(2,5)==22 & game(1,6)==22)
pause(1);
board(151:200 , 101:150 , :) = wint;
board(101:150 , 151:200 , :) = wint;
board(51:100 , 201:250 , :) = wint;
board(1:50 , 251:300 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,2)==22 & game(5,3)==22 & game(4,4)==22 & game(3,5)==22)
pause(1);
board(251:300 , 51:100 , :) = wint;
board(201:250 , 101:150 , :) = wint;
board(151:200 , 151:200 , :) = wint;
board(101:150 , 201:250 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,2)==22 & game(4,3)==22 & game(3,4)==22 & game(2,5)==22)
pause(1);
board(201:250 , 51:100 , :) = wint;
board(151:200 , 101:150 , :) = wint;
board(101:150 , 151:200 , :) = wint;
board(51:100 , 201:250 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,2)==22 & game(3,3)==22 & game(2,4)==22 & game(1,5)==22)
pause(1);
board(151:200 , 51:100 , :) = wint;
board(101:150 , 101:150 , :) = wint;
board(51:100 , 151:200 , :) = wint;
board(1:50 , 201:250 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,1)==22 & game(5,2)==22 & game(4,3)==22 & game(3,4)==22)
pause(1);
board(251:300 , 1:50 , :) = wint;
board(201:250 , 51:100 , :) = wint;
board(151:200 , 101:150 , :) = wint;
board(101:150 , 151:200 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,1)==22 & game(4,2)==22 & game(3,3)==22 & game(2,4)==22)
pause(1);
board(201:250 , 1:50 , :) = wint;
board(151:200 , 51:100 , :) = wint;
board(101:150 , 101:150 , :) = wint;
board(51:100 , 151:200 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,1)==22 & game(3,2)==22 & game(2,3)==22 & game(1,4)==22)
pause(1);
board(151:200 , 1:50 , :) = wint;
board(101:150 , 51:100 , :) = wint;
board(51:100 , 101:150 , :) = wint;
board(1:50 , 151:200 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,4)==22 & game(5,3)==22 & game(4,2)==22 & game(3,1)==22)
pause(1);
board(251:300 , 151:200 , :) = wint;
board(201:250 , 101:150 , :) = wint;
board(151:200 , 51:100 , :) = wint;
board(101:150 , 1:50 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,4)==22 & game(4,3)==22 & game(3,2)==22 & game(2,1)==22)
pause(1);
board(201:250 , 151:200 , :) = wint;
board(151:200 , 101:150 , :) = wint;
board(101:150 , 51:100 , :) = wint;
board(51:100 , 1:50 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,4)==22 & game(3,3)==22 & game(2,2)==22 & game(1,1)==22)
pause(1);
board(151:200 , 151:200 , :) = wint;
board(101:150 , 101:150 , :) = wint;
board(51:100 , 51:100 , :) = wint;
board(1:50 , 1:50 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,5)==22 & game(5,4)==22 & game(4,3)==22 & game(3,2)==22)
pause(1);
board(251:300 , 201:250 , :) = wint;
board(201:250 , 151:200 , :) = wint;
board(151:200 , 101:150 , :) = wint;
board(101:150 , 51:100 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,5)==22 & game(4,4)==22 & game(3,3)==22 & game(2,2)==22)
pause(1);
board(201:250 , 201:250 , :) = wint;
board(151:200 , 151:200 , :) = wint;
board(101:150 , 101:150 , :) = wint;
board(51:100 , 51:100 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,5)==22 & game(3,4)==22 & game(2,3)==22 & game(1,2)==22)
pause(1);
board(151:200 , 201:250 , :) = wint;
board(101:150 , 151:200 , :) = wint;
board(51:100 , 101:150 , :) = wint;
board(1:50 , 51:100 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,6)==22 & game(5,5)==22 & game(4,4)==22 & game(3,3)==22)
pause(1);
board(251:300 , 251:300 , :) = wint;
board(201:250 , 201:250 , :) = wint;
board(151:200 , 151:200 , :) = wint;
board(101:150 , 101:150 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,6)==22 & game(4,5)==22 & game(3,4)==22 & game(2,3)==22)
pause(1);
board(201:250 , 251:300 , :) = wint;
board(151:200 , 201:250 , :) = wint;
board(101:150 , 151:200 , :) = wint;
board(51:100 , 101:150 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,6)==22 & game(3,5)==22 & game(2,4)==22 & game(1,3)==22)
pause(1);
board(151:200 , 251:300 , :) = wint;
board(101:150 , 201:250 , :) = wint;
board(51:100 , 151:200 , :) = wint;
board(1:50 , 101:150 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(6,7)==22 & game(5,6)==22 & game(4,5)==22 & game(3,4)==22)
pause(1);
board(251:300 , 301:350 , :) = wint;
board(201:250 , 251:300 , :) = wint;
board(151:200 , 201:250 , :) = wint;
board(101:150 , 151:200 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(5,7)==22 & game(4,6)==22 & game(3,5)==22 & game(2,4)==22)
pause(1);
board(201:250 , 301:350 , :) = wint;
board(151:200 , 251:300 , :) = wint;
board(101:150 , 201:250 , :) = wint;
board(51:100 , 151:200 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
if (game(4,7)==22 & game(3,6)==22 & game(2,5)==22 & game(1,4)==22)
pause(1);
board(151:200 , 301:350 , :) = wint;
board(101:150 , 251:300 , :) = wint;
board(51:100 , 201:250 , :) = wint;
board(1:50 , 151:200 , :) = wint;
imshow(board)
a = title(con2);
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color','y')
sound(winning,y,z)
pause(6)
close
break;
end
% End of Player 2 Turn
% Check for No Winner Condition
if (all(game) == 1)
pause(1);
a = title('** NO WINNER **');
set(a,'FontSize',18)
set(a,'FontWeight','bold')
set(a,'Color',[0.5 0 0.5])
toot2
sound(hit,b,c)
sound(hit,b,c)
sound(hit,b,c)
pause(6)
close
break;
end
% End of One Round
end
% End of Program
fprintf('\n\n\n Thank You for using this Program')
fprintf('\n Programmed by MINA AYMAN')
fprintf('\n Questions or Comments : e-mail ( mina_ayman@yahoo.com )\n')
clear
% Sound Function
function adum2 = toot2()
% Whistle Generator Program
t = 0 : 1/2000 : 1;
sig = 0.7 * chirp(t,0,0.3,10000);
sound(sig,2000,8)