Connected Reconfiguration of Lattice-Based Cellular Structures by Finite-Memory Robots

We provide algorithmic methods for connected reconfiguration of lattice-based cellular structures by finite-state robots, motivated by large-scale constructions in space. We present algorithms that are able to detect and reconfigure arbitrary polyominoes, while also preserving connectivity of a structure during reconfiguration; we also provide mathematical proofs and performance guarantees. Specific results include methods for determining a bounding box, scaling a given arrangement, and adapting more general algorithms for transforming polyominoes.

aspects of digital production, engineering and even medicine. In many cases, the use of autonomous agents (such as robots) promises significant advantages, but also a number of additional challenges. Particularly intriguing challenges arise in space, with difficulties of expensive supply chains, scarcity of building materials, dramatic costs and consequences of even small errors, and the limitations of outside intervention in case of malfunctions. For many applications, an important aspect in this process is connectivity of the overall arrangement throughout the reconfiguration process, which is critical for overall coherence (in particular for assemblies in space, where disconnected pieces cannot regain connectivity), or for autonomous devices (such as catoms in claytronics [46]), which need connectivity for local motion, electric power and communication.
As described in parallel, practically oriented work [63], and visualized in our video [1], a number of significant advances have been made to facilitate overall breakthroughs; see Fig. 1 for an illustration. One important step has been the development of ultra-light and scalable composite lattice materials [48] that allow the construction of modular, reconfigurable, lattice-based structures [55]. A second step has been the design of simple autonomous robots [54,56] that are able to move on the resulting lattice structures and move their elementary cell components, thereby allowing the reconfiguration of the overall edifice. Combining such materials and robots in space promises to greatly increase the dimensions of constructible facilities and spacecraft, as well as offering to extend mission capabilities with reconfiguration and re-use [47]. Because moving mass and volume into space remains a critical factor, it is conceivable that the involved robots (just like the building material) can be produced and assembled in space; because robots will still require more complex production steps than the passive material, their availability will remain a bottleneck, so limiting their number is highly desirable. Moreover, production in space is not possible for sophisticated components such as complex microchips, adding a second objective: enabling the use of very simple robots.
In this paper, we provide algorithmic foundations for enabling extremely simple robots, i.e., finite automata, to perform a complex spectrum of construction tasks for cellular structures in space, such as computing a bounding box for a cellular arrangement, scaling up a given seed construction, and a number of other design operations. At all stages in this algorithmic process, we maintain connectivity of the overall assembly.

Our Results
We present the following results.
1. We show how two finite-state robots suffice to construct a bounding box for a given connected planar arrangement of grid cells (a polyomino P) in a limited number of steps; see Fig. 1 for an illustration. 2. We provide an algorithmic method that enables two finite-state robots to construct (for a polyomino P with a surrounding bounding box) a scaled up copy of P in a limited number of steps, while preserving connectivity of intermediate  [1] illustrating the scaling procedure. (Note that in that video, the blue marker is not distinguished from the red robot; in the rest of this paper, we make that distinction by using a different shape for the marker.) We start with a polyomino P (blue) in the top left and create a copy of P that is scaled by factor of 3 (bottom right). See https://www.ibr.cs.tu-bs.de/users/fekete/Videos/SoCG/ 2020/Space_final.mp4, in particular, 4:35-5:38 3. We give a more efficient method for scaling a monotone polyomino P, while preserving connectivity of intermediate arrangements. 4. We describe how other arbitrary reconfigurations can be adapted to our connected scenario.

Related Work
The structures considered in this work are motivated by the possibilities of ultra-light material, as described by Cheung and Gershenfeld [11] and Gregg et al. [48]. Modular two-dimensional elements mechanically link in 3D to form reversibly assembled composite lattices. This process is not limited by scale, and it enables disassembly and reconfiguration. As shown by Cramer et al. [14] and Jenett et al. [53], large but lightweight structures can be built from these components. Jenett et al. have developed autonomous robots that move on the surface [52,56] or within the cellular structure [54]. With the help of these robots, individual cells can be attached to an existing assembly, or moved to a different location. An approach for global optimization of a corresponding motion plan has been described by Costa et al. [13], while the design of hierarchical structures was addressed by Jenett et al. [57]. Assembly by simple robots has also been considered at the micro scale, where global control control is used for supplying the necessary force for moving agents, e.g., see Becker et al. [6] for the corresponding problem of motion planning, Schmidt et al. [66] for using this model for assembling structures, and Balanza-Martinez et al. [5] for theoretical characterizations. Distributed self-assembly for modular robots with limited computing resources was studied by Tucci et al. [68]. Self-configuration of robots themselves has been considered by Naz et al. [62]. A basic model in which robots themselves are used as building material was introduced by Derakhshandeh et al. [23,24]. This resembles Claytronics robots like Catoms, see Goldstein and Mowry [46]. A large spectrum of methods for tile-based assembly in biology has also been considered. Examples include DNA self-assembly, introduced by Winfree [69,70] and extended to a variety of models [10,20]. See Patitz [65] for a survey.
There has been a considerable amount of classic algorithmic work dealing with robots or agents on graphs. Blum and Kozen [8] showed that two finite automata can jointly search any unknown maze. Other work has focused on exploring general graphs (e.g., [35,40,64]), as a distributed or collaborative problem using multiple agents (e.g. [7,9,18,28,38]) or with space limitations (e.g. [3,31,[39][40][41]51]). Another problem related to robots on graphs is the rendezvous search problem [2], where two robots are searching for each other in a known or unknown environment. Anderson and Weber [4] presented an optimal strategy for discrete locations. The deterministic rendezvous problem as a variant of the previously described problem has also been considered [27,61,67]. For scenarios with more than two robots, we face the gathering problem, which was investigated on graphs [17,30,58] or, related to more realistic robotic scenarios, in the plane [12,15,37]. See also [36] for a comprehensive survey.
In the context of programmable matter, the spectrum of approaches includes selffolding matter [34,49,60] or self-disassembling magnetic robot pebbles [42]. From an algorithmic perspective, we are interested in different models representing programmable matter and further recent results. D'Angelo et al. [16] provide a simple model in which leader election can still be performed. Inspired by the single-celled amoeba, Derakhshandeh et al. [21] introduced the Amoebot model and later a generalized variant, the general Amoebot model [26]. The Amoebot model provides a framework based on a triangular lattice and active particles that can occupy a single lattice vertex or a pair of adjacent vertices. With just a few possible movements, these particles can be formed into different shapes like lines, triangles or hexagons [23], and perform distributed tasks such as leader election [19,26]. A universal shape formation algorithm within the Amoebot model was described by Di Luna et al. in [29]. An algorithm for solving the problem of coating an arbitrarily shaped object with a layer of self-organizing programmable matter was presented in [25] and analyzed in [22]. Kim et al. [59] generalized this model where each amoeba consists of two robots that simulate extend and retract by allowing at most two robots on a single cell. Other models with active particles were introduced in [71] as the Nubot model and in [50] with modular robots. Gmyr et al. [45] introduced a model with two types of particles: active robots acting like a deterministic finite automaton and passive particles. Furthermore, they presented algorithms for shape formation [44] and shape recognition [43]. Based on this model, Fekete et al. [32] presented algorithms to bound a given shape and for counting the number of particles or corners. They also introduced more complex geometric algorithms for copying, reflecting, rotating and scaling a given polyomino as well as an algorithm for constructing a bounding box surrounding a polyomino; however, this work did not account for connectivity of the particle configurations, which is critical for applications as the ones mentioned earlier.

