Dynamic creation is achieved by combining recursion and parallel composition.

let rec process ball state =
  do run (move state)
  until split ->
    run (ball (new_state' state))
    ||
    run (ball (new_state' state))
  done

#run (ball (new_state ())) ;;

Finally, each time we emit the split event, the ball is duplicated.

emit split ;;

emit split ;;

Warning the JavaScript interpreter can stop if there is to many balls.