image thumbnail
from POKER PREDICTOR by Luigi Giaccari
A Texas Hold'em Poker Probability and Odds calculator. Fast, accurate and free.

PokerPredictor(varargin)
function PokerPredictor(varargin)
%% Cose da fare

%menu (nel menu inserire istruzioni e link utili);
%demo file con tabella
%colorazione testo differenziale nelle statistiche
%migliorare la cosiderazione dei folds
%colorare il numero di vittorie in rapporto al numero di player
%colorazione tie in rapporto a quella della vittoria

%% Poker Predictor
%Inset here h-line


fprintf('\n')
fprintf('\n')
disp('This work is free thanks to our sponsors and users graditude:')
fprintf('\n')
disp('<a href="http://www.wordans.com/affiliates/?s=2664&amp;a=904">-WORDANS: Make you own T-Shirt</a>')	
fprintf('\n')
disp('<a href="http://www.odicy.com/affiliates/?s=2662&amp;a=903">-ODICY: affordable luxury made easy</a>')
fprintf('\n')
disp('<a href="http://www.gigasize.com/affiliates/?s=2665&amp;a=902">-GIGASIZE: the easiest way to upload and share files</a>')
fprintf('\n')
disp('<a href="http://www.advancedmcode.org/">-Advanced M-code</a>')
fprintf('\n')
disp('<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8412682">-Donate </a>')
fprintf('\n')
disp('Thank you!')




%% Presentation
PresentationFun();

%% Important variables

%game
NumPlayers=10;%numbers of players
NumFolds=0;%number of folds
NumSimulations=100000;
KnownCards=-ones(NumPlayers*2+5,1);%known cards for the computational routine
Selected=false(52,1);%flag selcted cards
CurrentTableCard=1;

%statistics
PlayerHighRank=zeros(10,1);
OpponentHighRank=zeros(10,1);
WinTieOdd=zeros(3,1);


TablePtr=BuildTable();%load the look up table;

load CardsImages.mat%load Cdata
%Cards images are stored in CardsImages from 1 to 52
%elemement 53 is a Back of card(unknown cards)
%elemement 54 is an EmptyCard
%element 55 is selected table card(currently unused);

load JetColorMap100.mat CJet;%100 colors from blu to red

%% Drawing

%Size constants
MW=[0 0 320 600];%Main window
DC=[21,35];%Deck card width height
stepx=DC(1)+3;%cards spacing
stepy=DC(2)+3;

%assign properties to figure
PokerPredictorGUI=figure('name','PokerPredictor',...
    'units','pixels',...
    'numbertitle','off',...
    'menubar','none',...
    'color',[0 .5 .5],...
    'Position',MW,...
    'CloseRequestFcn',@PokerPredictor_CloseRequestFcn,...
    'MenuBar','none',...
    'Resize','off',...
    'Toolbar','none');


%% draw deck cards buttons
c=1;


DeckCard=zeros(52,1);

for j=1:13
    for i=1:4
        DeckCard(c)=uicontrol('style','pushbutton',...
            'units','pixels',...
            'position',[5+stepx*(j-1) MW(4)-DC(2)-5-stepy*(i-1) DC(1) DC(2)],...
            'UserData',c,...
            'CallBack',@DeckCardClick,...
            'Cdata',CardsImages{c});
        
        c=c+1;
    end
end




%draw  TableCards
%% Players cards
%in players cards userdata there is a 1x2 matrix:
%the first number is the known card id, the second is deck card id,
%-1 one for no card, a number in 1-52 range for others deck cards


teta=linspace(pi/2,2*pi+pi/2-1/5*pi,10);

%create an ellipse for cards position
C=[MW(1)+DC(1)*6.5,MW(2)+MW(4)-DC(2)*8];%ellipse center
a=DC(1)*6;%x semiaxis
b=DC(2)*2;%y semiaxis
step=DC(1)+3;%spacing between cards


