Kaggriculture Agent
A game-playing agent for Kaggriculture, a two-player farming-market competition on Kaggle, built through controlled strategy tournaments, statistical testing, and reverse-engineering of public replays.
Money
Melon price at the shared market
- Melon
- Wheat
- Carrot
- Tomato
- Strawberry
- Goose coop
- Sheep pasture
- Empty plot
- Weeds
- Land not yet bought
- Farmer or hired hand
The game
Kaggriculture is a simulation competition on Kaggle. Two agents each run a farm for a 30-day season of 720 turns: buying seeds and livestock, planting, watering, harvesting, hiring farm hands, buying land, and selling into a market the two players share. Sell too much of one crop and you crash its price, for yourself and your opponent. The player with the most money at the end of the season wins, and agents are ranked on a ladder against a rotating pool of opponents.
I built an agent for it. I never submitted it, so it never played against other people’s bots on the ladder. The interesting part was the process, which looks a lot more like applied data science than game programming.
Approach: measure, don’t assume
The project followed a fixed order: verify the game mechanics against the official environment, build an evaluation harness, model the economics, build a reliable executor, and only then write strategies. Machine learning was deliberately last on the list. A learned policy is only worth training once simple, understandable strategies set a baseline to beat.
- A layered architecture. Strategies produce high-level intentions (“plant melons on these tiles”); a separate tactical executor turns them into legal moves, pathfinding, and task assignment for the farmer and hired hands.
- A strategy zoo. Sixteen strategies, from random play to monoculture, expansion rushes, market dumping, and opponent-aware strategies that read the rival’s farm and either copy, avoid, or attack their main crop.
- Tournaments with statistics. Every change was tested in paired matches across many random seeds and both seat positions, and only kept if the improvement cleared two standard errors.
- 310 automated tests, including differential tests that check my legality rules against the official environment.
What the experiments showed
The first version planted melons, the most profitable crop, on every tile. It earned $38,000–41,000 a season against weak opponents, then just $10,700 when it played a copy of itself: two farms selling the same crop into one market drove the price down for both. Diversifying crops and pacing sales fixed it. A shared market makes this a strategic game, not just an optimization problem.
Later, I recreated a strong public agent as a “shadow bot” (a faithful port of a published Kaggle notebook) to use as an independent test opponent. My best strategy lost to it in 30 of 40 matches. A traced game showed why: my agent kept buying land faster than its workers could farm it, so tile use fell from 86% to 26% while cash sat in empty fields. Capping expansion at two quadrants put my agent ahead on all 20 seeds in that matchup, and it won or broke even against every other opponent tested.
One season, replayed
The replay at the top of this page is a full 30-day match in the official game environment: my final agent against the public bot that had beaten its earlier version. My agent spends its entire starting $3,000 on a second block of land and seeds within the first few hours, runs with almost no cash through the first ten days, and is still behind on day 20. Then the larger farm pays off: it takes the lead for good on day 27 and finishes with $33,378 to the public bot’s $28,268.
The melon line shows why selling has to be paced: both farms sell into the same market, and the price moves sharply as supply arrives.
The last phase analyzed a public dataset of more than 19,000 real ladder games to profile what the top-ranked agents actually do, so the agent could be tested against realistic opponents rather than ones I’d invented.