A278832 Maximal material difference at the end of the n-th ply of a chess game.
0, 0, 3, 3, 10, 10, 15, 15, 24, 24
Offset: 1
Examples
In the first two half-moves no material can be captured. At its second move, i.e., ply 3, White has a few possibilities of capturing a black knight, e.g., 1. d3 Nh6 2. Bxh6; which yields a material difference of +3 for White. With 5 plies available, White should instead aim to capture a black pawn and Black's queen, as in 1. d3 g5 2. Bxg5 e5 3. Bxd8. This would yield an advantage of 1 + 9 = 10 for White.
Programs
-
PARI
/* For illustrative purpose only: yields correct values at least up to n = 6, but too slow for larger n; en-passant, castling and illegal moves (when king in check) are not handled correctly */ {A278832(n,B=concat([B=digits(211107889e8\9*10^32),-B[9..16],-B[1..8],1]),M=concat(vector(64,F,if( B[F]*B[65]>0,Vec(moveGen[abs(B[F])](B,F-1)),[]))))=vecmax(apply(if(n>1,m-> A278832(n-1,makeMove(B,m))-VALUE[VAL_OFFSET+B[m%64+1]], m->-VALUE[B[m%64+1]+VAL_OFFSET]),M))}; makeMove(B,m)={B[m%64+1]=B[m\64+1];B[m\64+1]=0;B[65]*=-1;B}; VALUE=[0,-9,-3,-3,-5,-1,0,1,5,3,3,9,0]; VAL_OFFSET=7; KING=setunion(ROOK=[-8,-1,1,8], BISHOP=[-9,-7,7,9]); moveGen=[pawn(B,F,s8=B[65]<<3,L=List(),F8=F%8,F65=F*65)={F8>0 && B[F+s8]*s8<0 && listput(L,s8-1+F65); F8<7 && B[F+s8+2]*s8<0 && listput(L,s8+1+F65); B[1+F+s8]==0 && listput(L,s8+F65) && F\8==6^(s8<0) && listput(L,s8<<1+F65); L},\ rook(B,F,d=ROOK,L=List(),T)={ for(i=1,#d,T=F; while(T%8*2!=(d[i]+9)%8*7 && T\8*2!=(d[i]+9)\8*7 && B[1+T+=d[i]]*B[65]<=0,listput(L,T+64*F); B[1+T] && break));L}, knight(B,F)=king(B,F,[-17,-15,-10,-6,6,10,15,17]), bishop(B,F)=rook(B,F,BISHOP), queen(B,F)=rook(B,F,KING), king(B,F,d=KING,L=List(),T)={for(i=1,#d,(T=F+d[i])>=0 && T<64 && (d[i]+2)%8 + F%8 > 1 && (d[i]+2)%8 + F%8<10 && B[1+T]*B[65]<=0 && listput(L,T+64*F));L}]
Extensions
a(3)-a(4) corrected and a(7)-a(10) from François Labelle, Nov 29 2016
Comments