%Green table
fc=2.7;%fattore di scala per i semiassi
pos=[C(1)-a*fc/2+DC(1),C(2)-b*fc/2+DC(2)/2,a*fc,b*fc];
rectangle('Position',pos,'Curvature',[1,1],...
          'FaceColor',[0 .5 0]);%verde scuro
set(gca,'units','pixels','position',pos);
  axis([pos(1),pos(1)+a*fc,pos(2),pos(2)+b*fc])
  axis off
  
  
  
TableCard=zeros(25,1);
c=1;
for i=1:10
    TableCard(c)=uicontrol('style','pushbutton',...
        'units','pixels',...
        'position',[C(1)+a*cos(teta(i)) C(2)+b*sin(teta(i)) DC(1) DC(2)],...
        'UserData',[c,-1],...
        'CallBack',@TableCardClick,...
        'Cdata',CardsImages{53},...
        'Selected','off',...
        'SelectionHighLight','on');
    c=c+1;
    TableCard(c)=uicontrol('style','pushbutton',...
        'units','pixels',...
        'position',[C(1)+a*cos(teta(i))+step C(2)+b*sin(teta(i)) DC(1) DC(2)],...
        'UserData',[c,-1],...
        'CallBack',@TableCardClick,...
        'Cdata',CardsImages{53},...
        'Selected','off',...
        'SelectionHighLight','on');
    c=c+1;
end


set(TableCard(1),'Selected','on');%all'inizio seleziona la currenttablecard

%draw Player text

uitext=uicontrol('style','text',...
    'units','pixels',...
    'position',[C(1) C(2)+50 45 15],...
    'fontsize',8,...
    'String','Player',...
     'Foregroundcolor',[1 1 1],...
    'Backgroundcolor',[0 .5 0],...
    'Fontweight','bold');


%% Flop cards
step=DC(1)+3;%spacing between cards
C(1)=C(1)-a*.6;%new center
C(2)=C(2)+10;%rise up a little
for i=1:3
    TableCard(c)=uicontrol('style','pushbutton',...
        'units','pixels',...
        'position',[C(1)+step*i C(2) DC(1) DC(2)],...
        'UserData',[c,-1],...
        'CallBack',@TableCardClick,...
        'Cdata',CardsImages{53},...
        'Selected','off',...
        'SelectionHighLight','on');
    c=c+1;
end

uitext=uicontrol('style','text',...
    'units','pixels',...
    'position',[C(1)+40 C(2)-20 45 15],...
    'fontsize',8,...
    'String','Flop',...
     'Foregroundcolor',[1 1 1],...
    'Backgroundcolor',[0 .5 0],...
    'FOntweight','bold');

%% Turn and river cards
step=DC(1)+10;%spacing between cards
for i=1:2
    TableCard(c)=uicontrol('style','pushbutton',...
        'units','pixels',...
        'position',[C(1)+step*(i+2.5) C(2) DC(1) DC(2)],...
        'UserData',[c,-1],...
        'CallBack',@TableCardClick,...
        'Cdata',CardsImages{53},...
        'Selected','off',...
        'SelectionHighLight','on');
    c=c+1;
end

uitext=uicontrol('style','text',...
    'units','pixels',...
    'position',[C(1)+step*3.2 C(2)-20 30 15],...
    'fontsize',8,...
    'String','Turn',...
     'Foregroundcolor',[1 1 1],...
    'Backgroundcolor',[0 .5 0],...
    'FOntweight','bold');

uitext=uicontrol('style','text',...
    'units','pixels',...
    'position',[C(1)+step*4.4 C(2)-20 30 15],...
    'fontsize',8,...
    'String','River',...
    'Foregroundcolor',[1 1 1],...
    'Backgroundcolor',[0 .5 0],...
    'FOntweight','bold');
       

%% Statistics Table
NR=10;%number of row
NC=3;%number of column
RowWidth=18;%larghezza riga(non esiste)
ColumnWidth=60;%larghezza colonna


%%Background colour
uicontrol('Style', 'frame',...
       'Position', [3 RowWidth-2  (NC)*ColumnWidth+3 (NR+2)*RowWidth+4],...
       'BackGroundColor', 'k');

