Gerrymandering

(remixed from more tiles, by ephan012)

Project Description

Use this project to simulate elections to explore gerrymandering.

Press the green flag to start up the simulation. 63 (9 x 7) cells (neighborhoods) are generated. The color suggests the political leanings of that cell red-to-blue. (The neighborhoods are defined in a script in the Districts sprite.) The population for each cell is randomly assigned when the green flag is pressed.
Click on any cell to see its cell number and its population.

In the default map, the overall election tends to lead to the red party winning. Click the script to broadcast “Election Day” to see what the overall election result will be. Each election has a random element but the red/blue ratio is defined by the color of the cell/neighborhood.

Now, see how you can define districts from those neighborhoods.  Can you find a definition of districts so that blue wins, despite the overall population leaning red?
There are four example districts (“district election across”) that include cell #1 (upper left) and three other cells/neighborhoods.  The “results” variable will show the results of that election. (Use the “clear results” block to reset the results.) Try each of those “district elections” to see what results you get.  You can use the block "show the district across" which will show you which cells are in that list of cells.

There are also some sample scripts for defining districts in terms of x,y coordinates. See the bottom of the sprite scripting area.

Created December 2, 2025

Last updated February 16, 2026

Published February 10, 2026