Tower Defense (Abandoned)
Anyone is free to take over this challenge and fork as necessary. Just give me credit ;)
Tower Defense is a format for casual games that was popularized in the Flash era. The player places towers that shoot down invaders moving along a predefined path.
Two submissions will compete against each other to invade the other player's village without being invaded themselves. They will have the ability to place towers, upgrade them, and spawn invaders to attack the enemy village. The game will be simulated deterministically in a turn based fashion, with each player being able to do one action each turn.
The game board is made up of two paths, each 100 spaces long. Each player begins with 500 gold, which is used for building towers and spawning invaders; and 100 life. Your objective is to bring your opponent's life down to 0. If neither player has been defeated after 100000 turns, the winner will be the player with the most life at that point, with ties being broken by who has the most gold at that point. If, somehow, there is still a tie, the match will be considered a tie.
Every 10 turns, players will receive gold. Initially, they receive 10 gold, but this amount increases by 3 every 100 turns.
Each time you successfully get an invader through your opponent's defenses, your income increases by 1 and you receive a portion of your income proportional to how much HP the invader had left.
Each time one of your towers defeats an invader, you receive gold. (More on that below)
Each space on the path can house one tower. There are 3 types of towers, which have a range and a power. It takes 10 turns for a tower to be ready after it is built. Towers can be upgraded either with a wider range or an increased power, in increments of 1. There is no hard limit to how many times a tower can be upgraded.
Range refers to how many spaces away from the tower that can be reached by the tower's abilities. A range of 0 means that only the space that the tower is on is affected by the tower's attacks.
Power has a different meaning depending on the kind of tower.
Each turn, turrets fire at the invader within range that is farthest along the path to your village. They deal damage equal to the tower's power.
Turrets begin with a range of 1 and a power of 1.
Stunners fire at the invader within range that is farthest along the path to your village. However, instead of dealing damage, they stun the invader for a number of turns equal to the tower's power. After firing, stunners cannot fire again for their power + 1 turns. Stunners will not fire at invaders that are already stunned.
Stunners begin with a range of 0 and a power of 3
When an invader is on the same space as the bomb tower, it triggers and deals damage equal to its power to all invaders within its range. After being triggered, it cannot fire again for another 5 turns.
Bombs begin with a range of 2 and a power of 2
Each turn, you may spawn an invader. At minimum, it costs 10 gold and has a base HP of 10. You can spend additional gold to increase its power:
- (1G) +1 HP
- (10G) +1 Defense (reduce damage taken by 1, but not lower than 1)
- (10G) +1 Stun resistance (reduces stun time by 1 turn)
You are limited on the maximum stats. You start off unable to boost stats, but every 100 turns, the maximum increases by 5
There can only be one invader on each space of the board and invaders cannot pass through each other. You cannot spawn an invader if there is already an invader on the first space of the board. Therefore, a potential counterplay from defenders to prevent massive hordes of invaders is to put stunners on the first few spaces.
The main game / AI driver is here (still a work in progress)
Submission logistics TBD
Both players will have complete knowledge about the state of the game and will be allowed to maintain state from the beginning of the game. They may not directly modify the game state. Any attempts to do so will be disqualified as will any attempt to obfuscate such an attempt.
(api description will go here)
Defenders should return an object with an
action property that is either
'destroy'. Each requires some additional properties to be set: (will add later)
Invaders should return an object which contains any stat boosts desired:
Both defenders or invaders may also return undefined or null to indicate not taking an action.
AIs must return their desired action in less than 10 milliseconds, averaged over 100 turns. Invalid actions returned by the AI will be ignored.
All submissions will compete against all other submissions in a round-robin tournament. The bot that wins the most matches is declared the winner. In the event of a tie, the number of turns it took to win will be totaled for all winning matches with the smallest cumulative turn count to victory wins. In the unlikely event of a further tie, the turns to loss will be totaled for all losing matches and the bot with the highest cumulative turn count to loss wins.
Only one submission per user can be scored in the round-robin tournament.
- No abusing standard loopholes
- No direct modification of the game state passed to you. It will not be defensively deep-copied. Don't obfuscate your code to try to hide state modification.
- Any uncaught exceptions will result in disqualification.
- Implementations must be totally deterministic, i.e. random number generators are only allowed if seeded consistently (either with a constant or with game state) and must use isolated random state which the other AI in play cannot access.
- Submissions shall include an explanation of the AI's strategy.