Preliminaries
In the following, we introduce models, general definitions as well as a description of the underlying limitations.

Model
We consider an infinite square grid graph G = (V , E), where V = Z 2 is the set of pixels, and two pixels p 1 and p 2 are adjacent when || p 1 − p 2 || 1 = 1. We call two pixels a diagonal pair when both their x-coordinates and their y-coordinates differ by one. We use the compass directions (N , E, S, W ) for orientation when moving on the grid with a global orientation.
Every pixel of G is either occupied by a passive particle (i.e., a tile) or empty. Passive particles cannot move or manipulate themselves. A maximal connected set of occupied pixels is called a polyomino. A tile p of a polyomino P is called convex if there is a 2 × 2 square solely containing p. Throughout this paper, we denote the number of convex tiles by k.
The boundary of a polyomino P is denoted by ∂ P and includes all tiles of P that are adjacent to an empty pixel or that form a diagonal pair with an empty pixel (see also Fig. 3 (a)). Polyominoes can have holes, i.e., finite maximal connected sets of empty pixels (see Fig. 3 (b)). Polyominoes without holes are called simple; otherwise, they are non-simple. The bounding box bb(P) of a given polyomino P is defined as the boundary of the smallest axis-aligned rectangle enclosing but not touching P; see  We use a robot as active particle. This robot works like a finite deterministic automaton that can move around on the grid and manipulate the polyomino. Because we only consider one robot in this paper, the robot knows the global orientation. In particular, we may assume that the robot's local orientation and the global orientation match in the beginning. As there are only four possible orientations (looking north, east, south, or west), the robot can always return to the initial orientation. The robot has the ability to move along the edges of the grid graph, to change the state of the current pixel by placing or removing a tile on it, and to place a special marker on top of a tile. These markers are indistinguishable passive particles that allow the robot to recognize a specific tile. The Robot works in a series of Look-Compute-Manipulate-Move cycles.
Look Phase: The robot checks if it stands on a tile and if a marker lies on top. Compute Phase: The robot computes the next motion step based on the current state and the information received from the look phase. Manipulation Phase: The robot sets the state of the current pixel to empty or occupied, or places / removes a marker from a tile. Move Phase: The robot performs the computed motion step w.r.t. its local orientation, which is one of the form {up, right, down, left, ⊥} with ⊥ denoting no motion.
Note that we can extend the look phase by checking any constant sized neighborhood. In particular, we may assume that the robot is able to observe the state of all eight surrounding pixels. For this we define the following look-up functions w.r.t. the robot's local orientation. Further, many of the algorithms presented in this paper use a subroutine, where the robot moves into a given direction as long as there is still a tile in this direction. We denote this motion by appending most to the moving direction, e.g., rightmost.
In the following, we assume that connectivity is ensured if the union of all tiles and the robot is connected.

Constructing a Bounding Box
Fekete et al. [32] showed how to construct a bounding box around a polyomino. However, that algorithm does not guarantee connectivity. We describe an algorithm to construct the bounding box, maintaining connectivity after each step. To accomplish the required connectivity, we specify without loss of generality that the connection between bb(P) and P must be on the south side of the boundary. For easier distinction, we show the tiles of the original polyomino in blue, while those of the bounding box (which is composed of additional tiles that are added during the process) are shown in gray. Note that this is for illustrative purposes only; the robots cannot distinguish between those tiles. (We follow this convention in the illustrations throughout this paper.) The construction can be split into three phases: (1) finding a start position, (2) constructing the bounding box, and (3) clean-up.

