# Generalized OKEY r=4 k=13 p players (p>=1) and every player gets s random tiles # 2*r sets of tiles labeled 1,...,k (later we will add the two jokers) #2*r*k+2 tiles #2*4*13+2 = 106 #Next time: #Write a Maple procedure convention the jokers are 0 #Tile(r,k) that inputs r and k and outputs the LIST of #[i,j], 1<=i<=k, 1<=j<=r Tile:=proc(r,k) local i,j,L: L:=[seq(seq([i,j],j=1..r),i=1..k)]: [op(L),op(L),0,0]: end: #Write a Maple procedure #Deal(r,k,p,s) that inputs integers r,k,p,s and outputs a list of lists of length #p let's call it L such that L[i] is the "hand" of player i, where L[i] is a random list of length s # remember that p players, every player gets s tiles, 2 #use the Maple command rand() # basically every player has s tiles Deal:=proc(r,k,p,s) local T, L, i, PD, tile, j: T:= Tile(r,k): if (p*s > nops(T)) then print (`Not enough tiles for all players!`): RETURN(FAIL): fi: L:= []: for i from 1 to p do: PD:=[]; for j from 1 to s do: tile:= rand(1..nops(T))(): PD:= [op(PD), T[tile]]: subsop(tile=NULL, T): od: L:= [op(L), PD]: od: L: end: