It depends if you want the computer to be dumb or smart.

Dumb: randomly pick 1,2 or 3 boxes.

Smart: very deep recursion to determine all possible outcomes and choose the optimal one.