Phase 1: Find a Start Position
To find a suitable start position, the robot R searches for a locally y-minimal pixel that is occupied by a tile; see Algorithm 1. This can be achieved by scanning the current row and moving down whenever possible. When there is no tile further down, R places a tile t with marker below the left most tile. Afterwards, R checks if there is sufficient space to start the bounding box below t, i.e., if there is no adjacent tile from P. With sufficient space, R can start constructing the bounding box and we proceed with phase (2). If not, we can restart phase (1) from the tile blocking construction. 1: function getStartPosition 2: findLocalMinimum 3: Move down 4: if bottom-row not empty then 5: Move to an occupied position 6: Go to Step 2 7: Place tile with marker 8: Move down 9: if bottom-row not empty then 10: x := bottom 11: Move down and place tile 12: Remove tile with marker and turn back 13: Change current pixel to state x 14: Move to one occupied pixel 15: Go to Step 2 1: function findLocalMinimum 2: Move rightmost 3: while isOnTile do 4: if bottom = empty then 5: Move down 6: Go to step 2 7: else 8: Move left 9: Move right Algorithm 1: Algorithm to find a valid start position to build the bounding box (left) and to find a local minimum (right).

Phase 2: Constructing the Bounding Box
The construction of the bounding box is performed clockwise around P, i.e., whenever possible, R makes a right turn. For this, several subroutines will be performed.
CheckTile: Starting at a tile t lying on a boundary, the robot follows this boundary until the marked tile is found. This function decides, if a boundary tile belongs to P or the current construction. See also Algorithm 2. ShiftLine: The last constructed line of the current construction gets shifted along the boundary of P. This routine returns true, if the line has been shifted. False is returned, if it is the first line of the construction. See also Algorithm 3. CheckTurn: Checks if a right turn is possible. If so, the robot performs the turn. See also Algorithm 4. Restart: When there is a tile t of P to the left of the starting position, the robot will not be able to construct bb(P) completely. When t is found, we call this routine to disassemble our construction to initiate a restart with phase (1) at t. See also Algorithm 5. Algorithm 2: An algorithm to check whether a tile belongs to P.
We will now show how the interplay of these subroutines constructs bb(P), see Algorithm 6. As long as we can extend the current line, we place a new tile and check if we can perform a right turn. At some point during construction, R finds a tile either belonging to P or to the current bounding box construction. To decide whether a tile t belongs to P or the current bounding box, we start moving around the boundary of 1: function ShiftLine 2: Move downmost 3: if Tile on the right contains marker then 4: return false 5: Move left 6: if Left-Column is empty then 7: Place tile 8: Move right 9: if top = empty then 10: Move up 11: Goto Step 5  Move up, remove tile, move down 4: while Not on tile with marker do 5: Remove tile 6: Move left 7: Remove tile with marker 8: Move left Algorithm 5: An algorithm initiate a restart.
the shape t belongs to. At some point, R reaches the marked tile. If R arrives from north then t is a tile of P, otherwise t is a tile of the bounding box. To find t again, we move to the south of the marked tile and follow the construction until we cannot move any further. From there we can carry on building bb(P). Now consider the two cases: If the tile does not belong to P, we are done with phase (2) and can proceed with phase (3). If it is a tile belonging to P, we need to shift the current line outwards and then continue the construction (see Fig. 4). If there are tiles blocking the shift process, then we deconstruct the current bounding box construction until we can shift again or until we can proceed adding tiles to the current line. If the line to shift is the first line of the constructed bounding box, we know that there exists a tile of P that has the same y-coordinate as the current starting position. Therefore, we build a bridge to traverse this gap, as shown in Fig. 5. Afterwards, we can restart from phase (1). Note that after a shifting process, the robot would perform a new check if it is still blocked. This would take O(|∂ P|) time for each tile on ∂ P. However, by keeping track of Top before and after the shifting process, the robot can identify a continuous line of P's boundary. Therefore, we can shift a line until we find a convex corner of P. Thus, we can modify the procedure such that CheckTile is called at most k times, where k is the number of convex tiles of P.

10:
if CheckTile then t is part of P 11: if not ShiftLine then 12:

Phase 3: Clean-up
We will now describe the final phase. A pseudocode for this phase can be found in Algorithm 7. Consider the case when R reaches a tile of the bounding box. Firstly, we prepare the clean-up phase by shifting the last line outwards until the next corner is reached (see Fig. 6(a)). Let this position be t. Then we can search for another suitable connection between P and bb(P), place a tile there, and move back to t. From there, we move to the marked tile to remove all tiles of the bounding box between the marked tile and t (see Fig. 6(b)-(d)). Note that during the preparation the robot may created a line of width two: When the last tile is placed underneath a corner that lies to the right, the robot continues construction until the next corner is hit. In order to remove the correct line in RemoveAppendix, we turn right whenever the next tile has a neighbor to the right and the top row contains at most two tiles (see Algorithm 7, RemoveAppendix, line 9). Note that the new connection between P and bb(P) may not be on the south side of P. If desired, the robot can simply add a new connection to any side and remove the old connection by moving around the bounding box. This way, we can also ensure that the connection will always be on the south side of P.
Theorem 1 Let P be a polyomino of width w and height h with k convex tiles. Constructing bb(P) such that bb(P) and P are always connected can be performed by one robot with one marker in O(max(w, h) · (wh + k · |∂ P|)) steps.

