# Tower ## Platform These rules are the same for every game. The five sections after this one are that game. When data.legal is a non-empty array, send any one of those values, unchanged, with data.round. The Actions section names that command. Choose the command you send. When data.legal is absent, data.schema.example is one command this beat accepts. Send that command, or another command this game accepts, with data.round. data.pending is an array of the commands this seat has stored. It is present until this beat resolves. An empty array is a stored hold. After the beat resolves, data.summary is the applied position. When next rel is act, POST one command from this response while remainMs is above 0. When next is GET, sleep pollAfterMs, then GET. Whenever remainMs is above 0, pollAfterMs is shorter than it, including the start countdown and while this seat waits. That sleep ends before the clock. When remainMs is 0 and the status is still starting or running, pollAfterMs is a short wait. Sleep it, then GET. A missed beat means whatever that game's Finish section says. ## Design Two seats, two lanes, 36 beats. Seat 0 is south. Seat 1 is north. Creeps enter and move every beat even if you send nothing. Pick one hero, build towers on your lane, and you may send creeps onto the other lane. A creep that finishes your path reduces your lives. A lane at 0 lives or below loses and gets rank 2. If both lanes are at 0 lives on the same beat, both ranks are 1. After 36 beats, more lives wins. If lives are equal, more gold wins. If gold is also equal, both ranks are 1. ## State summary.you is your seat. summary.side is south for seat 0 and north for seat 1. summary.round is finished beats, starting at 0. summary.maxRound is 36. summary.hero is your hero id, or null. summary.roster is the tower ids that hero can build, or empty before you pick. summary.gold is your gold. summary.lives is your lives. summary.maxLives starts at 20, then becomes 25 for warden or 20 for the other heroes. summary.income is 10, or 16 for bursar. With no hero it is 10. Coffer gold is not included. summary.enemyLives, summary.enemyGold, and summary.enemyHero are the other lane. summary.towers is your towers. Each has id, at, x, y, tower, name, rank, path, aim, hp, role, dmg, range, and reveal. summary.creeps is creeps on your lane. Each has id, kind, name, hp, maxHp, from, along, x, y, flying, hidden, armor, slow, poison, and fade. along is position on the path. from is the start of this beat. hidden is 1 when a tower with reveal 0 cannot shoot it. flying is 1 for a flier. summary.queue is how many creeps are waiting to enter your lane. summary.enemyTowers uses the same tower fields. summary.enemyQueue is the other waiting count. summary.enemyCreeps is a count of creeps on the other lane, not their details. summary.pads lists empty build sites with at, x, and y. summary.aim is first, last, strong, and air. summary.send lists kind and cost. summary.note is a fixed reminder. ## Actions legal() returns an object. The match response puts it on data.schema, not data.legal. data.schema.example is one command this beat accepts, not the only one. Put that command, or another accepted command, in actions. The object also has max, hero, towers, pads, upgrade, sell, aim, and send. max is 8. Send at most 8 commands. Pick a hero before any other op: {"op":"hero","id":"warden"}. id is warden, plague, hawk, or bursar. warden builds bolt, shell, frost, and wall, and sets lives to 25. plague builds blight, frost, star, and bolt. Plague adds 1 to slow on a tower that already slows, and 1 to poison on a tower that already poisons. hawk builds hawk, bolt, star, and blight. bursar builds coffer, bolt, shell, and wall, income 16, and its towers except coffer cost 115 percent of the base price, rounded down. Build: {"op":"build","at":0,"tower":"bolt"}. at is a pad at. tower must be in towers. Base costs are bolt 50, wall 60, frost 70, blight 75, shell 80, star 90, hawk 100, and coffer 40. A coffer adds gold at the end of the beat, starting at 4. A wall blocks ground creeps. Fliers pass walls. Upgrade: {"op":"upgrade","id":1,"path":0}. path is 0 or 1, rank must be below 3, and path cannot change later. Cost is 40 plus 30 times the current rank. Sell: {"op":"sell","id":1}. You receive 60 percent of gold spent on it, rounded down. Aim: {"op":"aim","id":1,"mode":"first"}. first is furthest along the path. last is nearest the entrance. strong is highest hp. air prefers a flier, then furthest along. Send: {"op":"send","kind":"swarm"}. kind must be in send. That creep joins the other lane. A build, upgrade, or send you cannot afford does nothing. Any other op is rejected. ## Finish result.ranks is [south rank, north rank]. Rank 1 wins. Both 1s means the lanes tied. An empty actions array holds that beat. Creeps still move. A missed clock is actions [null]. That is also a hold. A miss does not make you lose by itself. ## Secrets No information is hidden.