Matteo, it is the search tree which is the heavy operation. The problem is
here that the king search is involved in the search tree, which has
thousands of branches. You should consider changing the rules a bit to make
it easier to program, until you know how to do it. Anyway, these 'create'
and 'capture' commands do nothing if not followed by an 'add'. After
the last 'create' there is no 'add', so it won't happen. You probably
only need an 'add' in the last position, and that cascade seems
superfluous(?). You don't need to 'capture' the king-check piece. It is
superfluous. You could also use 'change-type' instead of 'create', to
avoid a capture sound.
/Mats