Proof Correctness:
It is straightforward to see that the robots will find a local y-minimum in phase (1): Consider a horizontal line the robot is on. If has tiles adjacent to the south, the robot eventually finds such tile by the scan from right to left. If has no tiles to the south, then is a local minimum and the robot will stop on the leftmost tile. By the simple check if there is sufficient space beneath this found local minimum, we can guarantee a suitable start position to construct bb(P).
For phase (2), we first prove that the membership test of a tile t is decided correctly by the robot. For that let F be the set of all maximally connected components of empty 1: function CleanUp 2: Move up 3: while Right = empty or Top = empty do 4: Preparation 5: Turn right by π/2 6: if marked tile is adjacent then 7: return 8: Move left andup 9: while Top = empty do 10: Move left 11: Place tile 12: Move right and down 13: Turn right by π/2 14: RemoveAppendix 15: Remove tile 16: Turn by π 17: while not isOnTile do 18: Move left 19: Place marker 1: function Preparation 2: Move down 3: while Bottom = empty do 4: Remove tile 5: Move left 6: Place tile 7: Move right 8: Move down 9: Move left 10: Place tile 11: repeat 12: Move up 13: until There are three neighbors 1: function RemoveAppendix 2: while Marked tile is not adjacent do 3: if Left = empty then 4: Move left, turn left by π/2 5: else 6: Move up 7: Move to and remove marked tile 8: Move south and turn to west 9: while Top-Row is not full do 10: Remove tile 11: Move up 12: if Right = empty then 13: Turn right by π/2 Algorithm 7: An algorithm to clean up the construction to obtain bb(P).
pixels. Assume that the tiles of the bounding box are placed in one of these connected components F ⊂ F. Then, t is adjacent to a position of F, and also the marker is placed on a tile that is adjacent to a position of F. Because the robot traverses a boundary of P, it never steps on a tile that is not adjacent to a position of F, and thus the robot eventually reaches the marked tile. It is straightforward that t must belong to P if the marker is met from above, because the robot started the bounding box construction below the marker. In summary, the robot can decide whether t belongs to P or to the bounding box.
For the remaining correctness proof, we show that the construction encloses P after phase (2). We show that (a) the tile of the construction placed last has distance two to the nearest tile of P using the L ∞ -metric, and (b) we do not construct loops not containing any tile of P. It is straightforward to see that (a) and (b) are true after phase (1). Now assume both are true after placing tile t. We will show that (a) and (b) also hold after placing the next tile t . Consider the operations from the algorithm.
Make a right turn: When we find a convex corner t corner , we perform a right turn.
Then t and t are within distance two of t corner . Shift line: Because the next tile would connect a tile t shift of P and t, a shift by one unit will not increase the distance between t (i.e., t shifted by one unit) and t shift . Deconstruct line: This is similar to the previous case. Consider the lowest tile t block of P that blocks further shifting. After deconstructing the current line two units below t blocked , the remaining last tile t of the construction has distance two to t blocked .
Combining all three cases, the last placed tile of the construction has a tile of P within distance two. Therefore, by induction, (a) holds for during the whole construction process.
Because we only perform a right turn after finding a convex corner of P, we must enclose at least one tile of P. Combining (a) and (b) it follows that we enclose P.
The easy structure of the construction after phase (2) make it straightforward to see that we can easily find a new connection between bb(P) and P, and move to the marked tile to remove unwanted tiles in phase (3).
Connectivity: While assembling the bounding box or checking the membership of a tile, there is always the marked tile that holds together P and the current construction. Whenever we have to build a bridge for traversing a gap, the constructed bridge between the previous starting position and the first intersection with P will not be removed until one robot ensures connectivity at this intersection. Finally, there is at least one connection between P and the bounding box when we are finishing the construction.
Time: Again, it is straightforward to see that phase (1) needs at most O(N ) ⊆ O(wh) steps to find a minimum. This includes also possible restarts from phase 2, because each maximal line of P can be visited at most once.
For phase (2), we split the runtime analysis into two parts: check a tile for membership and the actual construction. Analogous to [32], we show that in the actual construction every position within the final bounding box is visited a constant number of times for a fixed starting position in phase (2). Consider a pixel v within the final bounding box. At some point, v will be visited for the first time while constructing bb(P). Other visits are possible during shifting and removing the boundary tile placed on v. However, after a shift or removing the tile, which is part of the shifting process, we move away from v and never visit v again. Finally, there may be a constant number of additional visits while building a bridge for searching a new starting position. This results in O(wh) steps.
However, during the construction, we may need to restart up to max(w, h) times. Figure 7 shows a worst-case example. There are possibly up to max(w, h) starting positions s i that have a pixel somewhere to the left blocking the construction at some point during construction. Then, a pixel v could be visited after every restart of phase (2) implying that v can be visited up to max(w, h) times. This yields O(max(w, h)·wh) steps for the construction process.
For every tile that leads to a conflict during construction, the decision of whether that tile belongs to P, or the bounding box is completed by using the subroutine checkTile in Algorithm 2. This subroutine takes O(|∂ P|) steps for tiles of P and O(|C|) steps for tiles on the current construction C of bb(P). It is also straightforward to see that O(C|) ⊆ O(|∂ P|): Every tile of P can be charged with constant many tile of C. To this end, consider rays emanating from a tile t ∈ C. Then at least one ray hits a tile from P. Any tile of ∂ P can only hit by at most four of these rays. If no ray hits a tile of P, then t must be a corner or adjacent to a corner of C. Because we only make turn at convex tiles, C can have at most k convex tiles. Therefore, these convex tiles and their neighbors can be charged to one convex corner of δ P. In total, any tile of δ P is charged with O(1) cost. As described above, we can shift a line until we reach a convex corner of P without repeating a membership test. Thus, we only need to check for O(k) tiles if they belong to P or bb(P). Therefore, we have a total of O(max(w, h) · (wh + k · |∂ P|)) steps.
For phase (3) note that the robot moves at most twice over each tile of the current construction. Again, the number of these tiles can be bounded by O(|∂ P|). Thus, the time complexity of phase (2) dominates the total time complexity.
If we know in advance that the given polyomino contains no holes, then we can build a non-simple bounding box. Because we can always look for a hole to distinguish tiles from P and the bounding box, we require only a single robot without any markers. In particular, we adapt our algorithm as follows.
-The first bounding box element, which is placed right beneath a possible starting position has two vertically consecutive unoccupied pixels. (see Fig. 8 (a)). -Instead of creating a boundary of width one as described before, we construct it as a strip of width three, consisting of an outer, middle and inner lane. On the middle lane, every second pixel is unoccupied. Because there are no holes within simple polyominoes, the robot can easily distinguish between P and the bounding box (see Fig. 8 (b)). -When the robot recognizes that there is a tile t of P to the left of the starting position, we build the bridge as shown in Fig. 9: We add the gadget of Fig. 8 (c) to t and afterwards deconstruct the bounding box beginning with the starting position. Now we can restart with phase (1). -The minimum distance between P and bb(P) can either be two or three and may differ for every side of the bounding box. Because it may be necessary to search for a new connection between bb(P) and P while finishing the construction, and the minimal distance between the southern bounding box and P could be three, we need a second connection element, shown in Fig. 8 (d), with three vertically consecutive unoccupied pixels. For an example, see Fig. 10.
This yields the following corollary.