StatTable=zeros(NR,NC);

Table.String=cell(NR,NC);
Table.String(:,1)={'Errors',...
    'High Card',...
    'Pair',...
    'Two Pair',...
    '3 of Kind',...
    'Straight',...
    'Flush',...
    'Full House',...
    '4 of Kind',...
    'Royal Flush'};
Table.String(:,2:3)={'0%'};

Table.Color=cell(NR,NC);
Table.Color(:,:)={[0 0 1]};

Table.Color(:,1)={[.2 .2 .2]};%colore sfondo prima colonna


for j=1:NC
    for i=1:NR
        pos=[MW(1)+5+(j-1)*ColumnWidth ,MW(2)+(NR-i+1)*RowWidth, ColumnWidth-2,RowWidth-2];
        StatTable(i,j)=uicontrol('Style','text',...
            'units','pixels',...
            'position',pos,...
            'BackGroundColor',Table.Color{i,j},...
            'string',Table.String{i,j}) ;
    end
end

set(StatTable(:,1),'ForegroundColor',[1 1 1]);%colore testo prima colonna

%Table title with no handle
pos=[MW(1)+5 ,MW(2)+(NR+1)*RowWidth, ColumnWidth*3-2,RowWidth*2];
uicontrol('Style','text',...
    'units','pixels',...
    'position',pos,...
    'BackGroundColor',[.2 .2 .2],...
    'string','             Higher  Ranks              Player vs Best Opponent',...
    'Fontsize',9,...
    'ForegroundColor',[1 1 1],...
    'fontweight','bold') ;


%% Number of Players/Folds Push buttons

PlayersAdd=uicontrol('style','pushbutton',...
    'units','pixels',...
    'position',[270 200 20 20],...
    'UserData',1,...
    'CallBack',@PlayersNumber,...
    'String','+',...
    'Backgroundcolor',[1 .5 0]);
PlayersRemove=uicontrol('style','pushbutton',...
    'units','pixels',...
    'position',[270 180 20 20],...
    'UserData',-1,...
    'CallBack',@PlayersNumber,...
     'String','-',...
    'Backgroundcolor',[1 .5 0]);
FoldAdd=uicontrol('style','pushbutton',...
    'units','pixels',...
    'position',[270 150 20 20],...
    'UserData',1,...
    'CallBack',@PlayersFold,...
     'String','+',...
    'Backgroundcolor',[1 .5 0]);
FoldRemove=uicontrol('style','pushbutton',...
    'units','pixels',...
    'position',[270 130 20 20],...
    'UserData',-1,...
    'CallBack',@PlayersFold,...
     'String','-',...
    'Backgroundcolor',[1 .5 0]);
NumPlayersText=uicontrol('Style','text',...
    'units','pixels',...
    'position',[200 185 60 25],...
    'Backgroundcolor',[.2 .2 .2],...
      'Foregroundcolor',[1 1 1],...
      'Fontweight','bold',...
    'string',[num2str(NumPlayers),' Players']) ;

NumFoldsText=uicontrol('Style','text',...
    'units','pixels',...
    'position',[200 135 60 25],...
    'Backgroundcolor',[.2 .2 .2],...
      'Foregroundcolor',[1 1 1],...
      'Fontweight','bold',...
    'string',[num2str(NumFolds),' Folds']) ;

%% Winning tie statistics
NR=5;
NC=2;
WinningStat=zeros(NR,NC);

WinningStatistics.Color=cell(NR,NC);
WinningStatistics.Color(:,:)={[1 0 1]};%initiate to purple

WinningStatistics.String=cell(NR,NC);
WinningStatistics.String(:,1)={'Win '...
    'Tie '...
    'Odd'...
    'MaxBet/ Pot',...
    'Profit'};
WinningStatistics.String(:,2)={'0%'};
Height=22;
Width=60;


