We propose three novel gerrymandering algorithms which incorporate the spatial distribution of voters with the aim of constructing gerrymandered, equal-population, connected districts. Moreover, we develop lattice models of voter distributions, based on analogies to electrostatic potentials, in order to compare different gerrymandering strategies. Due to the probabilistic population fluctuations inherent to our voter models, Monte Carlo methods can be applied to the districts constructed via our gerrymandering algorithms. Through Monte Carlo studies we quantify the effectiveness of each of our gerrymandering algorithms and we also argue that gerrymandering strategies which do not include spatial data lead to (legally prohibited) highly disconnected districts. Of the three algorithms we propose, two are based on different strategies for packing opposition voters, and the third is a new approach to algorithmic gerrymandering based on genetic algorithms, which automatically guarantees that all districts are connected. Furthermore, we use our lattice voter model to examine the effectiveness of isoperimetric quotient tests and our results provide further quantitative support for implementing compactness tests in real-world political redistricting.Representative democracies must necessarily group constituents into voting districts by partitioning larger geographical territories. Gerrymandering is the act of purposely constructing voting districts which favour a particular electoral outcome. In the United States the power to draw district lines within a state belongs to the state legislature or districting commission. Thus, self-interested politicians with this authority could gerrymander -manipulate the district lines of their territory -to maximize the electoral outcome for their own party. Gerrymandering for political gain is morally questionable as it reduces the power of the electorate, and this practice is not restricted to any political party or country. Indeed, the Supreme Court of the Untied States has recently heard two gerrymandering cases, the first Gill v. Whitford [2018] concerned the 2011 redistricting plan for Wisconsin due to Republican legislators, and the second Benisek v. Lamone [2018] was regarding changes made to the boundaries of Maryland's 6 th district by the Democratic Party. Furthermore, in principle, there are instances in which elaborate redistricting could be applied with benevolent intent, such as ensuring the proper representation of minority groups (based on ethnicity, religion, or other identifiers) which are not spatially localized. Such majority-minority districts have also been the focus of Supreme Court hearings, e.g. Shaw v. Reno [1993] and Miller v. Johnson [1995].