Scaling Polyominoes
Now we consider scaling a given shape by a positive integer factor c. We start by increasing the scale of the shape (upscaling, i.e., c > 1) in Sect. 4.1, before considering how to decrease the size (downscaling, i.e., 1 c < 1) in Sect. 4.2.

Upscaling
In the following we assume that the robot has already built the bounding box and is positioned below the marked tile. See Figs. 2 and 11. The scaling process can be divided into two phases: (1) the preparation phase, and (2) the scaling phase. In phase (1) we proceed as follows (see Algorithm 8).
-We fill up the last, i.e., rightmost column within bb(P) except for the topmost pixel, -add a tile in the second last column above the south side of bb(P), -remove the lowest tile (called column marker) and third lowest tile (called row marker) on the east side of bb(P) (see Fig. 11(a)). This yields three columns within the bounding box (including bb(P) itself). The first (from west to east) is the current column of P to scale. The second column, is used to ensure connectivity and to decide if we finished scaling the current column. The third column marks the current overall progress, i.e., we can find the pixel in the correct current column and row that we want to scale next.
After this preparation, we can remove the marked tile that was used for connectivity in the beginning. Note that in special cases the marked tile had distance two to the right side of bb(P). In this case, we move the marker one unit to the left during the preparation. See Algorithm 8 line 4.

1: function scalePreparation 2:
Move rightmost 3: Move left twice and up 4: if is on marked tile then 5: Remove marker and move left 6: Place tile with marker and move right 7: Place tile and move right 8: while Top = empty do 9: Place tile and move up 10: Move right 11: Move downmost 12: Remove tile and move up twice Mark current column 13: Remove tile and move down Mark current row 14: while not on marked tile do 15: Move left 16: Remove marked tile and move down Algorithm 8: An algorithm to initialize scaling P.
In phase (2) we consider four main operations using three variables. b col denotes whether we scaled the last pixel of the current column, b pixel denotes the state of the pixel that we want to scale, and b new denotes whether we started scaling up a new column. We initialize phase (2) with b col := 0, and b new := 1.

Initialize next scaling:
The robot moves along the bottom side of bb(P) until it finds an empty pixel. This is the column marker. Then we check if we need to prepare the next column. See Algorithm 9 left. Afterwards, we scale the next pixel. Prepare next column: If b col = 1, then we prepare the next column. We move the column marker one pixel left and remove the tile two pixels above the column marker, i.e., we place the row marker. In addition, we place a tile one pixel above and two pixel to the left of the column marker. If this pixel was already occupied, then we completely scaled P and we can move on to phase (3). See Algorithm 9 right. Scaling the next pixel: We start from the column marker and move up until we reach the row marker. We place a tile, move one pixel up and set its state to empty. If there is no tile to the left, then we are about to scale the last pixel in the current column. Let b col denote whether the pixel was empty or not. Then the robot moves to the pixel that is scaled next, i.e., the robot moves one pixel down and two pixels left. Move left and remove tile 4: Move down 5: Move left twice 6: b fin = isOnTile 7: Set pixel to occupied 8: Move down and right 9: Remove tile 10: return b fin Algorithm 9: An algorithm to find the column marker and to prepare scaling the next column.
As seen in Algorithm 11, we iterate through these operations until we scale a column that only contains empty pixels. This is recognized when trying to place a tile during the preparation of the next column. See Algorithm 9 right, line 6. Afterwards, we start the clean-up phase. We remove all tiles from the old bounding box area, proceeding Move leftmost 4: if not b new then 5: Move upmost 6: Place c × c square* above 7: else 8: Place c × c square* left 9: Move to the right of the square Algorithm 10: An algorithm to scale the next pixel. *: While constructing the square, we leave out the middle pixel if b pos is false.
Algorithm 11: An algorithm to perform phase 2 of the scaling procedure using Algorithms 9 and 10.
column-wise from right to left. Due to the simple structure, we know that we finished removing this area when the removed column has no empty pixel. If necessary, all scaled empty tiles can also be removed. For each scaled column (e.g. from left to right), we remove empty scaled pixels from top to bottom until we find a scaled occupied pixel t. Then we remove scaled empty pixels from bottom to top until we reach t again. This way, the whole arrangement is always connected.