%%Back ground colour
uicontrol('Style', 'frame',...
       'Position', [MW(1)+73+Width*NC 12  (NC)*Width+3 (NR)*Height+4],...
       'BackGroundColor', 'k');

for i=1:NR
    for j=1:NC
        pos=[MW(1)+135+Width*j,125-Height*i ,Width-2 ,Height-2];
        
        WinningStat(i,j)=uicontrol('Style','text',...
            'units','pixels',...
            'position',pos,...
            'BackGroundColor',WinningStatistics.Color{i,j},...
            'string',WinningStatistics.String{i,j});
    end
end


%% Clear Button
ClearButton=uicontrol('style','pushbutton',...
    'units','pixels',...
    'position',[260 240 50 25],...
    'UserData',1,...
    'CallBack',@Clear,...
    'String','Clear',...
    'Backgroundcolor',[1 .5 0],...
'Fontweight','bold');


%% Initiate
%first calculus with all unknown cards
%Recalculate with the new configuration
[ PlayerHighRank,OpponentHighRank,WinTieOdd]=GameSimulation...
    (KnownCards([1:NumPlayers*2,21:25]),NumPlayers,NumSimulations,TablePtr);
UpdateStat();




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Child functions starts here
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%




%% Clear
    function Clear(varargin)
        
        %loop trough all player cards if occupied make it empty
        set(TableCard(CurrentTableCard),'selected','off');
        for ii=25:-1:1%reverse order helps to set CurrentTableCard to one in the end
            Data=get(TableCard(ii),'UserData');%Set current table card
            CurrentTableCard=Data(1);
            
            CardId=Data(2);
            %if filled make it empty and re-fill deck cards
            if CardId>0
                set(DeckCard(CardId),'Cdata',CardsImages{CardId});%refill
                set(TableCard(ii),'Cdata',CardsImages{53},...
                    'selected','off' );%refill
                
            end
        end
        
        
        Selected(1:end)=false;
        KnownCards(1:end)=-1;
        NumFolds=0;
        set(NumFoldsText,'String',[num2str(NumFolds),' Folds']) ;
        set(TableCard(CurrentTableCard),'selected','on');
        %Recalculate with the new configuration
        [ PlayerHighRank,OpponentHighRank,WinTieOdd]=GameSimulation...
            (KnownCards([1:NumPlayers*2,21:25]),NumPlayers,NumSimulations,TablePtr);
        UpdateStat();
    end

%% PlayersFold
    function PlayersFold(varargin)
        h=gcbo;
        action=get(h,'Userdata');
        
        if (NumFolds==0 && action <0)|| (NumFolds>=NumPlayers-1 && action>0)
            return%do nothing players number is not correct
        end
        NumFolds=NumFolds+action;%increase decrease
        
        set(NumFoldsText,'String',[num2str(NumFolds),' Folds']);%replot strings
        
        %Update Statistics with the new Folds number
        UpdateStat();
        
    end

