% Copyright 2006 by William S. Krasker % R(t,d,T,c,f) = prob that Team A wins with t periods to go, if score differential index is d, Team A has % T-1 timeouts left, Team A challenged c-1 times, and f=2 means there has been a failed challenge, % f=1 otherwise. p1td=[.1675 .19 .2125 .235]; % Prob of TD in last period, as function of number of timeouts. p1fg=.6*p1td; % Prob of FG in last period, as function of number of timeouts. p1tdnofg=[.1825 .205 .2275 .25]; % Prob of TD in last period, as function of number of timeouts, if FG useless. pch=0.0375; % Probability of a call Team A could challenge, on Team A's possession. qch=0.0375; % Probability of a call Team A could challenge, on Team B's possession. p=[0.2; 0.12]; % TD and FG probs if no challengeable call on Team A's possession. q=[0.2; 0.12]; % TD and FG probs if no challengeable call on Team B's possession. prev=[.05; .1; .25; .5; .8; .95]; % The possible probs of reversal if challengable call on Team A's possession. prevprobs=[.15; .2; .33; .14; .13; .05]; % Probabilities of the above values. qrev=[.05; .1; .25; .5; .8; .95]; % The possible probs of reversal if challengable call on Team B's possession. qrevprobs=[.15; .2; .33; .14; .13; .05]; % Probabilities of the above values. % On Team A's possession. Each row is prob that Team A gets TD if call reversed, prob that Team A gets % FG if call is reversed, prob that Team A gets TD if call is upheld (or unchallenged), and prob that % Team A gets FG if call is upheld (or unchallenged). P= [.25 .2 .15 .12; ... .25 .2 0 0; ... .35 .35 0 0; ... .75 .25 0 0]; % Probabilities of the above rows. Pprobs=[.47; ... .23; ... .27; ... .03]; % On Team B's possession. Each row is prob that Team B gets TD if call reversed, prob that Team B gets % FG if call is reversed, prob that Team B gets TD if call is upheld (or unchallenged), and prob that % Team B gets FG if call is upheld (or unchallenged). Q= [.15 .12 .25 .2; ... 0 0 .25 .2; ... 0 0 .35 .35; ... 0 0 .75 .25]; % Probabilities of the above rows. Qprobs=[.47; ... .23; ... .27; ... .03]; pmat=zeros(size(prev,1)*size(P,1),5); rowspmat=size(pmat,1); pmatprobs=zeros(rowspmat,1); count=0; for i=1:size(prev,1) for j=1:size(P,1) count=count+1; pmat(count,:)=[prev(i) P(j,:)]; pmatprobs(count)=prevprobs(i)*Pprobs(j); end end qmat=zeros(size(qrev,1)*size(Q,1),5); rowsqmat=size(qmat,1); qmatprobs=zeros(rowsqmat,1); count=0; for i=1:size(qrev,1) for j=1:size(Q,1) count=count+1; qmat(count,:)=[qrev(i) Q(j,:)]; qmatprobs(count)=qrevprobs(i)*Qprobs(j); end end maxt=48; maxd=100; numd=2*maxd+1; pot=0.5; % Probability of winning in overtime. p1pt=0.985; % Probability of successful kicked extra point. p2pt=0.43; % Probability of successful two-point conversion. probtimeout=0.09; % Probability of non-clock-management timeout usage per possession. R=zeros(maxt,numd,4,4,2); f2=2; % Indicates there has been a failed challenge. % Boundary win probabilities as function of score difference. B=ones(numd,1); for i=1:maxd B(i)=0; end B(maxd+1)=pot; aq=zeros(rowsqmat,1); % Final possession. Team A has ball. t=1 for f=1:2 for T=1:4 for c=1:4 for d=1:maxd-3 % FG useless. GOFOR2=p2pt*B(min(d+8,numd))+(1-p2pt)*B(min(d+6,numd)); GOFOR1=p1pt*B(min(d+7,numd))+(1-p1pt)*B(min(d+6,numd)); TD=max(GOFOR2,GOFOR1); R(t,d,T,c,f)=p1tdnofg(T)*TD+(1-p1tdnofg(T))*B(d); end for d=maxd-2:numd GOFOR2=p2pt*B(min(d+8,numd))+(1-p2pt)*B(min(d+6,numd)); GOFOR1=p1pt*B(min(d+7,numd))+(1-p1pt)*B(min(d+6,numd)); TD=max(GOFOR2,GOFOR1); R(t,d,T,c,f)=p1td(T)*TD+p1fg(T)*B(min(d+3,numd))+(1-p1td(T)-p1fg(T))*B(d); end end end end t=t+1 % Possible non-clock-management timeout usage. for f=1:2 for T=1:4 for c=1:4 for d=1:numd R(t,d,T,c,f)=probtimeout*R(t-1,d,max(T-1,1),c,f)+(1-probtimeout)*R(t-1,d,T,c,f); end end end end % Next to last possession. Team B has ball. t=t+1 for f=1:2 for T=1:4 for c=1:4 for d=1:numd % No challengeable call arises. TDPLUS2=R(t-1,max(d-8,1),T,c,f); TDPLUS1=R(t-1,max(d-7,1),T,c,f); TDPLUS0=R(t-1,max(d-6,1),T,c,f); GOFOR2=p2pt*TDPLUS2+(1-p2pt)*TDPLUS0; GOFOR1=p1pt*TDPLUS1+(1-p1pt)*TDPLUS0; TD=min(GOFOR2,GOFOR1); FG=R(t-1,max(d-3,1),T,c,f); NOSCORE=R(t-1,d,T,c,f); NOCHAL=q(1)*TD+q(2)*FG+(1-q(1)-q(2))*NOSCORE; % Challengeable call arises. for i=1:rowsqmat TDPLUS2=R(t-1,max(d-8,1),T,c,f); TDPLUS1=R(t-1,max(d-7,1),T,c,f); TDPLUS0=R(t-1,max(d-6,1),T,c,f); GOFOR2=p2pt*TDPLUS2+(1-p2pt)*TDPLUS0; GOFOR1=p1pt*TDPLUS1+(1-p1pt)*TDPLUS0; TD=min(GOFOR2,GOFOR1); FG=R(t-1,max(d-3,1),T,c,f); NOSCORE=R(t-1,d,T,c,f); DONTCHAL=qmat(i,4)*TD+qmat(i,5)*FG+(1-qmat(i,4)-qmat(i,5))*NOSCORE; if (T>1) & ( (c<3) | ((c==3)&(f==1)) ) % Can challenge. TDPLUS2=R(t-1,max(d-8,1),T,c+1,f); TDPLUS1=R(t-1,max(d-7,1),T,c+1,f); TDPLUS0=R(t-1,max(d-6,1),T,c+1,f); GOFOR2=p2pt*TDPLUS2+(1-p2pt)*TDPLUS0; GOFOR1=p1pt*TDPLUS1+(1-p1pt)*TDPLUS0; TD=min(GOFOR2,GOFOR1); FG=R(t-1,max(d-3,1),T,c+1,f); NOSCORE=R(t-1,d,T,c+1,f); REVERSED=qmat(i,2)*TD+qmat(i,3)*FG+(1-qmat(i,2)-qmat(i,3))*NOSCORE; TDPLUS2=R(t-1,max(d-8,1),T-1,c+1,f2); TDPLUS1=R(t-1,max(d-7,1),T-1,c+1,f2); TDPLUS0=R(t-1,max(d-6,1),T-1,c+1,f2); GOFOR2=p2pt*TDPLUS2+(1-p2pt)*TDPLUS0; GOFOR1=p1pt*TDPLUS1+(1-p1pt)*TDPLUS0; TD=min(GOFOR2,GOFOR1); FG=R(t-1,max(d-3,1),T-1,c+1,f2); NOSCORE=R(t-1,d,T-1,c+1,f2); UPHELD=qmat(i,4)*TD+qmat(i,5)*FG+(1-qmat(i,4)-qmat(i,5))*NOSCORE; CHAL=qmat(i,1)*REVERSED+(1-qmat(i,1))*UPHELD; else CHAL=0; end aq(i)=max(CHAL,DONTCHAL); end R(t,d,T,c,f)=(1-qch)*NOCHAL+qch*qmatprobs'*aq; end end end end t=t+1 % Possible non-clock-management timeout usage. for f=1:2 for T=1:4 for c=1:4 for d=1:numd R(t,d,T,c,f)=probtimeout*R(t-1,d,max(T-1,1),c,f)+(1-probtimeout)*R(t-1,d,T,c,f); end end end end %-------------------------------------------------- Complete the second half of the game. for posspairs=2:6 % Pairs of possessions. t=t+1 % Team A's possession. for f=1:2 for T=1:4 for c=1:4 for d=1:numd % No challengeable call arises. TDPLUS2=R(t-1,min(d+8,numd),T,c,f); TDPLUS1=R(t-1,min(d+7,numd),T,c,f); TDPLUS0=R(t-1,min(d+6,numd),T,c,f); GOFOR2=p2pt*TDPLUS2+(1-p2pt)*TDPLUS0; GOFOR1=p1pt*TDPLUS1+(1-p1pt)*TDPLUS0; TD=max(GOFOR2,GOFOR1); FG=R(t-1,min(d+3,numd),T,c,f); NOSCORE=R(t-1,d,T,c,f); NOCHAL=p(1)*TD+p(2)*FG+(1-p(1)-p(2))*NOSCORE; % Challengeable call arises. for i=1:rowspmat TDPLUS2=R(t-1,min(d+8,numd),T,c,f); TDPLUS1=R(t-1,min(d+7,numd),T,c,f); TDPLUS0=R(t-1,min(d+6,numd),T,c,f); GOFOR2=p2pt*TDPLUS2+(1-p2pt)*TDPLUS0; GOFOR1=p1pt*TDPLUS1+(1-p1pt)*TDPLUS0; TD=max(GOFOR2,GOFOR1); FG=R(t-1,min(d+3,numd),T,c,f); NOSCORE=R(t-1,d,T,c,f); DONTCHAL=pmat(i,4)*TD+pmat(i,5)*FG+(1-pmat(i,4)-pmat(i,5))*NOSCORE; if (T>1) & ( (c<3) | ((c==3)&(f==1)) ) % Can challenge. TDPLUS2=R(t-1,min(d+8,numd),T,c+1,f); TDPLUS1=R(t-1,min(d+7,numd),T,c+1,f); TDPLUS0=R(t-1,min(d+6,numd),T,c+1,f); GOFOR2=p2pt*TDPLUS2+(1-p2pt)*TDPLUS0; GOFOR1=p1pt*TDPLUS1+(1-p1pt)*TDPLUS0; TD=max(GOFOR2,GOFOR1); FG=R(t-1,min(d+3,numd),T,c+1,f); NOSCORE=R(t-1,d,T,c+1,f); REVERSED=pmat(i,2)*TD+pmat(i,3)*FG+(1-pmat(i,2)-pmat(i,3))*NOSCORE; TDPLUS2=R(t-1,min(d+8,numd),T-1,c+1,f2); TDPLUS1=R(t-1,min(d+7,numd),T-1,c+1,f2); TDPLUS0=R(t-1,min(d+6,numd),T-1,c+1,f2); GOFOR2=p2pt*TDPLUS2+(1-p2pt)*TDPLUS0; GOFOR1=p1pt*TDPLUS1+(1-p1pt)*TDPLUS0; TD=max(GOFOR2,GOFOR1); FG=R(t-1,min(d+3,numd),T-1,c+1,f2); NOSCORE=R(t-1,d,T-1,c+1,f2); UPHELD=pmat(i,4)*TD+pmat(i,5)*FG+(1-pmat(i,4)-pmat(i,5))*NOSCORE; CHAL=pmat(i,1)*REVERSED+(1-pmat(i,1))*UPHELD; else CHAL=0; end aq(i)=max(CHAL,DONTCHAL); end R(t,d,T,c,f)=(1-pch)*NOCHAL+pch*pmatprobs'*aq; end end end end t=t+1 % Possible non-clock-management timeout usage. for f=1:2 for T=1:4 for c=1:4 for d=1:numd R(t,d,T,c,f)=probtimeout*R(t-1,d,max(T-1,1),c,f)+(1-probtimeout)*R(t-1,d,T,c,f); end end end end t=t+1 % Team B's possession. for f=1:2 for T=1:4 for c=1:4 for d=1:numd % No challengeable call arises. TDPLUS2=R(t-1,max(d-8,1),T,c,f); TDPLUS1=R(t-1,max(d-7,1),T,c,f); TDPLUS0=R(t-1,max(d-6,1),T,c,f); GOFOR2=p2pt*TDPLUS2+(1-p2pt)*TDPLUS0; GOFOR1=p1pt*TDPLUS1+(1-p1pt)*TDPLUS0; TD=min(GOFOR2,GOFOR1); FG=R(t-1,max(d-3,1),T,c,f); NOSCORE=R(t-1,d,T,c,f); NOCHAL=q(1)*TD+q(2)*FG+(1-q(1)-q(2))*NOSCORE; % Challengeable call arises. for i=1:rowsqmat TDPLUS2=R(t-1,max(d-8,1),T,c,f); TDPLUS1=R(t-1,max(d-7,1),T,c,f); TDPLUS0=R(t-1,max(d-6,1),T,c,f); GOFOR2=p2pt*TDPLUS2+(1-p2pt)*TDPLUS0; GOFOR1=p1pt*TDPLUS1+(1-p1pt)*TDPLUS0; TD=min(GOFOR2,GOFOR1); FG=R(t-1,max(d-3,1),T,c,f); NOSCORE=R(t-1,d,T,c,f); DONTCHAL=qmat(i,4)*TD+qmat(i,5)*FG+(1-qmat(i,4)-qmat(i,5))*NOSCORE; if (T>1) & ( (c<3) | ((c==3)&(f==1)) ) % Can challenge. TDPLUS2=R(t-1,max(d-8,1),T,c+1,f); TDPLUS1=R(t-1,max(d-7,1),T,c+1,f); TDPLUS0=R(t-1,max(d-6,1),T,c+1,f); GOFOR2=p2pt*TDPLUS2+(1-p2pt)*TDPLUS0; GOFOR1=p1pt*TDPLUS1+(1-p1pt)*TDPLUS0; TD=min(GOFOR2,GOFOR1); FG=R(t-1,max(d-3,1),T,c+1,f); NOSCORE=R(t-1,d,T,c+1,f); REVERSED=qmat(i,2)*TD+qmat(i,3)*FG+(1-qmat(i,2)-qmat(i,3))*NOSCORE; TDPLUS2=R(t-1,max(d-8,1),T-1,c+1,f2); TDPLUS1=R(t-1,max(d-7,1),T-1,c+1,f2); TDPLUS0=R(t-1,max(d-6,1),T-1,c+1,f2); GOFOR2=p2pt*TDPLUS2+(1-p2pt)*TDPLUS0; GOFOR1=p1pt*TDPLUS1+(1-p1pt)*TDPLUS0; TD=min(GOFOR2,GOFOR1); FG=R(t-1,max(d-3,1),T-1,c+1,f2); NOSCORE=R(t-1,d,T-1,c+1,f2); UPHELD=qmat(i,4)*TD+qmat(i,5)*FG+(1-qmat(i,4)-qmat(i,5))*NOSCORE; CHAL=qmat(i,1)*REVERSED+(1-qmat(i,1))*UPHELD; else CHAL=0; end aq(i)=max(CHAL,DONTCHAL); end R(t,d,T,c,f)=(1-qch)*NOCHAL+qch*qmatprobs'*aq; end end end end t=t+1 % Possible non-clock-management timeout usage. for f=1:2 for T=1:4 for c=1:4 for d=1:numd R(t,d,T,c,f)=probtimeout*R(t-1,d,max(T-1,1),c,f)+(1-probtimeout)*R(t-1,d,T,c,f); end end end end end %-------------------------------------------------- Last two possessions of first half. % Final possession of first half. Team A has ball. t=t+1 for f=1:2 for T=1:4 for c=1:4 for d=1:numd TDPLUS2=R(t-1,min(d+8,numd),4,c,f); % New set of timeouts to start 2nd half. TDPLUS1=R(t-1,min(d+7,numd),4,c,f); TDPLUS0=R(t-1,min(d+6,numd),4,c,f); GOFOR2=p2pt*TDPLUS2+(1-p2pt)*TDPLUS0; GOFOR1=p1pt*TDPLUS1+(1-p1pt)*TDPLUS0; TD=max(GOFOR2,GOFOR1); FG=R(t-1,min(d+3,numd),4,c,f); NOSCORE=R(t-1,d,4,c,f); R(t,d,T,c,f)=p1td(T)*TD+p1fg(T)*FG+(1-p1td(T)-p1fg(T))*NOSCORE; end end end end t=t+1 % Possible non-clock-management timeout usage. for f=1:2 for T=1:4 for c=1:4 for d=1:numd R(t,d,T,c,f)=probtimeout*R(t-1,d,max(T-1,1),c,f)+(1-probtimeout)*R(t-1,d,T,c,f); end end end end % Next to last possession. They have ball. t=t+1 for f=1:2 for T=1:4 for c=1:4 for d=1:numd % No challengeable call arises. TDPLUS2=R(t-1,max(d-8,1),T,c,f); TDPLUS1=R(t-1,max(d-7,1),T,c,f); TDPLUS0=R(t-1,max(d-6,1),T,c,f); GOFOR2=p2pt*TDPLUS2+(1-p2pt)*TDPLUS0; GOFOR1=p1pt*TDPLUS1+(1-p1pt)*TDPLUS0; TD=min(GOFOR2,GOFOR1); FG=R(t-1,max(d-3,1),T,c,f); NOSCORE=R(t-1,d,T,c,f); NOCHAL=q(1)*TD+q(2)*FG+(1-q(1)-q(2))*NOSCORE; % Challengeable call arises. for i=1:rowsqmat TDPLUS2=R(t-1,max(d-8,1),T,c,f); TDPLUS1=R(t-1,max(d-7,1),T,c,f); TDPLUS0=R(t-1,max(d-6,1),T,c,f); GOFOR2=p2pt*TDPLUS2+(1-p2pt)*TDPLUS0; GOFOR1=p1pt*TDPLUS1+(1-p1pt)*TDPLUS0; TD=min(GOFOR2,GOFOR1); FG=R(t-1,max(d-3,1),T,c,f); NOSCORE=R(t-1,d,T,c,f); DONTCHAL=qmat(i,4)*TD+qmat(i,5)*FG+(1-qmat(i,4)-qmat(i,5))*NOSCORE; if (T>1) & ( (c<3) | ((c==3)&(f==1)) ) % Can challenge. TDPLUS2=R(t-1,max(d-8,1),T,c+1,f); TDPLUS1=R(t-1,max(d-7,1),T,c+1,f); TDPLUS0=R(t-1,max(d-6,1),T,c+1,f); GOFOR2=p2pt*TDPLUS2+(1-p2pt)*TDPLUS0; GOFOR1=p1pt*TDPLUS1+(1-p1pt)*TDPLUS0; TD=min(GOFOR2,GOFOR1); FG=R(t-1,max(d-3,1),T,c+1,f); NOSCORE=R(t-1,d,T,c+1,f); REVERSED=qmat(i,2)*TD+qmat(i,3)*FG+(1-qmat(i,2)-qmat(i,3))*NOSCORE; TDPLUS2=R(t-1,max(d-8,1),T-1,c+1,f2); TDPLUS1=R(t-1,max(d-7,1),T-1,c+1,f2); TDPLUS0=R(t-1,max(d-6,1),T-1,c+1,f2); GOFOR2=p2pt*TDPLUS2+(1-p2pt)*TDPLUS0; GOFOR1=p1pt*TDPLUS1+(1-p1pt)*TDPLUS0; TD=min(GOFOR2,GOFOR1); FG=R(t-1,max(d-3,1),T-1,c+1,f2); NOSCORE=R(t-1,d,T-1,c+1,f2); UPHELD=qmat(i,4)*TD+qmat(i,5)*FG+(1-qmat(i,4)-qmat(i,5))*NOSCORE; CHAL=qmat(i,1)*REVERSED+(1-qmat(i,1))*UPHELD; else CHAL=0; end aq(i)=max(CHAL,DONTCHAL); end R(t,d,T,c,f)=(1-qch)*NOCHAL+qch*qmatprobs'*aq; end end end end t=t+1 % Possible non-clock-management timeout usage. for f=1:2 for T=1:4 for c=1:4 for d=1:numd R(t,d,T,c,f)=probtimeout*R(t-1,d,max(T-1,1),c,f)+(1-probtimeout)*R(t-1,d,T,c,f); end end end end %-------------------------------------------------- Complete the first half of the game. for posspairs=2:6 % Pairs of possessions. t=t+1 % Team A's possession. for f=1:2 for T=1:4 for c=1:4 for d=1:numd % No challengeable call arises. TDPLUS2=R(t-1,min(d+8,numd),T,c,f); TDPLUS1=R(t-1,min(d+7,numd),T,c,f); TDPLUS0=R(t-1,min(d+6,numd),T,c,f); GOFOR2=p2pt*TDPLUS2+(1-p2pt)*TDPLUS0; GOFOR1=p1pt*TDPLUS1+(1-p1pt)*TDPLUS0; TD=max(GOFOR2,GOFOR1); FG=R(t-1,min(d+3,numd),T,c,f); NOSCORE=R(t-1,d,T,c,f); NOCHAL=p(1)*TD+p(2)*FG+(1-p(1)-p(2))*NOSCORE; % Challengeable call arises. for i=1:rowspmat TDPLUS2=R(t-1,min(d+8,numd),T,c,f); TDPLUS1=R(t-1,min(d+7,numd),T,c,f); TDPLUS0=R(t-1,min(d+6,numd),T,c,f); GOFOR2=p2pt*TDPLUS2+(1-p2pt)*TDPLUS0; GOFOR1=p1pt*TDPLUS1+(1-p1pt)*TDPLUS0; TD=max(GOFOR2,GOFOR1); FG=R(t-1,min(d+3,numd),T,c,f); NOSCORE=R(t-1,d,T,c,f); DONTCHAL=pmat(i,4)*TD+pmat(i,5)*FG+(1-pmat(i,4)-pmat(i,5))*NOSCORE; if (T>1) & ( (c<3) | ((c==3)&(f==1)) ) % Can challenge. TDPLUS2=R(t-1,min(d+8,numd),T,c+1,f); TDPLUS1=R(t-1,min(d+7,numd),T,c+1,f); TDPLUS0=R(t-1,min(d+6,numd),T,c+1,f); GOFOR2=p2pt*TDPLUS2+(1-p2pt)*TDPLUS0; GOFOR1=p1pt*TDPLUS1+(1-p1pt)*TDPLUS0; TD=max(GOFOR2,GOFOR1); FG=R(t-1,min(d+3,numd),T,c+1,f); NOSCORE=R(t-1,d,T,c+1,f); REVERSED=pmat(i,2)*TD+pmat(i,3)*FG+(1-pmat(i,2)-pmat(i,3))*NOSCORE; TDPLUS2=R(t-1,min(d+8,numd),T-1,c+1,f2); TDPLUS1=R(t-1,min(d+7,numd),T-1,c+1,f2); TDPLUS0=R(t-1,min(d+6,numd),T-1,c+1,f2); GOFOR2=p2pt*TDPLUS2+(1-p2pt)*TDPLUS0; GOFOR1=p1pt*TDPLUS1+(1-p1pt)*TDPLUS0; TD=max(GOFOR2,GOFOR1); FG=R(t-1,min(d+3,numd),T-1,c+1,f2); NOSCORE=R(t-1,d,T-1,c+1,f2); UPHELD=pmat(i,4)*TD+pmat(i,5)*FG+(1-pmat(i,4)-pmat(i,5))*NOSCORE; CHAL=pmat(i,1)*REVERSED+(1-pmat(i,1))*UPHELD; else CHAL=0; end aq(i)=max(CHAL,DONTCHAL); end R(t,d,T,c,f)=(1-pch)*NOCHAL+pch*pmatprobs'*aq; end end end end t=t+1 % Possible non-clock-management timeout usage. for f=1:2 for T=1:4 for c=1:4 for d=1:numd R(t,d,T,c,f)=probtimeout*R(t-1,d,max(T-1,1),c,f)+(1-probtimeout)*R(t-1,d,T,c,f); end end end end t=t+1 % Team B's possession. for f=1:2 for T=1:4 for c=1:4 for d=1:numd % No challengeable call arises. TDPLUS2=R(t-1,max(d-8,1),T,c,f); TDPLUS1=R(t-1,max(d-7,1),T,c,f); TDPLUS0=R(t-1,max(d-6,1),T,c,f); GOFOR2=p2pt*TDPLUS2+(1-p2pt)*TDPLUS0; GOFOR1=p1pt*TDPLUS1+(1-p1pt)*TDPLUS0; TD=min(GOFOR2,GOFOR1); FG=R(t-1,max(d-3,1),T,c,f); NOSCORE=R(t-1,d,T,c,f); NOCHAL=q(1)*TD+q(2)*FG+(1-q(1)-q(2))*NOSCORE; % Challengeable call arises. for i=1:rowsqmat TDPLUS2=R(t-1,max(d-8,1),T,c,f); TDPLUS1=R(t-1,max(d-7,1),T,c,f); TDPLUS0=R(t-1,max(d-6,1),T,c,f); GOFOR2=p2pt*TDPLUS2+(1-p2pt)*TDPLUS0; GOFOR1=p1pt*TDPLUS1+(1-p1pt)*TDPLUS0; TD=min(GOFOR2,GOFOR1); FG=R(t-1,max(d-3,1),T,c,f); NOSCORE=R(t-1,d,T,c,f); DONTCHAL=qmat(i,4)*TD+qmat(i,5)*FG+(1-qmat(i,4)-qmat(i,5))*NOSCORE; if (T>1) & ( (c<3) | ((c==3)&(f==1)) ) % Can challenge. TDPLUS2=R(t-1,max(d-8,1),T,c+1,f); TDPLUS1=R(t-1,max(d-7,1),T,c+1,f); TDPLUS0=R(t-1,max(d-6,1),T,c+1,f); GOFOR2=p2pt*TDPLUS2+(1-p2pt)*TDPLUS0; GOFOR1=p1pt*TDPLUS1+(1-p1pt)*TDPLUS0; TD=min(GOFOR2,GOFOR1); FG=R(t-1,max(d-3,1),T,c+1,f); NOSCORE=R(t-1,d,T,c+1,f); REVERSED=qmat(i,2)*TD+qmat(i,3)*FG+(1-qmat(i,2)-qmat(i,3))*NOSCORE; TDPLUS2=R(t-1,max(d-8,1),T-1,c+1,f2); TDPLUS1=R(t-1,max(d-7,1),T-1,c+1,f2); TDPLUS0=R(t-1,max(d-6,1),T-1,c+1,f2); GOFOR2=p2pt*TDPLUS2+(1-p2pt)*TDPLUS0; GOFOR1=p1pt*TDPLUS1+(1-p1pt)*TDPLUS0; TD=min(GOFOR2,GOFOR1); FG=R(t-1,max(d-3,1),T-1,c+1,f2); NOSCORE=R(t-1,d,T-1,c+1,f2); UPHELD=qmat(i,4)*TD+qmat(i,5)*FG+(1-qmat(i,4)-qmat(i,5))*NOSCORE; CHAL=qmat(i,1)*REVERSED+(1-qmat(i,1))*UPHELD; else CHAL=0; end aq(i)=max(CHAL,DONTCHAL); end R(t,d,T,c,f)=(1-qch)*NOCHAL+qch*qmatprobs'*aq; end end end end t=t+1 % Possible non-clock-management timeout usage. for f=1:2 for T=1:4 for c=1:4 for d=1:numd R(t,d,T,c,f)=probtimeout*R(t-1,d,max(T-1,1),c,f)+(1-probtimeout)*R(t-1,d,T,c,f); end end end end end