Skip to main content
darragh's blog

Examining the Political Bias of GuessThatParty.co.uk

With the elections just yesterday - I've been taking a look around the internet for stuff in relation to it and came across a website called guessthatparty.co.uk (Reddit post). At first glance, it appears as a fun, neutral game which is just tacking the micky out of stereotyping politics but whilst I was playing it - I noticed that there was a particular trend towards displaying Labour/Green MPs, so this led me to question whether the website is inherently biased towards pushing them.

Just to clarify:
I don't believe that the site itself is intentionally trying to be biased - I just thought it'd be a little fun to take a quick look into. I'd recommend checking it out - it is well made and honestly a bit fun.
I have written a TamperMonkey script if you would like to play this with an impartial selection.

Looking at the website source

The website is quite simple - it's just a short HTML page with styling and two scripts:

  1. The Supabase library
  2. game.js

The HTML source as of writing.

Taking a look at game.js - it is also very simple and easy to read, showing that the members are sourced from a single .json file candidates.json :

A snippet from game.js showing how candidates.json is sourced.

...which is neatly formatted with the schema of:

[
	{
	    "id": <int>, // from democracyclub.org.uk
	    "name": <string>,
	    "party": <string>, // "Conservative", "Reform", "Green", "Labour", "Liberal Democrat"
	    "image_url": <string>, // external url, hosted on democracyclub.org.uk
	    "image_file": <string> // internal url, hoested by guessthatparty.co.uk
	}
]

This file is composed of, at the time of writing, 2021 different politicians, all of which are sourced from democracyclub.org.uk - a non-partisan, not-for-profit [Community Interest Company].

However, when plotting them into a graph, it shows that they are not balanced between parties.

A graph showing how many members per party are included in the candidates.json.

View graph source code here.

... which makes sense - however there is nothing to account for this discrepancy between party sizes. The site uses a uniform random, meaning that you are statistically more likely to a Labour politician than any of the other parties. This is what makes it biased.

A snippet from game.js showing the candidate selection.

Making it impartial

Since this uniform distribution doesn't account for the party, we can take a simple approach to solve this:

  1. Bucket the politicians into parties
  2. Shuffle and randomly select a politician uniformly, from a uniformly selected bucket

This makes it impartial since there is a 1/51/5 chance that you will get any of the parties. Since this is the only factor at play in this game, we do not need to be concerned with the selection of the politicians so we can uniformly select one - no matter what the membership size is.

Example implementation

let partyBuckets = {};

function bucketPoliticians() {
	for (const party of PARTIES) {
		partyBuckets[party] = pool.filter(c => c.party === party);
	}
}

async function load() {
	// replacing the reshuffle() invokation
	// Note: I have moved away from generating a shuffled list
	// to uniformly selecting a party + politician upon demand 
	bucketPoliticians();
	// ...
}

function nextRound() {
	// replacing the currect reshuffle + pop statements
	// this could be cleaner but you get the idea
	const selectedParty = PARTIES[Math.floor(Math.random() * PARTIES.length)];
	const selectedPartyBucket = buckets[selectedParty];
	current = selectedPartyBucket[Math.floor(Math.random() * selectedPartyBucket.length)];
	// ...
}