%% PlayersNumber
    function PlayersNumber(varargin)
        
        %extract plu or minus action
        h=gcbo;
        action=get(h,'Userdata');
        
        if (NumPlayers==2 && action <0)|| (NumPlayers==10 && action>0)
            return%do nothing players numer is not correct
        end
        NumPlayers=NumPlayers+action;%increase decrease
        
        set(NumPlayersText,'String',[num2str(NumPlayers),' Players']);%replot strings
        
        if NumFolds>NumPlayers-1%NUmber of folds can not be > NumPlayers -1
            NumFolds=NumPlayers-1;
            set(NumFoldsText,'String',[num2str(NumFolds),' Folds']);%replot strings
        end
        
        
        
        %Now update cards on table
        if action<0
            
            
            %Check if cards were full, return them to deck
            
            
            %first card
            Data=get(TableCard(NumPlayers*2+1),'UserData');
            if Data(2)>0
                set(DeckCard(Data(2)),'Cdata',CardsImages{Data(2)});%remove card from table
                Selected(Data(2))=false;
                KnownCards(NumPlayers*2+1)=-1;
            end
            %remove images and change data user from table card
            Data(2)=-1;
            set(TableCard(NumPlayers*2+1),'Cdata',CardsImages{54},...
                'Enable','inactive',...
                'UserData',Data);
            
            
            %second card
            Data=get(TableCard(NumPlayers*2+2),'UserData');
            if Data(2)>0
                set(DeckCard(Data(2)),'Cdata',CardsImages{Data(2)});%remove card from table
                Selected(Data(2))=false;
                KnownCards(NumPlayers*2+2)=-1;
            end
            %remove images and change data user from table card
            Data(2)=-1;
            set(TableCard(NumPlayers*2+2),'Cdata',CardsImages{54},...
                'Enable','inactive',...
                'UserData',Data);
         
            
            
            
            
            %if we have deleted the current table card we need to update the value
            %to the first empty table card
            
            Status=get(TableCard(CurrentTableCard),'Enable');%check status of current table card
            if strcmp(Status,'inactive');
                set(TableCard(CurrentTableCard),'selected','off');
                
                CurrentTableCard=1;
                Data=get(TableCard(CurrentTableCard),'Userdata');
                if Data(2)<0; set(TableCard(CurrentTableCard),'selected','on');return;end
                
                
                CurrentTableCard=2;
                Data=get(TableCard(CurrentTableCard),'Userdata');
                if Data(2)<0; set(TableCard(CurrentTableCard),'selected','on');return;end
                
                CurrentTableCard=21;
                Data=get(TableCard(CurrentTableCard),'Userdata');
                if Data(2)<0; set(TableCard(CurrentTableCard),'selected','on');return;end
                
                CurrentTableCard=22;
                Data=get(TableCard(CurrentTableCard),'Userdata');
                if Data(2)<0; set(TableCard(CurrentTableCard),'selected','on');return;end
                
                CurrentTableCard=23;
                Data=get(TableCard(CurrentTableCard),'Userdata');
                if Data(2)<0; set(TableCard(CurrentTableCard),'selected','on');return;end
                
                CurrentTableCard=24;
                Data=get(TableCard(CurrentTableCard),'Userdata');
                if Data(2)<0; set(TableCard(CurrentTableCard),'selected','on');return;end
                
                CurrentTableCard=25;
                set(TableCard(CurrentTableCard),'selected','on');
            end
            
        else
            set(TableCard(NumPlayers*2-1),'Cdata',CardsImages{53},...
                'Enable','on');
            set(TableCard(NumPlayers*2),'Cdata',CardsImages{53},...
                'Enable','on');
        end
        
        
        
        %Recalculate with the new players numbers
        [ PlayerHighRank,OpponentHighRank,WinTieOdd]=GameSimulation...
            (KnownCards([1:NumPlayers*2,21:25]),NumPlayers,NumSimulations,TablePtr);
        UpdateStat();
        
    end
%% DeckCardClick.
    function DeckCardClick(varargin)
        h=gcbo;%get handle to current callback object
        CardId=get(h,'UserData');%Get Card value
        if Selected(CardId)
            return%Card is selected do nothing
        end
        
        
        
        Data=get(TableCard(CurrentTableCard),'UserData');
        
        
        % in case Current table card is empty
        if Data(2)>0%place is occupied we need to swap cards
            set(DeckCard(Data(2)),'Cdata',CardsImages{Data(2)});%remove card from table
            Selected(Data(2))=false;
            
        end%Now we can add the card normally
        
        
        set(h,'Cdata',CardsImages{54});
        set( TableCard(CurrentTableCard),'Cdata',CardsImages{CardId},...
            'UserData',[CurrentTableCard,CardId]);
        
        Selected(CardId)=true;%add the new card
        KnownCards(CurrentTableCard,1)=CardId;
        
        set(TableCard(CurrentTableCard),'selected','off');
        
        %Change CurrentCardTable
        if CurrentTableCard<=NumPlayers*2
            if mod(CurrentTableCard,2)==0%even card
                CurrentTableCard=21;%jump to first table card
            else
                CurrentTableCard=CurrentTableCard+1;
            end
        elseif CurrentTableCard>=21 && CurrentTableCard<25
            CurrentTableCard=CurrentTableCard+1;
        end
        
        [ PlayerHighRank,OpponentHighRank,WinTieOdd]=GameSimulation...
            (KnownCards([1:NumPlayers*2,21:25]),NumPlayers,NumSimulations,TablePtr);
        UpdateStat();
        
        
        
        set(TableCard(CurrentTableCard),'selected','on');
        
    end

