%
% -- M a t r i x P o k e r --
% easy intellectual entertainment
% for MATLAB users.
%
% Matrix Poker is a combination of hazard and
% combinatorial thinking. The game consists in
% filling the game board with random numbers
% (from 1 up to 13) to get a maximum score by
% forming premium combinations in rows, columns,
% and on two diagonals.
%
% 1. HOW TO PLAY
% --------------
% To start the game, run MATPOKER.M. You will
% see 25 empty green cells surrounded by 24
% gray cells. Above them there are three
% buttons ("New", "Count", "Help"), and a
% green cell with a random number between 1 and
% 13.
%
% Look at that number in the upper-left corner
% of the game window and click on an empty cell
% to place the number. Repeat this step until
% all green cells are filled by numbers, and
% try to create as many premium combinations as
% possible. After filling all cells, click on
% "Count" button to see your score. The
% abbreviations of formed premium conbinations,
% and their values will appear in surrounding
% gray cells.
%
% To see the rules and the table of premium
% combinations in your default web browser,
% click on "Help" button.
%
% To start a new game, click on "New".
%
% 2. THE NAME OF THE GAME
% -----------------------
% Indeed, it is poker, and premium combinations
% are called "pairs", "triplets", "full house",
% and so forth...
%
% 3. THE PREDECESSOR
% ------------------
% Matrix Poker is a variation of the old game
% called Matematico, which is described in:
% Zapletal, M.: Encyklopedie her,
% Olympia, Prague, 1975 (in Czech).
%
% 4. AUTHORS
% -----------
% (C) 2002-2003, Igor Podlubny, Peter Konecny.
% Technical University of Kosice, BERG Faculty,
% Department of Applied Informatics and Process Control.
%
% E-mail: igor.podlubny@tuke.sk
% peter.konecny@email.cz
% Web page: http://www.tuke.sk/podlubny/
%
%
% CHANGES:
% --------
% September 22, 2003:
% Slightly updated to work with Matlab R11, R12, and R13
% (it was reported that there were problems under R13).
function matpoker(action)
global scrambled_cards Step M
if nargin<1
action='initialize';
end
switch action
case 'initialize';
set(0,'Units','points');
screen_dim=get(0,'ScreenSize');
bl=screen_dim(3)/2 - 105;
bb=screen_dim(4)/2 - 120;
M=NaN*zeros(5,5);
cards = [randperm(13),randperm(13),randperm(13),randperm(13)];
index = randperm(52);
scrambled_cards=cards(index);
Step=1;
figure_h=figure('Units','points', ...
'Color',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'MenuBar','none', ...
'Name','Matrix Poker', ...
'NumberTitle','off', ...
'PaperPosition',[18 180 576 432], ...
'PaperType','A4', ...
'PaperUnits','points', ...
'Position',[bl bb 211 240], ...
'RendererMode','manual', ...
'Resize','off', ...
'Tag','Fig1');
a11 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0 0.501960784313725 0.250980392156863], ...
'Callback','matpoker GetCard', ...
'FontSize',12, ...
'FontWeight','demi', ...
'ForegroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[30.75 150 30 30], ...
'Style','togglebutton', ...
'Tag','a11', ...
'Value',1);
a12 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0 0.501960784313725 0.250980392156863], ...
'Callback','matpoker GetCard', ...
'FontSize',12, ...
'FontWeight','demi', ...
'ForegroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[60.75 150 30 30], ...
'Style','togglebutton', ...
'Tag','a12', ...
'Value',1);
a13 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0 0.501960784313725 0.250980392156863], ...
'Callback','matpoker GetCard', ...
'FontSize',12, ...
'FontWeight','demi', ...
'ForegroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[90.75 150 30 30], ...
'Style','togglebutton', ...
'Tag','a13', ...
'Value',1);
a14 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0 0.501960784313725 0.250980392156863], ...
'Callback','matpoker GetCard', ...
'FontSize',12, ...
'FontWeight','demi', ...
'ForegroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[120.75 150 30 30], ...
'Style','togglebutton', ...
'Tag','a14', ...
'Value',1);
a15 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0 0.501960784313725 0.250980392156863], ...
'Callback','matpoker GetCard', ...
'FontSize',12, ...
'FontWeight','demi', ...
'ForegroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[150.75 150 30 30], ...
'Style','togglebutton', ...
'Tag','a15', ...
'Value',1);
a21 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0 0.501960784313725 0.250980392156863], ...
'Callback','matpoker GetCard', ...
'FontSize',12, ...
'FontWeight','demi', ...
'ForegroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[30.75 120 30 30], ...
'Style','togglebutton', ...
'Tag','a21', ...
'Value',1);
a22 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0 0.501960784313725 0.250980392156863], ...
'Callback','matpoker GetCard', ...
'FontSize',12, ...
'FontWeight','demi', ...
'ForegroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[60.75 120 30 30], ...
'Style','togglebutton', ...
'Tag','a22', ...
'Value',1);
a23 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0 0.501960784313725 0.250980392156863], ...
'Callback','matpoker GetCard', ...
'FontSize',12, ...
'FontWeight','demi', ...
'ForegroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[90.75 120 30 30], ...
'Style','togglebutton', ...
'Tag','a23', ...
'Value',1);
a24 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0 0.501960784313725 0.250980392156863], ...
'Callback','matpoker GetCard', ...
'FontSize',12, ...
'FontWeight','demi', ...
'ForegroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[120.75 120 30 30], ...
'Style','togglebutton', ...
'Tag','a24', ...
'Value',1);
a25 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0 0.501960784313725 0.250980392156863], ...
'Callback','matpoker GetCard', ...
'FontSize',12, ...
'FontWeight','demi', ...
'ForegroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[150.75 120 30 30], ...
'Style','togglebutton', ...
'Tag','a25', ...
'Value',1);
a31 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0 0.501960784313725 0.250980392156863], ...
'Callback','matpoker GetCard', ...
'FontSize',12, ...
'FontWeight','demi', ...
'ForegroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[30.75 90 30 30], ...
'Style','togglebutton', ...
'Tag','a31', ...
'Value',1);
a32 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0 0.501960784313725 0.250980392156863], ...
'Callback','matpoker GetCard', ...
'FontSize',12, ...
'FontWeight','demi', ...
'ForegroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[60.75 90 30 30], ...
'Style','togglebutton', ...
'Tag','a32', ...
'Value',1);
a33 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0 0.501960784313725 0.250980392156863], ...
'Callback','matpoker GetCard', ...
'FontSize',12, ...
'FontWeight','demi', ...
'ForegroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[90.75 90 30 30], ...
'Style','togglebutton', ...
'Tag','a33', ...
'Value',1);
a34 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0 0.501960784313725 0.250980392156863], ...
'Callback','matpoker GetCard', ...
'FontSize',12, ...
'FontWeight','demi', ...
'ForegroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[120.75 90 30 30], ...
'Style','togglebutton', ...
'Tag','a34', ...
'Value',1);
a35 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0 0.501960784313725 0.250980392156863], ...
'Callback','matpoker GetCard', ...
'FontSize',12, ...
'FontWeight','demi', ...
'ForegroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[150.75 90 30 30], ...
'Style','togglebutton', ...
'Tag','a35', ...
'Value',1);
a41 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0 0.501960784313725 0.250980392156863], ...
'Callback','matpoker GetCard', ...
'FontSize',12, ...
'FontWeight','demi', ...
'ForegroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[30.75 60 30 30], ...
'Style','togglebutton', ...
'Tag','a41', ...
'Value',1);
a42 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0 0.501960784313725 0.250980392156863], ...
'Callback','matpoker GetCard', ...
'FontSize',12, ...
'FontWeight','demi', ...
'ForegroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[60.75 60 30 30], ...
'Style','togglebutton', ...
'Tag','a42', ...
'Value',1);
a43 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0 0.501960784313725 0.250980392156863], ...
'Callback','matpoker GetCard', ...
'FontSize',12, ...
'FontWeight','demi', ...
'ForegroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[90.75 60 30 30], ...
'Style','togglebutton', ...
'Tag','a43', ...
'Value',1);
a44 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0 0.501960784313725 0.250980392156863], ...
'Callback','matpoker GetCard', ...
'FontSize',12, ...
'FontWeight','demi', ...
'ForegroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[120.75 60 30 30], ...
'Style','togglebutton', ...
'Tag','a44', ...
'Value',1);
a45 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0 0.501960784313725 0.250980392156863], ...
'Callback','matpoker GetCard', ...
'FontSize',12, ...
'FontWeight','demi', ...
'ForegroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[150.75 60 30 30], ...
'Style','togglebutton', ...
'Tag','a45', ...
'Value',1);
a51 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0 0.501960784313725 0.250980392156863], ...
'Callback','matpoker GetCard', ...
'FontSize',12, ...
'FontWeight','demi', ...
'ForegroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[30.75 30 30 30], ...
'Style','togglebutton', ...
'Tag','a51', ...
'Value',1);
a52 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0 0.501960784313725 0.250980392156863], ...
'Callback','matpoker GetCard', ...
'FontSize',12, ...
'FontWeight','demi', ...
'ForegroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[60.75 30 30 30], ...
'Style','togglebutton', ...
'Tag','a52', ...
'Value',1);
a53 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0 0.501960784313725 0.250980392156863], ...
'Callback','matpoker GetCard', ...
'FontSize',12, ...
'FontWeight','demi', ...
'ForegroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[90.75 30 30 30], ...
'Style','togglebutton', ...
'Tag','a53', ...
'Value',1);
a54 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0 0.501960784313725 0.250980392156863], ...
'Callback','matpoker GetCard', ...
'FontSize',12, ...
'FontWeight','demi', ...
'ForegroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[120.75 30 30 30], ...
'Style','togglebutton', ...
'Tag','a54', ...
'Value',1);
a55 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0 0.501960784313725 0.250980392156863], ...
'Callback','matpoker GetCard', ...
'FontSize',12, ...
'FontWeight','demi', ...
'ForegroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[150.75 30 30 30], ...
'Style','togglebutton', ...
'Tag','a55', ...
'Value',1);
actual_card = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0 0.501960784313725 0.250980392156863], ...
'FontSize',12, ...
'FontWeight','demi', ...
'ForegroundColor',[1 1 1], ...
'ListboxTop',0, ...
'Position',[0.75 210 30 30], ...
'String',num2str(scrambled_cards(1)), ...
'Tag','NumberToPoke');
r1 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[180.75 150 30 30], ...
'Tag','Row1');
r2 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[180.75 120 30 30], ...
'Tag','Row2');
r3 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[180.75 90 30 30], ...
'Tag','Row3');
r4 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[180.75 60 30 30], ...
'Tag','Row4');
r5 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[180.75 30 30 30], ...
'Tag','Row5');
Row5Desk = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[0.75 30 30 30], ...
'Tag','Row5desc');
Row4Desk = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[0.75 60 30 30], ...
'Tag','Row4desc');
Row3Desk = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[0.75 90 30 30], ...
'Tag','Row3desc');
Row2Desk = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[0.75 120 30 30], ...
'Tag','Row2desc');
Row1Desk = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[0.75 150 30 30], ...
'Tag','Row1desc');
%setup the col of the frame
c1 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[30.75 0 30 30], ...
'Tag','Col1');
c2 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[60.75 0 30 30], ...
'Tag','Col2');
c3 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[90.75 0 30 30], ...
'Tag','Col3');
c4 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[120.75 0 30 30], ...
'Tag','Col4');
c5 = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[150.75 0 30 30], ...
'Tag','Col5');
Col5Desk = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[150.75 180 30 30], ...
'Tag','Col5desc');
Col4Desk = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[120.75 180 30 30], ...
'Tag','Col4desc');
Col3Desk = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[90.75 180 30 30], ...
'Tag','Col3desc');
Col2Desk = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[60.75 180 30 30], ...
'Tag','Col2desc');
Col1Desk = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[30.75 180 30 30], ...
'Tag','Col1desc');
second_diag = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[180.75 180 30 30], ...
'Tag','SecondDiag');
secDiagDesc = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[0.75 0 30 30], ...
'Tag','SecondDiagDesc');
main_diag = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[180.75 0 30 30], ...
'Tag','MainDiag');
MainDiagDesk = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'ListboxTop',0, ...
'Position',[0.75 180 30 30], ...
'Tag','MainDiagDesc');
new = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'Callback','close ''Matrix Poker''; clear all; matpoker', ...
'FontSize',12, ...
'FontWeight','demi', ...
'ListboxTop',0, ...
'Position',[30.75 210 60 30], ...
'String','New', ...
'Tag','NewGame');
count = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'Callback','matpoker count', ...
'FontSize',12, ...
'FontWeight','demi', ...
'ListboxTop',0, ...
'Position',[90.75 210 60 30], ...
'String','Count', ...
'Tag','Count');
rules = uicontrol(figure_h, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'Callback','matpoker rules', ...
'FontSize',12, ...
'FontWeight','demi', ...
'ListboxTop',0, ...
'Position',[150.75 210 60 30], ...
'String','Help', ...
'Tag','Rules');
case 'rules'
web(['file:///' which('mphelp.htm')]);
case 'GetCard'
CurrentObj=gcbo;
if get(CurrentObj,'Value') == 0
if Step > 25
set(findobj('tag','NumberToPoke'),'String', '','BackgroundColor', [0.8 0 0])
NextCard=get(CurrentObj,'String');
else
NextCard=scrambled_cards(Step);
set(CurrentObj,'string',num2str(scrambled_cards(Step)));
Step=Step+1;
if Step > 25
set(findobj('tag','NumberToPoke'),'String', '','BackgroundColor', [0.8 0 0])
else
set(findobj('tag','NumberToPoke'),'String', num2str(scrambled_cards(Step)))
end
end
else
NextCard=str2num(get(CurrentObj,'String'));
set(CurrentObj,'Value',0);
end
if Step>25
M(1,1)=str2num(get(findobj('Tag','a11'),'String'));
M(1,2)=str2num(get(findobj('Tag','a12'),'String'));
M(1,3)=str2num(get(findobj('Tag','a13'),'String'));
M(1,4)=str2num(get(findobj('Tag','a14'),'String'));
M(1,5)=str2num(get(findobj('Tag','a15'),'String'));
M(2,1)=str2num(get(findobj('Tag','a21'),'String'));
M(2,2)=str2num(get(findobj('Tag','a22'),'String'));
M(2,3)=str2num(get(findobj('Tag','a23'),'String'));
M(2,4)=str2num(get(findobj('Tag','a24'),'String'));
M(2,5)=str2num(get(findobj('Tag','a25'),'String'));
M(3,1)=str2num(get(findobj('Tag','a31'),'String'));
M(3,2)=str2num(get(findobj('Tag','a32'),'String'));
M(3,3)=str2num(get(findobj('Tag','a33'),'String'));
M(3,4)=str2num(get(findobj('Tag','a34'),'String'));
M(3,5)=str2num(get(findobj('Tag','a35'),'String'));
M(4,1)=str2num(get(findobj('Tag','a41'),'String'));
M(4,2)=str2num(get(findobj('Tag','a42'),'String'));
M(4,3)=str2num(get(findobj('Tag','a43'),'String'));
M(4,4)=str2num(get(findobj('Tag','a44'),'String'));
M(4,5)=str2num(get(findobj('Tag','a45'),'String'));
M(5,1)=str2num(get(findobj('Tag','a51'),'String'));
M(5,2)=str2num(get(findobj('Tag','a52'),'String'));
M(5,3)=str2num(get(findobj('Tag','a53'),'String'));
M(5,4)=str2num(get(findobj('Tag','a54'),'String'));
M(5,5)=str2num(get(findobj('Tag','a55'),'String'));
end
case 'count'
if Step>25
if prod(M(:)) == 0
else
diagonal=0;
[RowCom1,R1]=five(M(1,:),diagonal);
[RowCom2,R2]=five(M(2,:),diagonal);
[RowCom3,R3]=five(M(3,:),diagonal);
[RowCom4,R4]=five(M(4,:),diagonal);
[RowCom5,R5]=five(M(5,:),diagonal);
set(findobj('tag','Row1desc'),'String', RowCom1, 'Foreground', 'white', 'FontWeight', 'demi')
set(findobj('tag','Row2desc'),'String', RowCom2, 'Foreground', 'white', 'FontWeight', 'demi')
set(findobj('tag','Row3desc'),'String', RowCom3, 'Foreground', 'white', 'FontWeight', 'demi')
set(findobj('tag','Row4desc'),'String', RowCom4, 'Foreground', 'white', 'FontWeight', 'demi')
set(findobj('tag','Row5desc'),'String', RowCom5, 'Foreground', 'white', 'FontWeight', 'demi')
set(findobj('tag','Row1'),'String', num2str(R1), 'Foreground', 'red', 'FontWeight', 'demi')
set(findobj('tag','Row2'),'String', num2str(R2), 'Foreground', 'red', 'FontWeight', 'demi')
set(findobj('tag','Row3'),'String', num2str(R3), 'Foreground', 'red', 'FontWeight', 'demi')
set(findobj('tag','Row4'),'String', num2str(R4), 'Foreground', 'red', 'FontWeight', 'demi')
set(findobj('tag','Row5'),'String', num2str(R5), 'Foreground', 'red', 'FontWeight', 'demi')
diagonal=0;
[ColCom1,C1]=five(M(:,1)',diagonal);
[ColCom2,C2]=five(M(:,2)',diagonal);
[ColCom3,C3]=five(M(:,3)',diagonal);
[ColCom4,C4]=five(M(:,4)',diagonal);
[ColCom5,C5]=five(M(:,5)',diagonal);
set(findobj('tag','Col1desc'),'String', ColCom1, 'Foreground', 'white', 'FontWeight', 'demi')
set(findobj('tag','Col2desc'),'String', ColCom2, 'Foreground', 'white', 'FontWeight', 'demi')
set(findobj('tag','Col3desc'),'String', ColCom3, 'Foreground', 'white', 'FontWeight', 'demi')
set(findobj('tag','Col4desc'),'String', ColCom4, 'Foreground', 'white', 'FontWeight', 'demi')
set(findobj('tag','Col5desc'),'String', ColCom5, 'Foreground', 'white', 'FontWeight', 'demi')
set(findobj('tag','Col1'),'String', num2str(C1), 'Foreground', 'red', 'FontWeight', 'demi')
set(findobj('tag','Col2'),'String', num2str(C2), 'Foreground', 'red', 'FontWeight', 'demi')
set(findobj('tag','Col3'),'String', num2str(C3), 'Foreground', 'red', 'FontWeight', 'demi')
set(findobj('tag','Col4'),'String', num2str(C4), 'Foreground', 'red', 'FontWeight', 'demi')
set(findobj('tag','Col5'),'String', num2str(C5), 'Foreground', 'red', 'FontWeight', 'demi')
diagonal=1;
[DiagCom1,D1]=five(diag(M)',diagonal);
[DiagCom2,D2]=five(diag(fliplr(M))',diagonal);
set(findobj('tag','MainDiagDesc'),'String', DiagCom1, 'Foreground', 'white', 'FontWeight', 'demi')
set(findobj('tag','SecondDiagDesc'),'String', DiagCom2, 'Foreground', 'white', 'FontWeight', 'demi')
set(findobj('tag','MainDiag'),'String', num2str(D1), 'Foreground', 'red', 'FontWeight', 'demi')
set(findobj('tag','SecondDiag'),'String', num2str(D2), 'Foreground', 'red', 'FontWeight', 'demi')
TotalAward = sum([R1 R2 R3 R4 R5 C1 C2 C3 C4 C5 D1 D2]);
set(findobj('tag','Count'),'String', num2str(TotalAward))
end
end
end
function [combination,award]=five(x,diagonal)
x0=x;
x=sort(x);
Straight='S';
Broadway='B';
FullHouse='FH';
FullHousePremium='FH1';
Quads='Q';
Quads1='Q1';
Triplet='T';
DoublePair='DP';
Pair='P';
Nothing='';
StraightValue=50;
BroadwayValue=150;
FullHouseValue=80;
FullHousePremiumValue=100;
QuadsValue=160;
Quads1Value=200;
TripletValue=40;
DoublePairValue=20;
PairValue=10;
NothingValue=0;
DiagPremium = 10;
if diff(x)==[1 1 1 1]
combination=Straight;
award=StraightValue;
else
if diff(x)==[9 1 1 1]
combination=Broadway;
award=BroadwayValue;
else
if diff(x) == [0 0 12 0]
combination=FullHousePremium;
award=FullHousePremiumValue;
else
y=diff(x);
if prod(double(y(1:3)==0))==1 | prod(double(y(2:4)==0))==1
if prod(double(x(1:4)==[1 1 1 1]))==1
combination=Quads1;
award=Quads1Value;
else
combination=Quads;
award=QuadsValue;
end
else
y=sort(diff(x));
if sum(y(1:3))==0
combination=FullHouse;
award=FullHouseValue;
else
if sum(y(1:2))==0
if (sum(double(x==x(1)))==3) | (sum(double(x==x(2)))==3) | (sum(double(x==x(3)))==3)
combination=Triplet;
award=TripletValue;
else
combination=DoublePair;
award=DoublePairValue;
end
else
y=sort(y);
if y(1)==0 & ~(y(1)==y(2))
combination=Pair;
award=PairValue;
else
combination = Nothing;
award=NothingValue;
end
end
end
end
end
end
end
if diagonal==1 & ~(award==NothingValue)
award=award+DiagPremium;
end