Help:=proc(): print(`IniPos(m,n),`): print(`WhiteKingMoves(POS,m,n)`): end: #A position is a pair [[wR,wK],bK] #where wR is the location ([i,j]) # of the White Rook, wK that of #the white King, and bK is the location #of the black King WhiteMoves:=proc(POS,m,n) WhiteKingMoves(POS,m,n) union WhiteRookMoves(POS,m,n): end: IniPos:=proc(m,n): [[[m,1],[1,n-1]],[m,n]]:end: WhiteKingMoves:=proc(POS,m,n) local wK,bK,i,j,Neig,Board: Board:={seq(seq([i,j],i=1..m),j=1..n)}: wK:=POS[1][2]: bK:=POS[2]: i:=K[1]: j:=K[2]: Neig:={[i+1,j],[i-1,j],[i,j+1], [i,j-1],[i+1,j+1],[i+1,j-1], [i-1,j+1],[i-1,j-1]} intersect Board: if member(bK,Neig) then RETURN(BlackLost): fi: {seq([[Neig[i] ,POS[1][2]],POS[2]],i=1..nops(Neig))}: end: end: