|
{% set api_key = user.get('api_key') if user else 'YOUR_API_KEY' %}
|
|
{% set uname = user.get('username') if user else 'YOUR_USERNAME' %}
|
|
<div class="docs-content" data-render>
|
|
# Code Farm
|
|
|
|
Code Farm is a cooperative idle game built into DevPlace. Every member owns a farm of plots,
|
|
plants software projects that build over real time, harvests the finished builds for coins and
|
|
experience, and grows the farm with faster CI, more plots, and permanent perks. You can also
|
|
visit other members' farms to water their growing builds for a reward, or raid a ready build that
|
|
its owner left sitting too long.
|
|
|
|
Open it from your user menu or go straight to `{{ base }}/game`. You need a member account to
|
|
play. Visiting another farm at `{{ base }}/game/farm/{username}` is public.
|
|
|
|
Everything on this page also runs over the JSON API, so the game can be driven by a script as
|
|
well as by hand. The full request and response reference is the
|
|
[Code Farm API group](/docs/game.html); this page explains the rules and the numbers behind
|
|
them, then shows a complete automated client at the end.
|
|
|
|
## The core loop
|
|
|
|
1. **Plant** a crop in an empty plot. Planting costs coins.
|
|
2. The crop **builds** over real time. The build finishes at a fixed wall-clock moment.
|
|
3. **Harvest** the finished build for coins and experience, which empties the plot again.
|
|
4. Spend the coins on faster CI, more plots, and perks so the next loop pays more.
|
|
|
|
A farm starts with **50 coins** and **4 plots**. Nothing is lost while you are away: builds keep
|
|
progressing and wait for you, so the game is safe to check once an hour or once a day.
|
|
|
|
## Crops
|
|
|
|
Each crop has a coin cost to plant, a base build time, a coin and experience reward on harvest,
|
|
and a level at which it unlocks. Slower crops pay far more per build.
|
|
|
|
| Crop | Cost | Base build time | Coins | XP | Unlocks at level |
|
|
|------|-----:|----------------:|------:|---:|:----------------:|
|
|
| π Shell Script | 5 | 30s | 11 | 2 | 1 |
|
|
| π Python Script | 15 | 2m | 36 | 5 | 1 |
|
|
| π Web App | 40 | 5m | 98 | 12 | 2 |
|
|
| πΉ Go Service | 90 | 10m | 224 | 25 | 3 |
|
|
| π¦ Rust Engine | 200 | 30m | 520 | 60 | 4 |
|
|
| Ξ» Compiler | 500 | 1h | 1380 | 150 | 6 |
|
|
| βοΈ Kernel | 1200 | 2h | 3600 | 400 | 8 |
|
|
| πΈοΈ Distributed System | 5000 | 4h | 9500 | 900 | Mastery |
|
|
| π§ ML Pipeline | 12000 | 6h | 21000 | 1800 | Mastery |
|
|
| π Security Fortress | 30000 | 8h | 48000 | 3200 | Mastery, raid-immune |
|
|
|
|
The three Mastery-tier crops unlock once you have earned at least one Mastery point (see
|
|
Mastery, below), on top of the usual level requirement. Security Fortress can never be raided.
|
|
|
|
Build time is the base time divided by the farm build speed (CI tier and the growth perk, below),
|
|
so a higher tier finishes everything proportionally faster. Coin and experience rewards shown in
|
|
the API already include your perks, refactor bonus, and the current Market Saturation factor, so
|
|
read them from the live state rather than from this table. Each crop in the state also carries a
|
|
`market_state` of `normal`, `saturated`, or `boosted`.
|
|
|
|
## Plots
|
|
|
|
A farm starts with 4 plots and can grow to **12**. Each extra plot costs more than the last: the
|
|
price starts at **100 coins** and doubles for every plot you have already added.
|
|
|
|
| Plot number | Cost |
|
|
|:-----------:|-----:|
|
|
| 5th | 100 |
|
|
| 6th | 200 |
|
|
| 7th | 400 |
|
|
| 8th | 800 |
|
|
| 9th | 1600 |
|
|
| 10th | 3200 |
|
|
| 11th | 6400 |
|
|
| 12th | 12800 |
|
|
|
|
More plots is more builds in parallel, which is the main way to scale output.
|
|
|
|
## CI tier (build speed)
|
|
|
|
Upgrading your CI tier multiplies build speed for the whole farm. The upgrade is permanent.
|
|
|
|
| Tier | Name | Build speed | Upgrade cost |
|
|
|:----:|------|:-----------:|-------------:|
|
|
| 1 | Local Build | 1.0x | starting |
|
|
| 2 | Shared Runner | 1.25x | 150 |
|
|
| 3 | Fast Runner | 1.6x | 400 |
|
|
| 4 | Parallel Matrix | 2.0x | 1000 |
|
|
| 5 | Distributed Cache | 2.5x | 2600 |
|
|
|
|
## Levels and experience
|
|
|
|
Harvesting grants experience. Experience raises your level, and higher levels unlock the more
|
|
valuable crops. The maximum level is **20**. Each level needs `50 * (level - 1)^2` total
|
|
experience, so level 2 is at 50 XP, level 5 at 800, level 10 at 4050, and level 20 at 18050.
|
|
|
|
## Perks
|
|
|
|
Perks are permanent upgrades bought with coins. Each level of a perk costs more than the last.
|
|
There are four:
|
|
|
|
| Perk | Effect per level | Max level |
|
|
|------|------------------|:---------:|
|
|
| π Optimizer | +5% harvest coins | 10 |
|
|
| β‘ Build Cache | +4% build speed | 10 |
|
|
| π·οΈ Bulk Licenses | -3% planting cost | 8 |
|
|
| π Mentorship | +5% harvest experience | 10 |
|
|
|
|
The live state reports each perk's current level and the exact cost of its next level.
|
|
|
|
## Daily bonus and streak
|
|
|
|
Once per day you can claim a coin bonus. Claiming on consecutive days builds a streak that
|
|
increases the bonus, from **20 coins** on day one up to **92 coins** at a seven-day streak.
|
|
Missing a day resets the streak. The state field `daily_available` tells you when a claim is
|
|
ready, and `daily_reward` is the amount you would receive.
|
|
|
|
## Daily quests
|
|
|
|
Each day you are given three small goals, such as planting a number of crops, harvesting a number
|
|
of builds, watering neighbour builds, or earning a number of coins from harvests. Progress is
|
|
tracked automatically as you play. A completed quest is claimed by its **kind** (`plant`,
|
|
`harvest`, `water`, or `earn`) for a coin and experience reward. The state field `can_claim` on
|
|
each quest marks the ones that are ready.
|
|
|
|
## Fertilizer
|
|
|
|
Fertilizing a growing build spends coins to **halve its remaining time**. The cost scales with the
|
|
build's coin value and with how much time you skip, so a build with a long way to go costs more and
|
|
fertilizing is cheapest near the end. Each plot in the state reports its current `fertilize_cost`.
|
|
|
|
## Watering a neighbour (cooperation)
|
|
|
|
Visit another member's farm and water one of their **growing** builds. Watering reduces that
|
|
build's remaining time by 8% of its total build time and rewards **you**, the visitor, with
|
|
**6 coins and 3 experience**. A single plot can be watered up to **3 times** total across all
|
|
visitors, so popular farms fill up. Each plot reports `can_water`, `watered_count`, and
|
|
`max_waters`.
|
|
|
|
## Raiding a ready build (competition)
|
|
|
|
If an owner leaves a build **ready** without harvesting it, another member can raid it, but only
|
|
after a protection window (60 seconds by default, longer with Branch Protection or a Defense
|
|
building) has passed since the build became ready. The raider receives a fraction of the build's
|
|
coin value (half by default, less with the owner's defenses, floored so a raid never pays nothing)
|
|
and the owner loses the build entirely - except a Security Fortress build, which can never be
|
|
raided. The owner is told their farm was raided but the raider's identity is never revealed. You
|
|
can raid a given neighbour only once per hour. Raiding a farm with **10x** your own coins grants you
|
|
a 24-hour **Underdog** boost (+25% harvest coins). Each plot reports `can_steal` and `steal_coins`
|
|
(the payout a raid would give), and `ready_at` lets you compute when the protection window ends.
|
|
Harvest your own ready builds promptly to keep them safe, or invest in Defense (below).
|
|
|
|
## Market Saturation
|
|
|
|
The game tracks the last 48 hours of league-wide harvests of each crop. When a crop is being
|
|
farmed heavily, its payout drops in steps (down to 40% of normal); while that is happening, the
|
|
four starter crops (Shell Script, Python Script, Web App, Go Service) get a relief buff of up to
|
|
+15%. This rewards diversifying what you plant instead of printing one crop nonstop. Nothing else
|
|
about the crop changes - cost, build time, and unlock level are unaffected.
|
|
|
|
## Infrastructure, Defense, and Cosmetics (coin sinks)
|
|
|
|
Once you are earning more coins than you can spend on plots and perks, three permanent systems
|
|
give large coins a purpose:
|
|
|
|
- **Infrastructure** - one-time, prestige-gated buildings bought with `POST /game/infrastructure/buy`:
|
|
**Private Registry** (Rust, Compiler, and Kernel crops grow 15% faster, prestige 3+), **Canary
|
|
Deployments** (every harvest has a 12% chance to double and a 6% chance to only refund its
|
|
planting cost, prestige 8+), and **Observability Suite** (raises the minimum coins you keep when
|
|
raided from 10% to 30%, prestige 15+).
|
|
- **Defense** - an upgradeable building (`POST /game/defense/upgrade`) that lowers your raid losses
|
|
and lengthens your protection window with every tier. Unlike a one-time purchase, it costs a
|
|
**daily coin upkeep** proportional to your balance; if you do not have enough coins to cover it,
|
|
the tier decays by one level automatically. This is the sink that scales with wealth.
|
|
- **Cosmetics** - purely cosmetic titles and plot skins bought with coins (`POST /game/cosmetics/buy`)
|
|
and equipped (`POST /game/cosmetics/equip`). Zero gameplay effect; an equipped title shows next
|
|
to your name on the leaderboard.
|
|
|
|
## Mastery (beyond prestige)
|
|
|
|
Refactoring past **prestige 50** starts earning a second currency: one Mastery point immediately,
|
|
then one more every 10 further prestige. Mastery points never expire, and once you have earned at
|
|
least one, the three Mastery-tier crops above stay unlocked even if you later spend the point.
|
|
Spend Mastery points with `POST /game/mastery` on three permanent upgrades:
|
|
|
|
| Mastery upgrade | Effect | Max level |
|
|
|------------------|--------|:---------:|
|
|
| π Continuous Delivery | Auto-replant the same crop right after harvest, if affordable | 1 |
|
|
| π Farm Analytics | Unlocks lifetime stats on your farm | 1 |
|
|
| π Legacy Contracts | Unlocks a weekly contract slot paying Stars and a temporary coin boost | 1 |
|
|
|
|
The state reports `mastery_points`, `mastery_points_earned_total`, and each upgrade's level and cost.
|
|
|
|
## Refactor (prestige)
|
|
|
|
At level 10 or above you can **refactor**: the farm resets to its starting coins, level, CI tier,
|
|
perks, and plots, but you gain a permanent **+25% coin bonus** that stacks with every refactor and
|
|
multiplies with the Optimizer perk. Refactoring is the long-term progression and the single
|
|
largest factor in the leaderboard. The state reports `prestige`, `prestige_multiplier`, and
|
|
`prestige_available`.
|
|
|
|
Each refactor also awards **stars**, a separate prestige currency (more at higher levels and higher
|
|
prestige). Stars are never reset and are spent on permanent **Legacy upgrades**.
|
|
|
|
## Legacy upgrades
|
|
|
|
Stars buy Legacy upgrades, permanent boosts that persist through every future refactor. There are
|
|
five:
|
|
|
|
| Legacy upgrade | Effect | Max level |
|
|
|----------------|--------|:---------:|
|
|
| π€ CI Bot | Auto-collect ready builds when you open your farm | 1 |
|
|
| π Tech Debt Payoff | +10% harvest coins per level, stacks with refactor | 10 |
|
|
| ποΈ Bare-Metal | +5% base build speed per level | 8 |
|
|
| ποΈ Monorepo | +1 starting plot after each refactor per level | 4 |
|
|
| π‘οΈ Branch Protection | +30s steal grace and -5% steal loss per level | 5 |
|
|
|
|
The live state reports your `stars` balance and each legacy upgrade's current level and the exact
|
|
star cost of its next level.
|
|
|
|
## Leaderboards and scoring
|
|
|
|
The default leaderboard ranks the top farms by a composite score. Refactors dominate the formula,
|
|
then lifetime harvests, level, and everything else:
|
|
|
|
```
|
|
score = xp
|
|
+ prestige * 5000
|
|
+ total_harvests * 10
|
|
+ coins / 20
|
|
+ (ci_tier - 1) * 250
|
|
+ (plots - 4) * 200
|
|
+ total_perk_levels * 120
|
|
+ min(streak, 30) * 15
|
|
```
|
|
|
|
Read the top farms with `GET {{ base }}/game/leaderboard` (public, no account needed). Add
|
|
`?board=` to switch boards - `score` (default), `prestige`, `harvests` (this week only), `raids`
|
|
(average coins per successful raid over the last 30 days, minimum 3 qualifying raids), `time_to_kernel`
|
|
(fastest to harvest a Kernel after your last refactor), `fair_play` (rewards recent activity over
|
|
hoarding coins), and `era` (the current Era's board, empty when no Era is running - see below).
|
|
|
|
## Eras (seasons)
|
|
|
|
Administrators can occasionally start an **Era**: a fresh, visible "this season" leaderboard
|
|
(`board=era`) that everyone starts at zero on, while their real coins, prestige, Stars, Legacy, and
|
|
Mastery are completely untouched. When an Era ends, the top 10 by Era score earn permanent Stars
|
|
(and sometimes an Era-exclusive cosmetic). The state reports `era_active`, `era_name`, `era_coins`,
|
|
and `era_harvests` when one is running.
|
|
|
|
## Live updates
|
|
|
|
A farm page subscribes to the pub/sub topic `public.game.farm.{username}` and refreshes whenever
|
|
that farm changes, so watering, harvesting, and raids appear without a reload. A scripted client
|
|
does not need pub/sub: it can simply re-read the state after each action, since every action
|
|
endpoint returns the full updated farm.
|
|
|
|
## Playing through the API
|
|
|
|
Every action is a normal DevPlace endpoint that negotiates HTML or JSON. Send
|
|
`Accept: application/json` to get JSON, and authenticate exactly like the rest of the API: with
|
|
your **API key** in an `X-API-KEY` header (or `Authorization: Bearer`). Your key is on your
|
|
[profile page]({% if user %}/profile/{{ uname }}{% else %}/profile/YOUR_USERNAME{% endif %}).
|
|
|
|
### Endpoints
|
|
|
|
| Method | Path | Purpose |
|
|
|--------|------|---------|
|
|
| `GET` | `/game/state` | Your full farm state (always JSON). |
|
|
| `GET` | `/game/leaderboard` | Top farms (public). Accepts `?board=`. |
|
|
| `GET` | `/game/farm/{username}` | Another member's farm. |
|
|
| `POST` | `/game/plant` | Plant `crop` in `slot`. |
|
|
| `POST` | `/game/harvest` | Harvest the build in `slot`. |
|
|
| `POST` | `/game/fertilize` | Halve the remaining time of `slot`. |
|
|
| `POST` | `/game/buy-plot` | Unlock one more plot. |
|
|
| `POST` | `/game/upgrade` | Raise the CI tier. |
|
|
| `POST` | `/game/perk` | Upgrade `perk` (`yield`, `growth`, `discount`, `xp`). |
|
|
| `POST` | `/game/daily` | Claim the daily bonus. |
|
|
| `POST` | `/game/quests/claim` | Claim a completed quest by `quest` kind, optional `scope` (`daily` or `weekly`). |
|
|
| `POST` | `/game/prestige` | Refactor at level 10 or above. |
|
|
| `POST` | `/game/legacy` | Buy a legacy upgrade (`key`) with stars. |
|
|
| `POST` | `/game/mastery` | Buy a Mastery upgrade (`key`) with Mastery points. |
|
|
| `POST` | `/game/infrastructure/buy` | Buy an Infrastructure building (`key`) with coins. |
|
|
| `POST` | `/game/defense/upgrade` | Buy the next Defense tier with coins. |
|
|
| `POST` | `/game/cosmetics/buy` | Buy a cosmetic (`key`) with coins. |
|
|
| `POST` | `/game/cosmetics/equip` | Equip an owned title cosmetic (`key`). |
|
|
| `POST` | `/game/farm/{username}/water` | Water a neighbour's build in `slot`. |
|
|
| `POST` | `/game/farm/{username}/steal` | Raid a neighbour's unprotected ready build in `slot`. |
|
|
|
|
POST bodies are form encoded (`application/x-www-form-urlencoded`). Form fields are `slot` (an
|
|
integer plot index), `crop`, `perk`, `quest`, `scope`, and `key` (a legacy/Mastery/Infrastructure/cosmetic
|
|
key) where the table notes them. Every POST returns the full farm under `farm`, so one call both
|
|
performs the action and gives you the new state.
|
|
|
|
### Reading the state
|
|
|
|
```python
|
|
import json, urllib.request
|
|
|
|
request = urllib.request.Request(
|
|
"{{ base }}/game/state",
|
|
headers={"X-API-KEY": "{{ api_key }}", "Accept": "application/json"},
|
|
)
|
|
with urllib.request.urlopen(request) as response:
|
|
farm = json.loads(response.read())["farm"]
|
|
|
|
print("coins", farm["coins"], "level", farm["level"], "plots", farm["plot_count"])
|
|
for plot in farm["plots"]:
|
|
print(plot["slot"], plot["state"], plot.get("crop_name"), plot.get("remaining_seconds"))
|
|
```
|
|
|
|
### The farm state shape
|
|
|
|
`GET /game/state` returns `{"ok": true, "farm": {...}}`. The farm carries your totals plus three
|
|
lists you act on: `plots`, `crops`, and `quests`. A plot looks like this:
|
|
|
|
```json
|
|
{
|
|
"slot": 0,
|
|
"state": "growing",
|
|
"crop_key": "python",
|
|
"crop_name": "Python Script",
|
|
"reward_coins": 45,
|
|
"reward_xp": 5,
|
|
"ready_at": "2026-06-23T12:34:56+00:00",
|
|
"remaining_seconds": 73,
|
|
"watered_count": 1,
|
|
"max_waters": 3,
|
|
"can_water": false,
|
|
"can_steal": false,
|
|
"steal_coins": 0,
|
|
"fertilize_cost": 22
|
|
}
|
|
```
|
|
|
|
A plot's `state` is `empty`, `growing`, or `ready`. An entry in `crops` carries the live `cost`,
|
|
`reward_coins`, `grow_seconds`, `min_level`, and a `locked` flag, so a client can decide what is
|
|
both unlocked and affordable without hard-coding the table above.
|
|
|
|
### A complete automated farmer
|
|
|
|
This script plays the core loop on a schedule: it claims the daily bonus and any finished quests,
|
|
harvests every ready build, replants empty plots with the most valuable crop it can afford, and
|
|
prints a one-line summary. It uses only the Python standard library. Set your URL and API key,
|
|
then run it under `cron` or a `systemd` timer, or leave it looping.
|
|
|
|
```python
|
|
#!/usr/bin/env python3
|
|
"""Plays the DevPlace Code Farm automatically over the JSON API."""
|
|
|
|
import json
|
|
import time
|
|
import urllib.error
|
|
import urllib.parse
|
|
import urllib.request
|
|
|
|
BASE = "{{ base }}"
|
|
API_KEY = "{{ api_key }}"
|
|
POLL_SECONDS = 60
|
|
|
|
|
|
def call(method, path, fields=None):
|
|
headers = {"X-API-KEY": API_KEY, "Accept": "application/json"}
|
|
data = None
|
|
if fields is not None:
|
|
data = urllib.parse.urlencode(fields).encode()
|
|
headers["Content-Type"] = "application/x-www-form-urlencoded"
|
|
request = urllib.request.Request(BASE + path, data=data, headers=headers, method=method)
|
|
with urllib.request.urlopen(request) as response:
|
|
return json.loads(response.read())
|
|
|
|
|
|
def state():
|
|
return call("GET", "/game/state")["farm"]
|
|
|
|
|
|
def best_affordable_crop(farm):
|
|
options = [c for c in farm["crops"] if not c["locked"] and c["cost"] <= farm["coins"]]
|
|
if not options:
|
|
return None
|
|
return max(options, key=lambda c: c["reward_coins"])
|
|
|
|
|
|
def claim_free_rewards(farm):
|
|
if farm.get("daily_available"):
|
|
call("POST", "/game/daily")
|
|
for quest in farm.get("quests", []):
|
|
if quest.get("can_claim"):
|
|
call("POST", "/game/quests/claim", {"quest": quest["kind"]})
|
|
|
|
|
|
def harvest_and_replant(farm):
|
|
for plot in farm["plots"]:
|
|
if plot["state"] == "ready":
|
|
call("POST", "/game/harvest", {"slot": plot["slot"]})
|
|
farm = state()
|
|
for plot in farm["plots"]:
|
|
if plot["state"] != "empty":
|
|
continue
|
|
crop = best_affordable_crop(farm)
|
|
if not crop:
|
|
break
|
|
call("POST", "/game/plant", {"slot": plot["slot"], "crop": crop["key"]})
|
|
farm = state()
|
|
return farm
|
|
|
|
|
|
def run():
|
|
print("Code Farm automation started.")
|
|
while True:
|
|
try:
|
|
farm = state()
|
|
claim_free_rewards(farm)
|
|
farm = harvest_and_replant(state())
|
|
print(f"coins={farm['coins']} level={farm['level']} harvests={farm['total_harvests']}")
|
|
except urllib.error.HTTPError as error:
|
|
print("api error:", error.code, error.read().decode()[:200])
|
|
except OSError as error:
|
|
print("network error, retrying:", error)
|
|
time.sleep(POLL_SECONDS)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
run()
|
|
```
|
|
|
|
From here the natural extensions are easy: spend surplus coins with `POST /game/buy-plot` and
|
|
`POST /game/upgrade` when you can afford them, raise perks with `POST /game/perk`, water
|
|
neighbours by walking `GET /game/farm/{username}` and posting to its `/water` path for plots where
|
|
`can_water` is true, and refactor with `POST /game/prestige` once `prestige_available` is set. Be
|
|
polite to the rate limiter: mutating calls are limited per account, so a poll interval of a minute
|
|
or more with one action per finished build stays well within limits.
|
|
|
|
## Ask Devii
|
|
|
|
You can also play in plain language through the Devii assistant, which calls the same endpoints
|
|
for you:
|
|
|
|
> Check my Code Farm, harvest anything that is ready, and replant with the best crop I can afford.
|
|
|
|
Devii reads your state, performs the actions, and reports your new coin and level totals.
|
|
|
|
</div>
|
|
|
|
<div class="devii-doc-cta">
|
|
<a href="/game" class="sidebar-link">Open Code Farm</a>
|
|
</div>
|