%% TableCardClick.
    function TableCardClick(varargin)
        h=gcbo;%get handle to current callback object
        Data=get(h,'UserData');%Set current table card
        
        set(TableCard(CurrentTableCard),'selected','off');
        CurrentTableCard=Data(1);
        
        CardId=Data(2);
        
        %if filled make it empty and re-fill deck cards
        if CardId>0
            
            set(DeckCard(CardId),'Cdata',CardsImages{CardId});%refill deck card
            Data(2)=-1;%card is now unknow
            set(h,'Cdata',CardsImages{53},...
                'UserData',Data);%reflag as unknown
            Selected(CardId)=false;
            KnownCards(CurrentTableCard)=-1;
            
            %Recalculate with the new configuration
            [ PlayerHighRank,OpponentHighRank,WinTieOdd]=GameSimulation...
                (KnownCards([1:NumPlayers*2,21:25]),NumPlayers,NumSimulations,TablePtr);
            UpdateStat();
        end
        
        set(TableCard(CurrentTableCard),'selected','on');
        
        
    end

%% UpdateStat
    function UpdateStat()
        
        
        
        %consider Folds
        gain=WinTieOdd(3)/100;%this is the win + tie/numtie percentage
        oppgain=1-gain;
        
        %the fold action get this winning chance, now we to divide it trough
        %players
        foldgain=oppgain*(NumFolds/(NumPlayers-1));
        
        %compute weights
        w1=gain/(1-foldgain);%Player weight
        
        
        w2=(WinTieOdd(1))/ (WinTieOdd(2)/2+WinTieOdd(1));%win/tie weight
        if isnan(w2)%for infinity Odd
            w2=0;
        end
        if NumPlayers-NumFolds==1%no tie chance
            w2=1;
        end
        
        %update values in temporary variables, this avoids memory
        %computational error, each times NumFolds is updated
        
        if NumPlayers-NumFolds==1%no tie chance
            Tie=0;
            Win=100;
        else
            Tie=WinTieOdd(2)+w1*(1-w2)*foldgain*100;% *2 consider two players tie
            Win=WinTieOdd(1)+w1*w2*foldgain*100;
        end
        Gain=(gain+w1*foldgain)*100;%Win+tie/numtie
        MaxBet=Gain/(100-Gain)*100;%to compute the maximumBet/Pot ratio
        
        Odd=1/(Gain/100);
        
        
        %Print the values in the table According to colormap
        set(StatTable(1,2),'String',num2str(PlayerHighRank(1),0))
        set(StatTable(1,3),'String',num2str(OpponentHighRank(1),0))
        %Loop trough rows and update volume
        for ii=2:10
            
            index=round(PlayerHighRank(ii));if index==0;index=1;end
            set(StatTable(ii,2),'String',[num2str(PlayerHighRank(ii),'%0.2f'),'%'],...
                'BackgroundColor',CJet(index,:));
            
            index=round(OpponentHighRank(ii));if index==0;index=1;end
            set(StatTable(ii,3),'String',[num2str(OpponentHighRank(ii),'%0.2f'),'%'],...
                'BackgroundColor',CJet(index,:));
        end
        
        
        %Print Win Tie Odd
        
        
        
        
        %set color on win textboxes
        %Win
        index=round(Win);if index==0;index=1;end
        set( WinningStat(1,:),'BackgroundColor',CJet(index,:));
        
        %Tie
        index=round(Tie);if index==0;index=1;end
        set( WinningStat(2,:),'BackgroundColor',CJet(index,:));
        
      
        
        
        %set text on  winning statistics
        set( WinningStat(1,2),'String',[num2str(Win,'%0.2f'),'%']);%
        set( WinningStat(2,2),'String',[num2str(Tie,'%0.2f'),'%']);%
        set( WinningStat(3,2),'String',[num2str(Odd,'%0.2f'),' : 1']);%
        set( WinningStat(4,2),'String',[num2str(MaxBet,'%0.2f'),'%']);%

        Profict=Gain/(1/(NumPlayers-NumFolds))-100;%in futuro decidere
        %se considerare il numero di folds, un calcolo pi accurato
        %del profitto richiederebbe la storia del gioco per sapere quanto
        %denaro c' sul tavolo.
        
        
        %interpolazione per il profict sapendo
        %che pu andara da -100% a +(NumPlayers-1-Numfolds)*100%
        
        Pivot=20;%value in which the colormap passes from cian to green
        if Profict<0
            index=round((100+Profict)/100*Pivot);if index<1;index=1;end ;if index>100;index=100;end
        else
            index=round(Pivot+Profict/(100*(NumPlayers-.99-NumFolds))*(100-Pivot));if index<1;index=1;end ;if index>100;index=100;end
        end
          %color for profict
        set( WinningStat(5,:),'BackgroundColor',CJet(index,:));
        set( WinningStat(5,2),'String',[num2str(Profict,'%0.2f'),'%']);%
        
        
         %Odd
        index=round(1/Odd*100);if index==0;index=1;end
        set( WinningStat(3,:),'BackgroundColor',CJet(index,:));
        
          %Set color on (MaxBet/Pot)
         Pivot=25;%value in which the colormap passes from good to evil 
         Pivot2=100-Pivot;
        if MaxBet>100  
        index=Pivot+round(Pivot2-Pivot2*100/MaxBet);if index<1;index=1;end ;if index>100;index=100;end
        else
              index=round(MaxBet/100*Pivot);if index<1;index=1;end ;if index>100;index=100;end
        end
        set( WinningStat(4,:),'BackgroundColor',CJet(index,:));
        
      
        
    end




