r/coding • • Jan 25 '21

I made a program that shows how effective gerrymandering can be in python - source code & explanation in description

https://www.youtube.com/watch?v=d8M1bCLl-i0&feature=youtu.be
380 Upvotes

28 comments sorted by

14

u/RedditingJinxx Jan 25 '21

Very impressive, well done

6

u/jms_nh Jan 25 '21

I kept waiting for someone to come out with a game involving politics / gerrymandering / ratfcking / misinformation etc. given the last four years. At least let's have some fun with the situation instead of repressed anger.

3

u/toxicwaste55 Jan 26 '21

I've dreamed of making one for many years. The hard part is making it fun enough that you could make a living off it. The harsh reality of game dev is that your dream project is almost certainly doomed. There's no way I can justify losing my insurance, falling behind on my mortgage, and not funding my retirement to make an app that you play for 10 minutes and uninstall.

1

u/ArkyBeagle Jan 26 '21

instead of repressed anger.

Nah. Just look at it for what it is. Really, life gets better if you give humanity the benefit of the doubt. People really do the best they can but it only goes so far.

1

u/[deleted] Feb 03 '21

This is beautiful. How did you map the connected edges? You should blog about this.

1

u/StephanoCarlson Feb 03 '21

Thanks. For the edges - every district has a list of people contained. Each person has their own line “ids”, which are used to turn on or off the lines. With all of them on it would appear as a simple grid. When drawing the district, I collect all the line ids of all the people contained into a list. The line ids that make up the edges of the district will only appear once in that list, and all the ones that appear 2+ times are in the middle of the district. Hope that made sense

3

u/fetusfarm Jan 25 '21

It’s also effective in JavaScript.

24

u/purleyboy Jan 25 '21

Do not give this code to the GOP

14

u/bonafidebob Jan 25 '21

As if they haven’t already been using computers to do this for decades?

10

u/[deleted] Jan 25 '21

Based on leaked documents they are using Excel to plan their gerrymandering.

3

u/flip314 Jan 25 '21

They have this code already (used in conjunction with very detailed voter information). It's what made REDMAP possible in 2010.

1

u/ArkyBeagle Jan 26 '21

Look into Karl Rove. This is well understood and has been for a long time.

4

u/oantolin Jan 25 '21

I would have worded the title as follows: "I made a program in python that shows how effective gerrymandering can be". :)

2

u/Yakhov Jan 26 '21

How did we get here?

Career politicians and Citizens United

3

u/cryo Jan 25 '21

I feel the headline could have been rearranged for less ambiguity :p

1

u/ptoki Jan 25 '21

I like it very much! Good work!

1

u/toobulkeh Jan 25 '21

-80 to +80 swing for both sides? Well done.

This shit needs to be taken more seriously, there's too much money in it for people NOT to spend boatloads on it.

1

u/[deleted] Jan 26 '21

Well done

1

u/Windoge_Master Jan 25 '21

Now make it work on real data and sell it to the highest bidder lmao

-30

u/omega552003 Jan 25 '21

Do not give this code to the DNC

5

u/cbarrick Jan 25 '21

TBF, we're in the midst of the 2020 redistricting cycle, and the GOP is largely in charge.

States decide how they redistrict.

  • 19 states will be redistricted by a GOP controlled legislature.

  • 8 states will be redistricted by a DNC controlled legislature.

  • 16 states will either split the redistricting power or use independent commissions.

  • 7 states have only one district.

The power of the GOP is put into perspective when you look at the number of districts they will be in charge of drawing:

  • The GOP will draw 182 districts.

  • The DNC will draw 76 districts.

https://en.wikipedia.org/wiki/2020_United_States_redistricting_cycle

Also, the GOP was in charge of the 2000 and 2010 redistricting cycles that got us into this gerrymandered mess in the first place.

Gerrymandering is explicitly part of the GOP policy. They call it project REDMAP.

https://en.wikipedia.org/wiki/REDMAP

17

u/[deleted] Jan 25 '21

You are confused about which party does the bulk of gerrymandering in 2021. If we were in the 90s, I might agree with you.

4

u/Mechakoopa Jan 25 '21

How about we just agree "fuck gerrymandering" in general and give this to nobody?