N=40;
T=zeros(N);

%Sont pris en compte :
% Le jet des dés


%Jets de dés
T=T+diag(6*ones(N-6-1,1),6+1);
T=T+diag(6*ones(6+1,1),6-N+1);
for k=1:5
T=T+diag(k*ones(N-k-1,1),k+1);
T=T+diag(k*ones(k+1,1),k-N+1);
T=T+diag((6-k)*ones(N-(6+k)-1,1),6+k+1);
T=T+diag((6-k)*ones(6+k+1,1),6+k-N+1);
end
T=T/36;


%Prison

for k=1:30
T(k,11)=T(k,31)+T(k,11);
T(k,31)=0;
end

T



%Excès de vitesse
for k=1:30
T(k,:)=T(k,:)*215/216;
T(k,11)=T(k,11)+1/216;
end
for k=32:40
T(k,:)=T(k,:)*215/216;
T(k,11)=T(k,11)+1/216;
end


P=T;

Q=eye(N)-P;

r=null(Q');
r=100*r/sum(r)

figure(1)
subplot(221)
bar(eye(1,40)*P^2*100);
set(gca,'YGrid','on')
set(gca,'XTick',[1,5,10,15,20,25,30,35,40])
set(gca,'XTickLabel',{1,5,10,15,20,25,30,35,40})
XLIM([0.5,40.5]);

subplot(222)
bar(eye(1,40)*P^10*100);
set(gca,'YGrid','on')
set(gca,'XTick',[1,5,10,15,20,25,30,35,40])
set(gca,'XTickLabel',{1,5,10,15,20,25,30,35,40})
XLIM([0.5,40.5]);

subplot(223)
bar(eye(1,40)*P^50*100);
set(gca,'YGrid','on')
set(gca,'XTick',[1,5,10,15,20,25,30,35,40])
set(gca,'XTickLabel',{1,5,10,15,20,25,30,35,40})
XLIM([0.5,40.5]);

subplot(224)
bar(r);
set(gca,'YGrid','on')
set(gca,'XTick',[1,5,10,15,20,25,30,35,40])
set(gca,'XTickLabel',{1,5,10,15,20,25,30,35,40})
XLIM([0.5,40.5]);

%figure(1)
%bar(r)
%set(gca,'Color','w')
%set(gca,'YGrid','on')
%set(gca,'XTick',[1,4,7,10,13,16,19,22,25,28,31,34,37,40])
%set(gca,'XTickLabel',{1,4,7,10,13,16,19,22,25,28,31,34,37,40})
%XLIM([0.5,40.5]);

figure(2)
gr(1)=r(2)+r(4); %Violet
gr(2)=r(7)+r(9)+r(10); %Bleu clair
gr(3)=r(12)+r(14)+r(15); %Rose
gr(4)=r(17)+r(19)+r(20); %Orange
gr(5)=r(22)+r(24)+r(25); %Rouge
gr(6)=r(27)+r(28)+r(30); %Jaune
gr(7)=r(32)+r(33)+r(35); %Vert
gr(8)=r(38)+r(40); %Bleu
gr(9)=r(6)+r(16)+r(26)+r(36) %Gares
bar(gr)
set(gca,'XTickLabel',{'Violet','Bleu clair','Rose','Orange','Rouge','Jaune','Vert','Bleu','Gares'})
set(gca,'Color','w')
set(gca,'YGrid','on')
set(gca,'XLim',[0.5,9.5])
