The continuous flock-of-starlings optimization (CFSO) is applied to the optimization of the array coils usually used for transcranial magnetic stimulation. The CFSO is the continuous equivalent model of the flock-of-starlings optimization (FSO) algorithm, and it is expressed in terms of a state-space representation. The trajectories of the CFSO particles that explore the space solutions of the optimization problem, are obtained by a direct application of closed forms with suitable time windows (TWs). Thanks to the representation in terms of state equations, it is possible to drive the trajectories by passing from convergence to divergence or vice versa, i.e., from exploration to exploitation. Moreover, it is possible to refine the solution by reducing the amplitude of the TWs, during the optimization procedure, enhancing the performance of numerical FSO algorithm. The use of closed forms makes the CFSO easy to be implemented and accurate in quality of solution. Validation results are presented and the performances of different optimal array coils configurations have been compared.