Theorem 2 After building bb(P), scaling a polyomino P of width w and height h by a constant scaling factor c without losing connectivity can be performed with a single robot in O(wh · (c 2 + cw + ch)) steps.
Proof Correctness: We scan through the whole bounding box of P and scale every pixel. This implies that we scale every tile of P. Because we scale column-wise, we ensure that every scaled tile is built at the correct position. Connectivity is guaranteed because we never remove a tile that is necessary to preserve connectivity.
Time: Each of the w · h pixels within the bounding box of P is scaled. To this end, the robot has to move O(c(w + h)) steps to reach the position at which the scaled pixel needs to be constructed. A further O(c 2 ) steps are needed to construct the tile. Finding the next pixel to scale takes O(c(w + h)) steps, including going back, finding the correct column and row, and moving the row and column marker. In total we have O(wh(c 2 + cw + ch)) steps.

Downscaling
In this section, we show that a shape P that is already scaled up by a factor c > 1, can be downscaled to its original size, i.e., we scale the shape by the factor 1 c . We assume that the scaled area, i.e., the cw × ch area containing P, is filled with scaled empty pixels (i.e., c × c squares with their middle tiles missing) and the scaled tiles of P. If this is not the case, we can simply fill up this area until we obtain a rectangular box. See Fig. 12 for an arrangement that satisfies these conditions and Fig. 13 for an overview of the construction.
In the following, we describe a strategy that positions the downscaled version of P at the bottom right corner of the scaled area. Similar to our other strategies, we proceed in three phases: (1) the preparation phase, (2) the downscaling phase, and (3) the clean-up phase.
In phase (1), we start building a vertical line v on the right side of the scaled area starting to the right of the top right corner. We construct the line downwards until the last tile t s of v has no tile to its left. The line v will guarantee connectivity throughout the downscaling process, and we can use t s to recognize the start of the scaled area. Then, from the tile above t s , we construct a horizontal line h of length three and place a further tile above the rightmost tile of h . We use h for indicating where we want to construct the downscaled version of P. In particular, the last tile of h marks the current column of P we are processing. See Fig. 12 for the configuration after the preparation phase. See also Algorithm 12 for pseudocode of phase (1).
In phase (2), we downscale P from left to right and from bottom to top. We use the Boolean variable b new to decide whether to start a new column in the next iteration or not. We initialize phase (2) with b new = 1. With b pixel we store the state of the scaled 1: function initScaleDown 2: Move to the left side of an c × c square.

3:
Move upmost 4: Move rightmost 5: Move right 6: while Left = empty do Construct v 7: Place tile and move down 8: Place tile and move up Place t s 9: Repeat three times: Move right and place tile Construct h 10: Move up and place tile 11: Move down Algorithm 12: An algorithm to initialize downscaling.  Move downmost 8: if Right = empty then 9: Move up 10: Move rightmost 11: Move upmost 12: if not b new then 13: Move up, place tile 14: Move down 15: Move left 16: Set pixel to state b pos 17: Move right 18: Move downmost 19: if b new then 20: Move right 21: Place tile and move up 22: Place tile and move down 23: return b new Algorithm 13: An algorithm to scale a shape down. Figure 13 shows an example for phase (2). In the clean-up phase (3), we remove the auxiliary structures, first t 2 , then v from top to bottom. Afterwards, we can remove the rightmost tile of h , the tile above it and the last column from top to bottom, which is not part of the polyomino. To remove the rest of h , we start to remove the line from the right to left until there is a tile t of the polyomino above h . Then we remove the remaining part of h from left to right until we find t again. Only the downscaled version of our original shape remains.  Proof Correctness: We prove that (a) we scan the columns completely from bottom to top, and (b) we downscale each scaled pixel at the correct position. Assume that we leave out one scaled pixel p in a column. Then we will not consider the scaled pixels above p and we start a new column. This, however, requires that the robot has not seen any tile above the previous scaled pixel. Thus it must have been the last scaled pixel in the column and p does not exist.
Consider a scaled pixel p that we downscale next. Because the column above the rightmost tile of h shows how many pixels are already downscaled in the current column, we will find the correct position to downscale p.
Due to the simple structure, the clean-up phase is straightforward. Connectivity: Similar to the upscaling operation, the column above the rightmost tile of h guarantees connectivity of the downscaled area. For this, consider any connected shape P, we can cut through P with a vertical line and add tiles along this line. Clearly, this structure is still connected. Because all tiles have a connection to this vertical line, we can remove everything to the right of the line without loosing connectivity..
Similarly, v preserves connectivity of the upscaled area with the downscaled area, especially when processing the last column.
Time: Phase (1) takes at most O(ch) time to construct v and O(1) to construct h . In phase (2), for each scaled pixel we get its state in time O(cw + ch). Removing this scaled pixel needs O(c 2 ) time, scaling it down takes another O(cw + ch) steps. Because there are wh many scaled pixels, we need O(wh · (c 2 + cw + ch)) steps for phase (2).
Removing the auxiliary structures in phase (3) needs only O(ch) steps to remove v and O(w) to remove h . For all three phases, we get a total runtime of O(wh · (c 2 + cw + ch)).

Scaling Monotone Polyominoes
When the polyomino P is x-or y-monotone, we can scale P using two robots without constructing a bounding box. P is called x-monotone (y-monotone) if the intersection with any vertical (horizontal) line with P is a connected set. See Fig. 14 for a polyomino and its scaled version. In the following we consider an x-monotone polygon P. We proceed in two phases: (I) scaling the columns of P vertically, (II) scaling the columns of P horizontally.

