Coder Social home page Coder Social logo

bot.land's Introduction

Bot Land Scripts

This repo contains TypeScript code for controlling bots on Bot Land. Bot Land is an RTS game where you control your units programmatically instead of manually. This code, with appropriate tactical use, reached #1 on the Bot Land attack leaderboard in October 2019:

These bots allow you to execute a variety of strategies. If you're familiar with units from Starcraft 2 / Warcraft 3, these bots are analogous to:

  • micro / blink Stalkers that kite enemies
  • "Siege Tanks" (artillery) that micro and lay mines
  • specialists in melee combat
  • a cloaking melee unit that does splash damage
  • cloak rushing the enemy CPU
  • supporting other units (medic, repair, etc.)

Except, now you can micro your units perfectly via code instead of with your fingers. For example, check out this 5vs12 battle using missiles and landmines:

5vs12 fight

Getting Started

This is a JavaScript/TypeScript project, and requires that you have NodeJS and Yarn installed on your system first. Then, do the following:

  1. Clone this repository: git clone https://github.com/mizzao/bot.land.git.
  2. Install local dependencies: yarn install.
  3. Build the bot code: yarn build.

Bots will show up in the build directory. If you have any problems, create an issue.

We recommend you use VS Code to work with this repo if you don't already have an editor of choice, as it will automatically set up most of the tools used here. You can use the Run Build Task (Ctrl+Shift+B by default) command to build all the bots.

Features

Bot Land uses a reduced dialect of JavaScript where all variables are global and code is written as a single file. Obviously, this makes it difficult to use modern development conveniences like type checking, code reuse, and sharing code between bots. This repo is my attempt to fix some of those issues and make it more fun to write code for bots. It includes the following, much of which is provided by TypeScript:

  • Static and inferred types for the Bot Land API
  • Code isolation and reuse (using Typescript and project references)
  • Incremental builds (Typescript 3.4)
  • Fine control on how source *.ts files get compiled into target *.js files
  • Code formatting and linting (Prettier and Tslint)

For more information on how we set up TypeScript to transpile to a format that Bot Land will accept, see this StackOverflow question.

Commands

Several commands are available as yarn scripts: yarn <command>, which you can see in package.json. The ones of note are:

  • build and build-clean to compile all bots
  • format and lint to format code and check for common errors
  • botland strips out all var keywords in the output and converts all variables to global.

Add New Bots

If you want to write new bots, first fork this repo. Then:

  1. Copy any bot folder (i.e. Sneaktillery) to a new folder <NewBot>.
  2. Rename the bot (e.g. Sneaktillery.ts --> <NewBot>.ts).
  3. Edit the <NewBot>/tsconfig.json to set files and outFile with the name of the new bot.
  4. Edit tsconfig.json and add a reference to <NewBot>.

If you like your new bot and it works well, consider opening a pull request to share your code with the community.

Known Issues

Because Bot Land uses an "eccentric" version of JavaScript, you should keep in mind that not everything written in standard TypeScript will transfer verbatim to your code. For example, all local variables will be global: const foo = 42; in a function may be overwriting an existing value of foo that you may be using elsewhere. Using TypeScript means we are protected against using undeclared variables in local function scopes; however if you want to use stateful global variables explicitly it is a good idea to declare them with declare let GLOBAL_FOO; at the top of your bot file.

Shared variables and arrays also have an non-standard interaction, which will be documented later.

Bugs / Questions

Can't find an answer to your question here? Open an issue or discuss this code on the Bot Land Discord.

bot.land's People

Contributors

mizzao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

bot.land's Issues

Defense test checklist

  • Reflect / shields (especially team activations) are correct
  • Movement / patrol is correct
  • Artillery sneaks are dealt with
  • Seeing new units and following is correct
  • Mining team
  • Lure and sneak

Artillery improvements on defense

Will help with both side sneaks, as well as dealing damage that can't be reflected while tanks keep enemies still.

On defense:

  • waypoint movement code
  • do not wait for sensors to move (but activate them if available)
  • micro at a smaller evade distance (min of 5)

Artillery helper

Has repair, as well as a strong melee attack to break up anyone who gets near.

Requires code to coordinate movement.

ZapKiteBot

Loadout:

  • zapper 3
  • thrusters 2/3
  • reflect 1/2

Attempts to keep the closest enemy at (1,1). On a diagonal so avoids lasers. Moves too quickly for artillery. Can only be melee'd with charge available. Reflects missiles.

Could complement missile kiters well. Worth giving a shot.

Better evasion along back/bottom walls

On side walls:

  • When evading along bottom wall randomly step upward. This is because enemies follow horizontally and won't step on the mines, etc. This allows us to get out and around again.

On rear wall:

  • Bots get stuck when there are more than 2 enemies, but should just run forward and try to go around.

Sneaktillery improvements

  • Allow sneaktillery to kill chips from the side t(hen, it may be able to continue along undetected.)
  • Allow it to move around blocking units in the way
  • If teleport is enabled, jump forward when trying to advance.
  • better support for 2 sneaktillery at once