%% --- Executes when user attempts to close figure1.
    function PokerPredictor_CloseRequestFcn(hObject, eventdata, handles)
        % hObject    handle to figure1 (see GCBO)
        % eventdata  reserved - to be defined in a future version of MATLAB
        % handles    structure with handles and user data (see GUIDATA)
        %         DeleteTable(handles.TablePtr);
        % Hint: delete(hObject) closes the figure
        % close PokerPredictor
        
        choice = questdlg('Are you sure you want to quit?', ...
            'Poker Predictor', ...
            'Yes','No','No');
        if strcmp(choice,'Yes')
            DeleteTable(TablePtr);
            delete(hObject);
        end
    end
end
% End Poker Predictor

%%  Presentation
function PresentationFun()
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to PokerPredictor (see VARARGIN)

% Choose default command line output for PokerPredictor
%         handles.output = hObject;

% Update handles structure
%         guidata(hObject, handles);
 load StartImage.mat Presentation2

 B=[150,30];%button width height
 W=[296 520];%Window width height
 C=[100 100];%left down corner of the window
 f=figure('color','k',...
        'MenuBar','none',...
    'Resize','off',...
    'Toolbar','none');
    rect=[ C(1) C(2) W(1) W(2)];

axes('position',[0 .1 1 .9]);
image(Presentation2);

axis image off 
Continue = uicontrol('Position', [ (W(1)-B(1))/2 20  B(1) B(2)], 'String', 'Continue', ...
    'Callback', 'uiresume(gcbf)');
set(f,'OuterPosition',rect+[0 0 0 50],...
    'Position',rect)
uiwait(gcf)%Wait for a key press on COnrinue button

delete(f);

% UIWAIT makes PokerPredictor wait for user response (see UIRESUME)
% uiwait(handles.figure1);
end


Contact us at files@mathworks.com