Needing to redraw North Carolina's legislative districts under a court order, lawmakers last year employed a state lottery machine to select a new map at random.
Courts had ruled the previous map unfair, due in part to testimony by mathematicians and computer scientists who showed how the plans had been drawn to weaken the state Democratic Party.
To fix the issue, the lottery machine was loaded with maps deemed to be more equitable, drawn by a computer program written by Jowei Chen, a University of Michigan professor of political science.
"Back in the day, this was something that would take you weeks to do with pen and paper," Chen told the Thomson Reuters Foundation.
"Now, my laptop can draw one computer-simulated map in a minute."
The techniques of Chen and other researchers are coming under the spotlight ahead of the U.S. election on Nov. 3, after which officials will be using 2020 Census data to redraw the lines for thousands of legislative districts.
Redistricting is done every 10 years to reflect changing demographics as reported in the census, also done every 10 years.
"It'll be consequential for the political playing field over the whole next decade," said Sam Wang, a professor of neuroscience at Princeton University and founder of the Princeton Gerrymandering Project, a group studying election mapping.
'A perfect storm'
Wang and other experts are on the lookout for gerrymandering, a technique used to manipulate district lines in such a way to advantage or disadvantage a particular group.
An unfair map might split Black voters into several districts to dilute their voting power or spread Republican voters across districts to make it easier for Democrats to win majorities.
Some gerrymandering is illegal, but it is not always easy to prove or detect.
"For years it was hard to say for when a map went too far," said Michael Li, a lawyer who works on the issue at the Brennan Center in New York, a civil rights group.
In dozens of court cases across the country researchers like Chen have presented evidence to help challenge districts drawn after the 2010 census and in some cases forced their redrawing.
Recent advances in supercomputers, algorithms and advanced mathematics have made it possible to study, detect, and push back more precisely against maps designed to skew elections.
"It's a perfect storm," said Wang. "We see increases in the partisanship and political polarization that leads to gerrymandering, and at the same time, we have big advances in computing for detecting and studying it."
'A bug in our democracy'
The term gerrymandering emerged out of a 19th century effort by Massachusetts Gov. Elbridge Gerry to manipulate the state's maps to benefit incumbents.
"It's a bug in our democracy," said Wang. "Legislatures have the power to draw their own lines, and they create the system they run under, opening the floodgates to self dealing."
The development of advanced mapping software over the past decade made it even easier for incumbents to draw maps that might subtly skew in their favor, said Gregory Herschlag, a mathematician at Duke University in North Carolina.
Duke, Tufts University in Boston, Princeton and other universities have created dedicated programs to study gerrymandering and train researchers to testify in court cases.
In 2017, Sandra Covington and a group of Black North Carolina residents were locked in a multi-year legal battle trying to show that the state's legislative map unfairly concentrated Black voters in 28 districts, diluting their vote.
They called upon Herschlag, who used his computer to draw thousands of potential maps and compared his results with the existing map, a technique called the ensemble method or outlier analysis.
He examined whether Black voters were clustered in a way that looked atypical when compared with thousands of possible map variations and noticed something was amiss.
"The racial makeup was highly atypical of a plan that was drawn neutrally without regards to race," Herschlag said.
The case made its way to the U.S. Supreme Court, and the legislature was forced to redraw a number of district maps.
So far, such techniques have mostly been used in court to show that maps have been drawn unfairly to benefit a particular political party or racial group.
The real test will come after the November election, when lawmakers could draw on the emerging suite of technical tools to devise fairer maps or double down on gerrymandering, Wang said.
He is particularly hopeful that a number of states that have set up independent commissions to draw the new districts will use the newest technology.
Wendy K. Tam Cho, a senior research scientist at the National Center for Supercomputing Applications, said the new techniques are not a panacea and communities still must decide what a fair map looks like.
"How do you measure fairness?" Cho said. "The computer isn't going to answer that."
(Writing by Avi Asher-Schapiro @AASchapiro, Editing by Ellen Wulfhorst.)