The cloth is modelled as a matrix of particles, each particle constrained by distance to an adjacant particle. The particles are modelled separately as free bodies, then moved to satisfy the distance constraints. Satisfying any constraints will likely violate another so the process is repeated several times. The more particles that are used, the more articulated the cloth will appear, but the slower the computation time, and the harder it is to satisfy the increased quantity of constraints, in terms of both computation time and quality of the result. A low quality will result in the cloth stretching and distorting.
Wind is modelled quite randomly by applying a force to random selections of particles for random times. The force itself is also randomised but chosen around a desired average.
The general idea of particles and constraints are taken from the paper Advanced Character Physics by Thomas Jakobsen.