Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

New answers tagged

2

Memorizer import sys import random from functools import lru_cache board = [ [{"R"},{"K"},{"B"},{"Q"},{"k"},{"B"},{"K"},{"R"}], [{"P"},{"P"},{"P"},{"P"},{"P"},{"P"},{"P"},{"P"}], [set(),set(),set(),set(),set(),set(),set(),set()], [set(),set(),set(),set(),set(),set(),set(),set()], [set(),set(),set(),set(),set(),set(),set(),set()], [...


10

Pokey Opens with the knight-based variant of the Scholar's Mate (a 5-move checkmate). If this fails, it presses the attempt a little farther, with a sequence of moves that hardcounters Prickly. The structure of this bot is based on Prickly, but it improves on the Zombie March phase by frequently inserting king moves to get out of check, improves on the ...


11

Lichess 2013-2015 I gathered move frequency data from about 50 million lichess games. Moves are ordered from the most to the least frequent. Moves are considered equal if the from square and the to square are equal. Promotion is assumed to always be to queen. I've chosen lichess because I have a lot of them sitting on my hard drive. I don't expect it to do ...


8

Prickly Focuses on defensive captures, by sending a large number of probably-illegal moves after each move in its opening plan. The opening plan focuses on moving pieces to locations where they can easily defend each other. It tries to transition into a Zombie March midgame with an endgame based on a group of queens sweeping the board, but usually that ...


8

Backline Backline attempts to take advantage of the fact that its opponent can't see what's going on. It sends one piece at a time into its opponent's back rank, capturing as many pieces as possible before returning each piece to where it started so that it remembers where it is for next time. Backline is written in Python 3.7. #! /usr/bin/python3 ...


14

Blunt Instrument v2 There was a severe bug in the previous implementation that caused my bot to occasionally move pieces away from the enemy king. Given that the king is the most important piece, moving pieces away from him is obviously illogical. Now, any moves that lose too much ground are simply discarded. No retreat! No surrender! Moves that lose a bit ...


1

Parry and Slice - 472a33460a33c1785a28190c9406e36e Defends against CBC with a small stack of walkers, then goes for a 3-city buildup because nothing else is fast enough after spending time on shielding. It then moves into a Backstabber variant. Lategame, it throws in an occasional buildup phase to recover from situations where one of the endless rushers ...


1

Orbit - 1ec7b9413c34cd8cd66d5bf28a9537ef Just quickly threw this together on a whim but... The concept was to have the first walker keep ringing round the first city and see what happens. Uninterrupted, it keeps a pile of quite high-value walkers floating around until they build a few cities at once. Then keeps building, gradually creeping towards the ...


24

Just Everything Generates a list of every possibly legal move, shuffles it, then cycles through it repeatedly. Since there are only 1792 possibly legal moves, this will never forfeit due to the 2000-attempt rule. This is meant as a template that other answers can build on. #! /usr/bin/python import sys import random _, color, seed = sys.argv[:3] ...


21

Zombie March Slowly walks all its pieces forward across the board, in a random order (but favoring pawns). The first 5 moves sent specifically counter the scholar's mate. #! /usr/bin/python import sys import random _, color, seed = sys.argv[:3] random.seed(seed) moveorder = [(2, 2), (1, 1), (0, 2), (0, 1), (1, 2), (2, 1), (2, 0), (1, 0)] moveorder7 = [...


16

Scholar #include <assert.h> #include <stdio.h> #include <stdlib.h> enum { WHITE, BLACK }; int main(int argc, char **argv) { assert(argc == 3); int color; switch (argv[1][0]) { case 'w': color = WHITE; break; case 'b': color = BLACK; break; default: assert(0); } if(color == WHITE) { ...


2

CBC Forever - 9c65942bf924d9bb09e99d22daf0d8d0 An endless loop of inverse CBC. After a while it starts cycling walkers around behind it, to clean up any enemy cities that got into its corner. This is partly intended as a demonstration of how to do a long inverse CBC, but of course it beats a lot of stuff in its own right. const turn = api.turn(); const ...


3

Hocus Pocus(!?) - 966e8f3ad189b9535c2e1fad3ffc065a Weird strategy that I'm unable to describe - it's probably(?!) an amalgam of Feint, Two Cities (??!) and whatever else I can't remember. At the moment of posting, (I think it?) beats everything but the Evolvors and Intercept & Destroy. Uses anti-CBC at the beginning, then hocus pocus(!?) strategy. Edit: ...


4

Twin Cities - 46b9d27b1994c35a8ef214c1b2067609 Starts off with a corner start and then makes use of how attacks work to return fire before building up it's own forces. Beats most bots, loses to others. //Twin Cities const turn = api.turn(); if (turn < 31) { switch(turn % 2) { case 0: api.awayY(); break; case ...


1

Feint - cb68f09d808b5de34daf5c45b46f2bea Briefly dips into a reverse Cage Bar Cutter, then jumps to a corner and tries to get behind the opponent before switching to the main circling strategy. const turn = api.turn(); if (turn === 0) { this.generator = (function* () { yield* [[3, 8], [2, 16], [3], [0], [1], [0, 27]]; let laps = 1; ...


1

CBC Goes With Everything - f904da9534cf91ff2d5d399f59757ebc Repeats the CBC pattern 5 times, then proceeds to build its own Faraday Cage and perform a stock Galeforce. 6 appears to be the maximum number before it starts losing to variants of itself for being "too persistent"; I picked 5 'cause it's a nice round number close to that. const turn = api.turn()...


4

Intercept and Destroy - 3dcc9463f47626a217a5a51762f02fe6 An improved version of Cage Bar Cutter, intercepting creation of Faraday Cage-like structures. After attempting interception, escape to the corner and attempt to build on the opponent's side. Aggressive attackers will not target themselves, so you can build up there. Non-aggressive builders will have ...


6

Cage Bar Cutter - 49d7afbe8bb6d542acc871ac40d12e83 No more faraday cages! Similar to Zerg Rush, but tuned to prevent Faraday Cages from growing at all (in either direction). In the spirit of this being a trivial bot, it makes no attempt to clean up bots that escape to the corners (but most can't manage that anyway). const turn = api.turn(); const opening ...


2

Evolvor: Overnight - 7512fcfcef33bff323d5cdaf1bb833ff This is utilizing exactly the same evolution code as Evolvor: First Encounter, but with a significant increase to the time provided. As of the time of posting, this only loses to 4 entries - two of them mine (whoops) and all of them rushy. I hope to be able to fix this issue soon. switch ("...


2

Backstabber - 2d632fb11ea1a7b1b73788d396a6a45d After making Galeforce, I got to wondering if anything could beat a really persistent Doombeam - one that never stopped firing. None of the existing bots seemed to be able to. This bot can do it, though, and it beats most of the other bots too! const turn = api.turn(); if (turn === 0) { this.generator = (...


2

Galeforce - 294c357b051e6e165d18657748d02cfe Sets up 8 cities, then sprays walkers in various directions. Looks a bit like a Doombeam followed by a Line Drive (and the Galeforce vs. Doombeam matchup comes down to persistence). const turn = api.turn(); if (turn === 0) { this.generator = (function* () { yield* [[1, 24], [0], [1], [2], [1, 3]]; ...


3

Evolvor: First Encounter - c0382c11979adc1f47773714ffc8376f This is the first in what I hope becomes a series of bots that result from a genetic algorithm. Does some really weird things which result in tons of cities and then... usually can't convert it into a victory. switch ("...


2

3 Base rush - 3f6d1a1461564ace3d7e22cedba08c20 A bot building three cities before launching an indirect attack and proceeding to lose. if (api.turn() < 29) { api.awayX(); } else if(api.turn() < 40) { api.awayY(); } else if(api.turn() < 42) { api.awayX(); } else if(api.turn() == 42) { api.awayY(); } else if(api.turn() < 45) { ...


3

Line Drive - 54e4de5b03423cc19a1ec0e22f32a981 Attempts to occupy an entire column of the grid, then unleash an unstoppable barrage in the x-direction. EDIT: Now biases its barrage toward one wall and changes direction more rapidly, allowing it to beat some bots that the previous version couldn't beat. const turn = api.turn(); if (turn === 0) { this....


3

Sweeping Endgame - 3f69bdf2be37886ff396d0c485007e80 More complex bot, with a setup phase, a sweeping mid-game strategy, and an endgame that covers all corners and directions. //Sweeping Endgame v2 this.t = api.turn(); //initial city setup if (this.t < 29) { api.awayY(); } else if (this.t < 59) { api.awayX(); //mid-game loop, now attempts to ...


2

Quad Rush - a0a4a9f3c8b8863392f109fdfd52af00 Double barrel x2. EDIT: Changed the cadence so we end up with a [2] runner and two [1] instead of four [1], which makes a difference in some matchups. if (api.turn() < 29) { api.awayY(); } else if (api.turn() < 59) { api.awayX(); } else if (api.turn() % 3 == 0) { api.towardsY(); } else { api....


5

Double Barrel - 7d0a88c1533fc89b2ee26484bbcafc59 Makes a second city and immediately opens fire diagonally, catches lots of bots during setup. if (api.turn() < 29) { api.awayY(); } else if (api.turn() % 3 == 2) { api.towardsY(); } else { api.towardsX(); } You can include this bot in your code if desired.


5

Zerg Rush - 1f8b3963656f9e15577f886e0125a343 Oh boy, here we go... Of course a Zerg Rush would work. Why wouldn't it, right? It makes me feel incredibly dirty, but it had to be done. const turn = api.turn(); if (turn === 0) { this.generator = (function* () { while (true) { yield* [[3], [2, 2]]; } })(); this.nextCall ...


12

Doombeam - 496367ff51c27dc62ebdc473cd14f333 Time for a tryhard entry. Sets up a massive 12-city railgun and fires it off straight at the spawn point. Even if some of the cities get destroyed before the setup is complete, it still has enough firepower to devastate everything in its path. Additionally, after the far corner is filled with its cities to the ...


3

Weirdflow - 8f82f8a5fd15fc29e60b9cce4343309c This was an attempt at a very clean bot that turned into an incredibly sloppy counter to Rushdown. const turn = api.turn(); if (turn === 0) { this.generator = (function*() { for (let i = 0; i < 10; ++i) { yield* [[0], [2, 2]]; } for (let i = 0; i < 5; ++i) { ...


Top 50 recent answers are included