# Bubble Sort Design

### From AgentSheetsWiki

This project is an implementation of one-, two- and three- dimensional Bubble Sort. Bubble sort is a simple sort algorithm in which adjacent numbers (represented as colors) get swapped if they are in the wrong order. AgentCubes is used in this case to visualize how the algorithm works. Please note that there is no centralized control in this implementation. Every bubble at each moment in time is ready to swap itself. A simple generalization of this approach leads to the 2D version of bubble sort in which numbers bubble horizontally as well as vertically.

## Category

- Computer Science

## Explorations

- Run the "1D Bubbles" world to see how numbers are sorted in a single dimension. Bubbles are sorted according to a single value. Step the simulation to see the sorting step by step. Or use a slower speed on the animation slider.
- Run the "2D Bubbles" world for two-dimensional sorting: the bubbles are sorted according to two values, Red and Green.
- Run the "3D Bubbles" world for three-dimensional sorting: the bubbles are sorted according to three values, Red, Green, and Blue. Sorting takes place in multiple layers.
- Use the "2D Bubbles 2500" for sorting a large number of bubbles
- Run the "2D partial sorts". Once the two separate clusters are sorted, select the 2D bubble in the Agents list and make pathways to connect the two clusters, while the simulation is still running.
- Be the bubble! Select a bubble and go into first-person camera mode and play the simulation. Make sure the speed slider is not at the fastest setting so you can see the animation. You can then watch the sorting take place from the perspective of a bubble.
- Create your own worlds of 1D, 2D, and 3D bubbles.

## Acknowledgements

- Simulation built by Alexander Repenning