Handle other equipment:

  • cloak
  • reflect
  • teleport

Fix EWMA movement issues

  • Do not shoot chips when out of EWMA range; this has caused many groups of bots to get ded.
  • Bots shouldn't be forced to move toward EWMA, the ones that are actively microing should "pull" the ones that are not occupied. So move the code toward the end rather than the beginning.

DistractBot

Regen 3, TP 2, thrusters 2

The whole point of this bot is to keep the enemy team occupied for as long as possible. For hard to crack, coordinated defenses that need a distraction so that a crack team can take out the CPU.

Cloak rush defenses

Ideas:

  • light them on fire with inferno zap or laser
  • always attack to an enemy location that is within 3 columns of the right
  • defenders should bump cloak locations (require getting on the space of enemy target): this also is unaffected by the fire zappers dying.
  • Missile micro should not back up when they uncloak

Add melee to chaos zapper

If melee is not equipped, it will keep going around at 2x DPS (flash zapper).

But if it is, it should bash adjacent units a bit, cloak and all.

Missile micro darts across a row of enemies in an attempt to avoid laser

It will run across a whole column and back.

If there is an enemy in the row we're moving to, don't move there. Just move the other way, or back, or shoot. (This helps with offense as well).

This code may inadvertently help with artillery dodging, but that is only at 5 range, so we can factor it out to a separate section.

Make defense less vulnerable to lures / landmines

Phase 1: dedicated reflect 3 / thrusters 3 miners lured out the tanks.
image

Phase 2: 2 of the same, plus 2 reflect 3 / melee 2 teleporters. Once rangers engaged the miners were pretty useless.
image

Phase 3: laser 3 / reflect 3. These guys were dumb and shot chips, but most of the damage was self-inflicted via reflect.
image

Ideas:

  • lasers on defense?
  • if tanks are damaged and beyond halfway point, pull back.

Better defense coordination

Tanks should have reflect 3, no shield.
Behind units should cast shield on tanks, as big as possible.

Need to figure out a heuristic to get shields cast on tanks.

Too many editor configs

Not sure which one of these is authoritative, but the ones that aren't should be deleted.

  • .vscode/settings.json
  • .editorconfig
  • .prettierrc.json
  • tslint.json

Bundle of melee units

Like spartans... band together to reduce surface area. Could be useful against uncoordinated/mass melee enemies.

Improve mining coordination / avoid leroy jenkins

It seems that when one of the miners goes ahead and leeeroy jenkins everyone, there is not a good distribution of mines when enemies charge. We should help them to coordinate better.

Mine layers also don't lay enough mines when enemies are further out but not that close.

Ideas

  • advancing in a diagonal should stay that way
  • random up/down movements actually don't help for miners...coordinate?

Would be interesting if miners could keep formation, at least for the initial assault.

Unified defense is vulnerable to chip killing

By the time attacking artillery that start from the back make it up to the front, defenders have backed up to the CPU, and just let the chips die.

Maybe this is OK though. The chips buy us a turn.

Fix artillery micro mining

Just like missile micro, it should run more the closer the enemy gets, not wait around to get pummeled.

Also, try running it on speed 3 instead of 1.

Repair bot

Used on attack.

  • looks for friendly bots to repair. broadcasts its location

  • if a bot sees repair bot nearby and no enemies, it waits to get repaired

  • mainly for supporting micro or artillery units.

AggroMiner improvements

  • Initial coordinated mine laying "carpet" (can prototype #44) until reaching back wall
  • Configurable VS_LASERS to either stay on row/col or on a diagonal
  • Configurable EVADE_DISTANCE: how close to stay to enemies while laying mines
  • Support/try various defenses:
  • reflect 3 / cloak 3 (shadow minelayer)
  • reflect 3 / cloak 1 / thrusters 2
  • thrusters 3 + shield/reflect (fast minelayer)
  • teleport + shield/reflect (evasive minelayer)
  • co-shielding of other minelayers
  • regen 2 / shield 2 / thrusters 2 (roach minelayer)
  • can also use regen in any combination above.

Generally very flexible because 6 slots are open!!

Fast Zapper

Update the zap kite bot: note that when using thrusters with zapper, damage is dealt every time the bot moves. So effective DPS can be twice as high (!!) as with normal zapper. But enemy melee units can only hit you half the time.

Why melee a single unit for 550 when you can splash in all directions for 700, and diagonally for 350? Then just cloak when zap runs out, and do it again!

Make defense less vulnerable to lures / mines

Too stringent and we risk getting a run-around and the CPU killed. We can probably clear if either condition is satisfied:

  • <= 3 spaces away with sensors on
  • <= 1 space away with no sensors on

Also, bots should not follow enemies more than halfway across the map (just delete enemy target location). This will both cause them to be less sensitive to mines, and get back to the CPU faster in case of lures. Because it will return and not just sit at the edge, it won't be vulnerable to artillery micro.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.