# Uniform Circle Formation for Fully, Semi-, and Asynchronous Opaque Robots with Lights
## 7 The Algorithm for the Asynchronous Mode  
In the asynch mode, severe issues may arise whenever robots are activated while other robots are moving to their destinations. In fact, robot snapshots may not be sufficient to reconstruct some fundamental aspects of the system (e.g., SEC, main diameters, safe diameters and chords), crucial for their correct motion. This is basically due to the fact that _(i)_ moving robots _can be obstructed_ by other robots, _(ii)_ moving robots _can obstruct_ other robots, and _(iii)_ a static snapshot does not reveal the motion of the robots. For (_i_), the algorithm guarantees obstructed moving robots cause neither collisions nor ambiguous snapshots. For (_ii_) and (_iii)_, new light colors of type _moving_ are lighted up as soon as a robot starts moving. Specifically, let \(r\) be a robot that must set its light with \(c\) as color (note that \(c\) can be equal to the current color of the robot) and reach a new position \(q\) according to the ssynch algorithm. In the asynch strategy, \(r\) set its color as _moving_c_ before starting moving (at the beginning of the move phase). Once on \(q,r\) stops itself and so completes its cycle (still remaining with the color _moving_c_). At the next activation, \(r\) simply updates its color from _moving_c_ to \(c\). If a robot \(r^{\prime}\) sees at least a _moving_-colored robot and \(r^{\prime}\) is not lighted with a _moving_ color, \(r^{\prime}\) skips its turn and does nothing. This technique allows an asynchronous swarm to simulate a ssynch scheme. Therefore, the ssynch algorithm can be adapted through the following features, depending on the phases of the algorithm, to solve the UCF problem in the asynch mode:  
* In the first phase, pivots and angles (after having set placeholders if necessary) must be set, according to the same precedence logic as in the ssynch mode. More precisely, if an activated robot \(r\) figures out that regular tuples are incomplete and it does not see moving robots (i.e., robots with some _moving_ light colors), \(r\) establishes whether or not it has to become a pivot or angle robot. In the affirmative, if \(r\) already lies on a pivot or angle position, \(r\) assumes the proper color as in the ssynch mode; otherwise, \(r\) updates its color as _moving_pivot_down_, _moving_pivot_s2_, _moving_pivot_r4_ or _moving_angle_ (note that these colors are intended for the only pivots and angle robots which have to move) depending on its final destination, and \(r\) moves there. Once re-activated, a robot with the color _moving_x_ simply changes its color into \(x\)\(\in\)\(\{\)_pivot_down_, _pivot_s2_, _pivot_r4_, _angle_\(\}\), and stands still. Otherwise, if the robot does not have to reach a pivot or angle position, or it sees some robots with color light of type _moving_, then it stays still.
* The second phase starts after the regular tuple setting. Robots enter the SEC on diameters and chords only if they see no other robot with the color _moving_internal_.  
Activated robots that sit on \(n\)-gon vertices and are neither pivots nor angles, assume the color _sec_ and stay still. When entering the SEC, a robot assumes the color _moving_internal_. Once re-activated, a _moving_internal_ colored robot simply switches its color into _internal_ and stays still.
* In the third phase, the _internal_ robots go back to the SEC traveling perpendicularly with respect to the safe segment they lie on. An internal robot \(r\) starts to move only if it sees only robots with lights on (with colors _pivot_, _pivot_down_, _pivot_r1_, _pivot_r2_, _pivot_r3_, _pivot_r4_, _pivot_s1_, _pivot_s2_, _pivot_s3_, _angle_, _sec_, _internal_). If this is the case, \(r\) determines its \(n\)-gon vertex position and moves there while assuming the color _moving_sec_. Otherwise, it stays still. This strategy guarantees the internal robot to correctly compute the SEC, the safe segment where it lies, and so the target \(n\)-gon. Once on the SEC, \(r\) will turn its color from _moving_sec_ to _sec_.