Write a Python agent that plays Greedy Pig, run it against the game's bots and see the results — free in your browser, with no sign-up and nothing saved.

Greedy Pig

Write CustomPlayer.make_decision(game_state) to return 'bank' or 'continue'.

Rules

  • Each round starts with zero unbanked money. Players share one six-sided die.
  • A roll of 2–6 adds that value to each active player's unbanked money. Each player then chooses an action.
  • 'bank' saves your unbanked money and sits you out for the rest of the round. 'continue' keeps you in for the next roll.
  • A 1 erases all unbanked money and ends the round, with no decision requested. Banked money stays safe.
  • If everyone banks, the round ends. All players rejoin the next round with their banked totals.
  • The game ends after a roll where anyone banks 100 or more. The highest banked total wins; tied leaders share the reward. Remaining unbanked money is lost.
  • At 150 unbanked, your money is automatically banked.

Agent interface

game_state contains:

  • round_no, roll_no: current round and roll numbers.
  • players_banked_this_round: names of players who have banked this round.
  • banked_money, unbanked_money: dictionaries mapping player names to their money.

Use self.name to look up your own money, for example game_state["unbanked_money"][self.name]. Add short debugging messages with self.add_feedback(message).

Submission results

Your agent plays 300 games against the test bots. Total Points sums your rewards: by default, each win earns 10 points, tied winners split those points, and other players earn 0. Leagues may set custom placement rewards. Reward points are separate from banked money. Dice rolls vary, so results can differ between submissions.


Want lessons first? Start the free Python course or browse the Python lessons.