function pay=cardgame3(nplays,mybet,compbet)
% for the computer to always bet, set compbet=1
% same as cardgame2 only without display. you bet if card>yourbet, computer if
% >compbet
card=[' 2';' 3';' 4';' 5';' 6';' 7';' 8';' 9';'10';' J';' Q';' K';' A']; pay=[];
for i=1:nplays
p=permuternd(13);
if (p(2)>=compbet)  % in this case computer bets
 if(p(1)>=mybet)
     payoff=6*sign(p(1)-p(2));
 else
     payoff=-1;
 end

 %disp(['The computer raised. Your card ', card(p(1),:), ':   Computers card ' card(p(2),:), ':   Your payoff ',num2str(payoff)])
 pay=[pay payoff];
 disp('')
else    % runs this if the computer does not bet
  
 if(p(1)>=mybet)   % you bet computer does not
     payoff=1;
 else    % you& computer do not bet
     payoff=0;
 end
 %disp(['The computer does not raise. Your card ', card(p(1),:), ':   Computers card ' card(p(2),:), ':   Your payoff ',num2str(payoff)])
 pay=[pay payoff];
 disp('')
end
end
mp=mean(pay);
disp(['Mean payoff per game ', num2str(mp)])
disp([' Your total won/lost is ', num2str(mp*length(pay))])