Phase I
During the first phase, we process the polyomino column-wise from left to right to scale the columns of P vertically by the factor c. The marker is placed on the uppermost tile of the current column. For every tile in that column, the robot moves the marker one unit down. If there is no further tile, the robot keeps the marker. The robot extends the current column on the upper side by c − 1 tiles and moves down until the marker or the end of the column is reached. In the latter case, the current column is finished. See Fig. 15 for an example.
To scale the next column, we consider three cases. The lowest tile of the next column may have an equal, a higher or a lower y-coordinate than the lowest tile of the current column. Let t n (t c , resp.) be the lowest tile of the next (current, resp.) column and y t n (y t c , resp.) the y-coordinate of that tile. The three cases are handled as follows; see also Algorithm 14.
1. y t n = y t c : We can simply continue with the next column, see Algorithm 15. 2. y t n > y t c : Before moving to the next column we have to scale empty pixels. For each empty pixel t e below t n with y-coordinate y t e ≥ y t c , we move every column to the right of the current column c − 1 units up. This can be done by marking the next empty pixel and by letting the robot shift the columns up. The shifting process can be done by adding c − 1 tiles above each column and afterwards removing c − 1 tiles from the bottom. See also Algorithm 16 for Pseudocode, and Fig. 16 for an example. 3. y t n < y t c : This case is more complex because it is not immediately clear in which direction all remaining columns have to be shifted in order to scale the next column correctly. We perform a scaling of the next column and a shifting of remaining columns at the same time. We proceed as follows. Let t be the tile with y-coordinate y t = y t c . We scale the column from top to t as described above, i.e., we run mono-toneCaseI until we remove the marker from a pixel for which left is occupied and bottom-left is empty. For each tile below t starting from the bottom, we add c −1 to the bottom of the column and shift all columns to the right c −1 steps down, which can be performed analogously to the shifting process from monotoneCa-seII. Note that this process is completed when the robot returns to the marker and when the marker is to the right of t c , i.e., bottom-left is empty and left is occu- An algorithm to scale a monotone shape. Algorithms for mono-toneCaseI and monotoneCaseII can be found in Algorithm 15 and 16, respectively. We leave out the Pseudocode for monotoneCaseIII as it is analogously to a combination of the previous two.
pied. We leave out the Pseudocode for monotoneCaseIII as it is analogously to a combination of the previous two cases. See Fig. 17 for an example. We can now proceed with the next column.

Phase II
When all columns have been scaled vertically, we proceed with phase II to scale the columns horizontally. The idea of phase II is as follows. Proceed column-wise; for a column C shift all remaining columns c − 1 steps to the right to make space for 1: function monotoneCaseI 2: Move upmost 3: Place marker 4: while isOnTile do 5: Take marker, move down 6: if isOnTile then Place marker 7: Move upmost 8: loop c − 1 times 9: Move up and place tile 10: while bottom = empty and marker not reached do 11: Move down 12: if Tile contains marker then 13: Remove marker 14: Move down 15: Move up 16: while Right = empty and Top = empty do 17: Move up Algorithm 15: An algorithm to scale the current column if y t n = y t c .
1: function monotoneCaseII 2: while Left = empty do 3: Move down 4: while not isOnTile do 5: Place tile with marker and move up 6: while not isOnTile do 7: Move up 8: Move left 9: repeat Add c − 1 tiles above remaining columns. 10: Move right 11: Move upmost 12: Add c − 1 tiles above the column 13: while Right = empty and Bottom = empty do 14: Move down 15: until Right = empty 16: Move downmost 17: repeat Remove c − 1 tiles from the bottom of remaining columns. 18: loop c − 1 times 19: Remove tile and move up 20: while Left = empty do 21: Move up 22: Move left 23: while down = empty do 24: Move down 25: if Marked tile lies to the right then 26: Move right 27: until On marked tile 28: Remove marked tile and move up 29: monotoneCaseI Scale tiles in current column Algorithm 16: An algorithm to scale the current column if y t n > y t c . *Note that we can recognize the stop, if there is a marker somewhere to the right. building c −1 copies of C (see Fig. 18). To identify C in a later step, we place a marker on the bottom most tile of C. Clearly, we cannot simply shift a column c − 1 steps to the right, as this would disconnect the shape. Instead, we process the columns from right to left until we reach C and shift the columns in the following way.
For a column C , copy it c−1 times to the right. Then, starting from the bottommost tile of C , we remove c − 1 tiles to the right leaving the tile of the rightmost copy of C . We repeat this process with the rows above until we find a row with a tile t of C that has an adjacent tile to the left. Note that there is no tile below t. Thus, we can simply remove rows of C and c − 2 copies from the top as long there is a tile below the left most tile.
After this clean-up, the rightmost copy of C still exists and is connected with its previous column by a bridge. We can now proceed with the column to the left of t. If this column is C, then we perform the same steps without the clean-up phase. See also Algorithm 17 for Pseudocode. 1: function monotonePhaseII 2: Move downmost and place marker 3: moveToRightmostCol 4: b found = scaleCol 5: while not b found do 6: while Left = empty do 7: loop c − 1 times 8: Remove tile and move right 9: Move up and c − 1 times left 10: Move topmost 11: while Bottom = empty do 12: loop c − 1 times 13: Remove tile and move right 14: Move down and c − 1 times left 15: Move left and upmost 16: b found = scaleCol 17: Move c times right 18: while Top-Left = empty do 19: if isOnTile then Goto Line 2 20: Move up 1: function moveToRightmostCol 2: while Top = empty do 3: Move up 4: if Right = empty then 5: Move right 6: Move downmost if Tile contains marker then 5: b found = 1 6: Remove Marker 7: loop c − 1 times 8: Move right, place tile 9: Move c − 1 times left 10: Move down 11: Move up 12: return b found Algorithm 17: An algorithm for the second phase to scale monotone shapes.

