An explicit form of the Lax pair for the q-difference Painleve equation with
affine Weyl group symmetry of type E^{(1)}_8 is obtained. Its degeneration to
E^{(1)}_7, E^{(1)}_6 and D^{(1)}_5 cases are also given.
We introduce generalized energies for a class of U_q(D^{(1)}_n) crystals by
using the piecewise linear functions that are building blocks of the
combinatorial R. They include the conventional energy in the theory of affine
crystals as a special case. It is shown that the generalized energies count the
particles and anti-particles in a quadrant of the two dimensional lattice
generated by time evolutions of an integrable D^{(1)}_n cellular automaton.
Explicit formulas are conjectured for some of them in the form of ultradiscrete
tau functions.