To build districts in each ensemble, this algorithm uses Monte Carlo Markov Chains, implemented by the Gerrychain library. Monte Carlo Markov Chains combine the Monte Carlo method, which draws random samples to form an estimate of the probability distribution, with Markov Chains, which use the previous outcome to generate a new outcome. When the Markov Chain's new outcomes have low correlation with the previous outcome, the probability distribution it produces is more representative of random sampling, so a Monte Carlo Markov Chain can produce a very close approximation to the probability distribution of a completely random ensemble. More details can be found in Dr. Daryl DeFord's tutorial.
Sometimes, a state's electoral map is so skewed that any set of districts that has any correlation at all with the original map is biased as well. To ensure that districts in the computer-generated ensemble are independent of the initial state (the state's electoral map), we use the Recombination method, which produces outcomes with far lower correlation with the initial state. The essence of this algorithm is to combine two adjacent districts, draw a minimum spanning tree, then sever a single connection in this tree to separate these two districts again. Details on this method can be found on the Metric Geometry and Gerrymandering Group's website.
To ensure that districts are drawn to be "reasonably" compact (i.e. they don't look like the image below), the algorithm only accepts the redrawn district if it satisfies a compactness bound. In the case of this program, this bound limits the number of cut edges (neighboring precincts in separate electoral districts) at 115% of the amount of cut edges in the enacted plan.
All code used to produce all parts of this website, including the graphs and maps, can be found on my GitHub repository.