Theorem 4
Scaling an x-monotone polyomino P with N tiles, width w, and height h by a constant scaling factor c without losing connectivity can be done with two robots in O(wc 2 N ) steps.
Proof Correctness phase I: Scaling the first column is correct, because for each tile we add c−1 tiles to the top of the column, which results in scaling the column by factor c. Furthermore, the lowest tile t c of the first column still has the same neighbor t (either an empty pixel or a tile) with the same number of empty and occupied pixels above and below t. We use this fact as an invariant to prove that the remaining columns are also scaled correctly. Now assume we correctly scaled the first k columns. In the first case, when y t c = y t n , we scale the next column similar to the first column. Therefore, the lowest tile still has the same neighbor after scaling. Now consider the i-th tile t i in the column from below before scaling. Then, t i moves c(i − 1) units upwards after scaling the first i − 1 tiles. This results in t i having its correct neighbor to the left, namely the i-th pixel from the previous column (note that we can consider all empty pixels above any column already scaled). Thus, after scaling all tiles, the neighbors to their left are all correct. In conclusion, the invariant still holds for the first k + 1 columns for the first case. For the second case (y t c < y t n ), we shift all remaining columns by c − 1 steps up, such that t n has the correct neighbor to the left. Note that t n maintains its right neighbor during the shifting process. Thus, after the shifting process, the invariant holds and we can scale the column.
In the remaining case, we can scale all tiles in the next column with y-coordinate at least y t c , which does not change the invariant for the first k + 1 columns. When scaling the lower tiles, we shift all remaining columns down, such that t n keeps it neighbor to the right. Thus, after scaling this complete column, the invariant holds for the first k + 1 columns.
By induction, we correctly scale the columns. Correctness phase II: To prove the correctness of phase II, we show that the shift of columns is performed without losing connectivity. The scaling is done within the shifting process by ignoring the clean-up for the last column. Thus, a repeated shifting phase scales the polyomino.
Consider the rightmost column. After copying this column c times, the whole polyomino is still connected. In the clean-up phase, we keep a bridge between the shifted column and the next column, maintaining connectivity. This bridge can then be used to copy the next column. By induction, we can shift n columns without losing connectivity.
Combining phase I and II, we scale the polyomino by the factor c.

Adapting Algorithms
As shown in [32], there are algorithms that may not preserve connectivity. An immediate consequence of being able to scale a given shape is that we can simulate any algorithm A within our model while guaranteeing connectivity: We first scale the polyomino by three and then execute A by always performing three steps into one direction if A does one step. If at some point the robot needs to move through empty pixels, then we place a 3 × 3-square with the middle pixel empty (if a clean-up is desired at the end of A, i.e., removing all scaled empty pixels, we fill up the complete row/column with these squares). This guarantees connectivity during the execution and we obtain the following theorem. Proof Approach:

Theorem 5 If there is an algorithm
The first step is to scale the polyomino P of width w and height h by a factor c = 3 with the strategy above. We keep any 3 × 3 square in the clean-up phase of the scaling algorithms. This gives us a 3w × 3h rectangle containing the scaled polyomino and 3×3 segments representing empty pixels from the w × h area of the initial polyomino.
We adapt the algorithm A as follows. When the robot places a tile in A, then we place a tile in the middle of the 3 × 3 square in A . A removal in A is represented by removing the middle tile of the 3 × 3 square in A .
For each step the robot moves into direction d in A, we move 3 steps into direction d in A , i.e., the robot effectively moves on a grid scaled up by a factor of three (see Fig. 19(a)). If the robot reaches a pixel at which no 3 × 3 square is present (see Fig. 19(b)), then the robot adds such a square representing an empty node and leaves the middle bottom tile missing (see Fig. 19(c)). Then the robot fills up the complete row/column with 3 × 3 squares and returns to the pixel at which the middle bottom tile is missing (see Fig. 19(d)). From there we can continue the execution of A.
Analysis: The scaling procedure requires O(wh · (w + h)) steps. Due to the described movement adjustment of doing three steps in A instead of one step in A, the runtime of A increases by the constant factor three. Finally, we consider the fill-in procedure to be used in case of stepping on an empty pixel. Depending on the robot's movement area for A, we get O(max((w −w)h , (h −h)w )) steps for filling in. This results in an overall runtime of O(wh ·(w+h)+max((w −w)h , (h −h)w )+T (A)) steps.

Conclusion
We have demonstrated how geometric algorithms for finite automata can be used to enable very simple robots to perform a number of fundamental construction tasks while preserving connectivity. At this point, the main focus of our paper has been a feasibility study of the considered problems rather than a tight analysis of the proposed solutions; as a consequence, non-trivial lower bounds have yet to be established. There is also a whole range of possible extensions. Is it possible to scale general polyominoes without the preceding bounding box construction? A possible approach is to cut the polyomino into a subset of monotone polyominoes, which could be handled separately. Expanding the existing repertoire of operations to three-dimensional configurations and operations is another logical step. An equally relevant challenge is to develop distributed algorithms with multiple robots that are capable of solving a range of problems with the requirement of connectivity, without having to rely on the preceding scaling procedure that we used in our work. Other questions arise from additional requirements of real-world applications, such as the construction and reconfiguration of space habitats.
Funding Open Access funding enabled and organized by Projekt DEAL.
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by/4.0/.