Hack Club
Defector logo

Defector

by @Heliodex at Hack Club

Write a bot that plays a strategy game, battle other bots,
and win money to spend on video games!

Every few seconds 2 bots battle, and the winner climbs the leaderboard.

How it works

You write a tiny function that, given your history with an opponent, picks a move: cooperate (C) or defect (D). Your bot gets a new opponent every battle and earns points per round. Better bots win more battles and climb the Elo ladder.

  • Write a bot in TypeScript or JavaScript, no frameworks needed.
  • You may have up to 3 active bots in the live tournament at once.
  • Your bots' Elo starts at 1000 and updates automatically after each battle.

See the Guide for bot examples, and how to write a bot in 3 lines of code.

Want to know how it works under the hood? The tournament is an Iterated Prisoner's Dilemma: in each round both you and your opponent choose to cooperate or defect.

  • If you both cooperate you each get 2 points.
  • If you both defect you each get 1 point.
  • If one of you defects while the other cooperates, the defector gets 3 points and the other gets 0.

This makes the payoff matrix (how many points you get for each move) look like this:

You →
Opponent ↓
CooperateDefect
Cooperate2, 20, 3
Defect3, 01, 1

Over at least 100 rounds, the accumulated score decides the winner. Elo tracks who wins consistently and adjusts their rating accordingly.

Track your time spent with Lapse so we can verify it for your rewards! The base rate is $4 in grants (spendable at various video game vendors) per verifiable hour tracked building bots. The higher your bots rank on the leaderboard, the more you can earn!

Frequently Asked Questions

Who's eligible to join?
The event is intended for high school students of any experience level. Anyone aged 13-18 is eligible to participate.
19 or over? Get the same prizes by referring others!
Do I need to know how to code JavaScript?
Nope! The Guide will walk you through the basics of writing a bot. It starts with the simplest bots, only a few lines of code, then gradually shows how to build bots with more advanced strategy.
Do I need to know game theory?
Not at all. The simplest bots are only a few lines of code, and you can iterate and deploy new bots throughout the programme, while seeing what works and what doesn't.

If you don't know game theory now, you will by the end of the programme! If you want to learn the easy way, check out the Guide.
What are the prizes?
Everyone who verifiably spends time gets video game grants or gift cards as a reward. Based on leaderboard position and how many matches your bots play, your grants may be larger!
How much does it cost to join in?
Defector is completely free to join and participate in. All prizes are provided by us. All you need is a Hack Club Auth account to log in and participate.
Who runs this?
Defector is sponsored by Hack Club, a US-based 501(c)(3) non-profit organisation. Hack Club aims to incentivise high schoolers all over the world to advance their programming skills and ship their projects.

We think you learn best when you're building, so we provide the useful resources and the amazing community to help you do that. We make, break, learn, and share projects together. Welcome to the club!