This video is aiming to demonstrate that 2D binary sorting can easily be done by writing simple shape rules in the DrawScript mode in Shape Machine. Instead of writing code to sort binary digits, Shape Machine allows users to visually program this logic by considering the symbols 0 and 1 as shapes drawn in shape rules. The initial shape consists of a 4X4 binary matrix of 1s and 0s in a random order both vertically and horizontally. The first shape rule specifies the horizontal sorting: when this rule is applied, all 1s will go to right and all 0s will go to left (big-endian order). The second shape rule specifies the vertical sorting: when this rule is applied , all 1s will go down and all 0s will go up. If we apply the first rule multiple times we will sort the 0s and 1s horizontally and if we apply the second rule multiple times, we will sort the 0s and 1s vertically. In the first example, all 1s will go to down-right corner. If we want to sort in different ways, we can easily swap the left-hand-side and right-hand side in alternative ways to sort the 1s and the 0s in the other corners of the matrix respectively. |