The input to this algorithm is an extended affine permutation of size n. An extended affine permutation of size n is a map f from the integers to the integers, with two requirements. First, the numbers f(1) through f(n) must represent the equivalence classes , mod n, of the numbers 1 through n. Secondly, there is a kind of periodicity, namely that f(i + n) = f(i) + n. So then, the values of f are specified by its output on any consequitive n integers. Usually, the map f is described by listing the values f(1) through f(n), in brackets. This is called the 1,...,n window of the permutation. An affine permutation (as opposed to an extended affine permutation) has the additional property that the sum of the numbers f(1) through f(n) is the same as the sum of the numbers 1 through n. For example, with n = 4, using the 1,...,4 window, [0, 2, 7, 1] is an affine permutation, as is [-1, 5, 14, -8]. The permutation [3, 1, -2, 4] is an extended affine permutation but not an affine permutatio.
This page can be used in two ways. First, you can have the page generate a random affine permutation. To do that, enter the size of the desired permutation in the first textbox. You can choose any positive whole number up through 20 for n. The degree of spread in randomness is controlled by the textbox to its right. For that, you can choose any whole number up through 5.  Once you have entered this information, click the Run button directly to the right. Alternatively, press Enter while in one of these two textboxes. This will display a random affine permutation and the output of the AMBC algorithm when applied to that affine permutation. The most recent output is added at the top.
Instead, you can enter an extended affine permutation in the textbox labeled "Permutation". Enter the 1,...,n window for the permutation. The numbers should be separated by commas, with or without spaces between the numbers, with or without square braces. That is, you can enter 0,2,4 or 0, 2, 4 or [0,2,4] or [0, 2, 4]. Then, click the Run button to the right of the Permutation textbox, or press Enter while in the textbox. The most recent output is added at the top.
You can use the Clear Top Item and Clear All buttons to remove output from the page.
One use case for this page is for research. You can use the page to run multiple permutations, and then save the results to a PDF. The Comment textbox allows you to enter additional information, for example, a reduced expression for the permutation. This information will be displayed, to the right of the permutation, in the output. Pressing Enter when in the Comment textbox will run the permutation which is entered in the Permutation textbox.
When you're ready to print your results to a PDF, you can, if you like, use the Reverse Output button to reverse the order in which the results are displayed, so that the first results are on top. Also, you can hide the controls. To do this, click the little black box to the right of the Information button. Then press Ctrl-P (or right-click and select Print) to print the page to a PDF. After that, you can click the black box again to reveal the controls.
As an alternative to printing to a PDF, you can also save your output by saving the page as Web Page, complete.
This is a port to JavaScript of Mike Chmutov's Java code for the Affine Matrix Ball Construction algorithm. The original code can be found here: https://github.com/mchmutov/AMBC. The drawing code and the code to run the webpages are borrowed from the pages on my site: https://devragj.github.io/. Two papers describing the Affine Matrix Ball Construction can be found at these links: Matrix-Ball Construction of affine Robinson-Schensted correspondence, Monodromy in Kazhdan-Lusztig cells in affine type A. The second paper has a more condensed description of the algorithm.
Please contact me at devra.johnson at verizon.net.