title: Totally Blind Chess

text:
# Question
Title: Totally Blind Chess
In this challenge, you play chess without seeing any of your opponent's pieces or moves. Or your own pieces. Or whether your own moves succeeded. You send only a stream of moves, with no feedback. If your move is legal (when it is your turn) it will be played, otherwise it is silently discarded.

## I/O

The only input is two command line arguments. The 1st is either `w` or `b`, indicating whether you play White or Black. The 2nd is an integer in the range \[0, 263), which you may use as a random seed. For a given seed, your program must produce deterministic output.

Your output must be an infinite stream of move attempts, one per line, in the format `<start square> <end square> [optional piece for pawn promotion]`. Squares are specified in algebraic notation. The 3rd parameter may be one of `q r b n`, for queen, rook, bishop, or knight respectively. Castling is performed by specifying the start and end locations of the king. If the 3rd parameter is not provided for a pawn promotion, queen is chosen by default. If the 3rd parameter is provided for a non-promotion, it is ignored. Examples:

* `b2 c4` (a possible knight move)
* `e3 d5 q` (another possible knight move)
* `e2 e1 b` (a possible promotion of a black pawn to bishop, or a king, rook, or queen move of either color)
* `g7 h8` (a possible capture by a white pawn which promotes to queen, or a bishop, queen, or king move of either color)
* `a8 f1` (a move attempt which always fails)

Check out the example bot for clarification on the I/O formats.

Any illegal move attempts will be skipped. Note that it is illegal to leave your king in check. When it is your turn, the controller will keep reading lines until it finds a valid move. This means that **all games will be valid according to the rules of chess**.

## Limits

* The game shall be declared a draw if both players complete 100 consecutive moves without captures or pawn moves.
* A player who makes 2000 consecutive unsuccessful move attempts shall forfeit the game.
* Players must output move attempts reasonably quickly, say no more than 10 ms per move attempt. There is no hard limit for this; ask me in The Nineteenth Byte if you are in doubt.
* Your program must be runnable with free (lunch) software on at least one of Windows or Linux.

## Controller

To download the controller (so far tested on Windows and Ubuntu),

```
git clone https://github.com/feresum/totallyblindchess.git

```

The repository is periodically updated to include the source code and configuration for all the players in the contest. See the README for usage instructions.

## Victory condition

A round robin tournament where each pair of opponents play 200 games. Players score 2 points for a win and 1 point for a draw. Most points wins.

## Final standings

The controller seed was 6847095374473737716.

```
================Standings after 100 cycles:=================
  Pokey                 3003
  BlindMoveMaker1       2412
  Prickly               2268
  Backline              2069
  ZombieMarch           1990
  JustEverything        1688
  Lichess2013-2015      1625
  Memorizer             1598
  BluntInstrument        738
  Scholar                609
============================================================

```

Congratulations to Brilliand with Pokey, scoring 83%.

## Miscellaneous

Sample games from an old tournament

Although the official winner has been declared, you may, if you wish, post new answers with your score against the other participants (the controller repository includes all bots which competed).

# Answer
### 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 Just Everything idea by ordering the moves in a way that makes long-range moves more likely, and throws in a bit of Backline behavior right after the checkmate attempt. The queen swarm idea is still in there too, but that part is still failing.

```
#! /usr/bin/python

import sys
import random
import math

_, color, seed = sys.argv[:3]

random.seed(seed)

colnames = "abcdefgh"
rownames = "12345678" if color == "w" else "87654321"

def coord2code((col, row)):
    return colnames[col] + rownames[row];

def sendmove((a, b)):
    print coord2code(a), coord2code(b)

def long_safe_move(start, step, length):
    a,b = start
    x,y = step
    i = 0
    while i < length:
        m_start = (a+x*i,b+y*i)
        j = length
        while j > i:
            m_end = (a+x*j,b+y*j)
            if m_end[0] >= 0 and m_end[0] <= 7 and m_end[1] >= 0 and m_end[1] <= 7:
                yield (m_start, m_end)
            j -= 1
        i += 1

captures = ([((x,1),(x+1,2)) for x in range(7)]
         + [((x+1,1),(x,2)) for x in range(7)]
         + [((0,0),(0,1)), ((1,0),(3,1)), ((2,0),(1,1)), ((2,0),(3,1))]
         + [((7,0),(7,1)), ((6,0),(4,1)), ((5,0),(6,1)), ((5,0),(4,1))]
         + [((3,0),(2,1)), ((3,0),(3,1)), ((3,0),(4,1)), ((4,0),(5,1))])
sendmove(((4,1),(4,2)))
captures = ([m for m in captures if not (4,1) in m]
         + [((x,2),(x+1,3)) for x in range(7)]
         + [((x+1,2),(x,3)) for x in range(7)])
for m in captures:
    sendmove(m)
sendmove(((3,0),(5,2)))
captures = ([m for m in captures if not (3,0) in m and not m[0] == (5,2)]
         + [((4,0),(3,1))])
for m in captures:
    sendmove(m)
sendmove(((6,0),(7,2)))
captures = ([m for m in captures if not (6,0) in m]
         + [((4,0),(3,1))])
for m in captures:
    sendmove(m)
sendmove(((7,2),(6,4)))
captures = (captures
         + [((5,2),(5,6))])
for m in captures:
    sendmove(m)
sendmove(((7,1),(7,3)))
sendmove(((7,1),(7,2)))
sendmove(((7,2),(7,3)))
captures = ([m for m in captures if not (7,1) in m and not (7,2) in m]
         + [((7,0),(7,3))]
         + [((x,3),(x+1,4)) for x in range(7)]
         + [((x+1,3),(x,4)) for x in range(7)])
for m in captures:
    sendmove(m)
sendmove(((7,3),(7,4)))
captures = ([m for m in captures if not (7,3) in m]
         + [((7,0),(7,6))]
         + [((x,4),(x+1,5)) for x in range(7)]
         + [((x+1,4),(x,5)) for x in range(7)])
for m in captures:
    sendmove(m)
sendmove(((7,4),(7,5)))
captures = ([m for m in captures if not (7,4) in m]
         + [((x,5),(x+1,6)) for x in range(7)]
         + [((x+1,5),(x,6)) for x in range(7)])
for m in captures:
    sendmove(m)
sendmove(((7,5),(7,6)))
for m in long_safe_move((7,0), (0,1), 6):
    sendmove(m)
captures = ([m for m in captures if not (7,5) in m and not (5,6) in m]
         + [((x,6),(x+1,7)) for x in range(7)]
         + [((x+1,6),(x,7)) for x in range(7)])
for m in captures:
    sendmove(m)
sendmove(((5,2),(7,4)))
sendmove(((7,4),(7,6)))
captures = ([m for m in captures if not (7,4) in m]
         + [((6,4),(7,6))])
for m in captures:
    sendmove(m)
sendmove(((7,6),(7,7)))
captures = [m for m in captures if not (7,6) in m]
for m in captures:
    sendmove(m)
sendmove(((5,6),(6,5)))
captures = [m for m in captures if not (5,6) in m]
for m in captures:
    sendmove(m)
sendmove(((6,5),(7,6)))
sendmove(((7,6),(7,7)))
for m in captures:
    sendmove(m)
for m in long_safe_move((7,7), (-1,0), 7):
    sendmove(m)
for m in captures:
    sendmove(m)
for m in long_safe_move((7,6), (-1,0), 7):
    sendmove(m)
for m in captures:
    sendmove(m)
sendmove(((5,2),(3,0)))
sendmove(((7,4),(3,0)))
def zombiemarch():
    colorder = list(range(8))
    random.shuffle(colorder)
    roworder = [6,5,4,3,2,1]
    for col in colorder:
        for row in roworder:
            if col >= 1:
                yield ((col,row), (col-1,row+1))
            if col >= 1:
                yield ((col,row), (col-1,row+1))
            yield ((col,row), (col,row+1))
captures = list(zombiemarch())
for m in captures:
    sendmove(m)
captures = [m for m in captures if not m[0][1] == 1]
def jitter(tiles):
    fromset = set()
    for (a,b) in tiles:
        fromset.add(b)
    for (a,b) in fromset:
        if a>0:
            yield ((a,b), (a-1,b))
        if a<7:
            yield ((a,b), (a+1,b))
        if a>0:
            if b>0:
                yield ((a,b), (a-1,b-1))
            if b<7:
                yield ((a,b), (a-1,b+1))
        if a<7:
            if b>0:
                yield ((a,b), (a+1,b-1))
            if b<7:
                yield ((a,b), (a+1,b+1))
        if b>0:
            yield ((a,b), (a,b-1))
        if b<7:
            yield ((a,b), (a,b+1))
kingescape = list(jitter({((4,0),(4,0))}))
for m in captures:
    sendmove(m)
for m in captures:
    sendmove(m)
for m in kingescape:
    sendmove(m)
kingescape = list(jitter(kingescape))
for m in captures:
    sendmove(m)
for m in captures:
    sendmove(m)
for m in kingescape:
    sendmove(m)
kingescape = list(jitter(kingescape))
for m in captures:
    sendmove(m)
for m in captures:
    sendmove(m)
for m in kingescape:
    sendmove(m)
kingescape = list(jitter(kingescape))
for m in captures:
    sendmove(m)
for m in captures:
    sendmove(m)
for m in kingescape:
    sendmove(m)
for m in long_safe_move((7,7), (-1,0), 7):
    sendmove(m)
for m in captures:
    sendmove(m)
sendmove(((0,7),(2,5)))
for i in range(2):
    for m in long_safe_move((0+3*i,6), (1,0), 3):
        sendmove(m)
    for m in long_safe_move((1+3*i,7), (1,0), 3):
        sendmove(m)
    for m in long_safe_move((2+3*i,5), (1,0), 3):
        sendmove(m)
    kingescape = list(jitter(kingescape))
    for m in kingescape:
        sendmove(m)
sendmove(((7,7),(6,6)))
for m in long_safe_move((7,0), (0,1), 5):
    sendmove(m)
for i in range(3):
    for m in long_safe_move((6-2*i,6), (0,-1), 2):
        sendmove(m)
    for m in long_safe_move((7-2*i,5), (0,-1), 2):
        sendmove(m)
kingescape = list(jitter(kingescape))
for m in kingescape:
    sendmove(m)

def allmovegroups():
    # Knight moves
    for row in range(8):
        for col in range(8):
            for x in (1, 2, -2, -1):
                if x+col >= 0 and x+col <= 7:
                    for y in (2/x, -2/x):
                        if y+row >= 0 and y+row <= 7:
                            yield [((col, row),(x+col, y+row))]
                        else:
                            # Move knights away from edges
                            yield [((col, row),(int(math.copysign(x,4-col))+col, int(math.copysign(y,4-row))+row))]
    # Bishop moves
    for i in range(8):
        yield long_safe_move((0,i), (1,1), 7)
        yield long_safe_move((7,i), (-1,1), 7)
        yield long_safe_move((0,i), (1,-1), 7)
        yield long_safe_move((7,i), (-1,-1), 7)
        if i != 0:
            yield long_safe_move((i,0), (1,1), 7)
            yield long_safe_move((i,7), (1,-1), 7)
        if i != 7:
            yield long_safe_move((i,0), (-1,1), 7)
            yield long_safe_move((i,7), (-1,-1), 7)
    # Rook moves
    for i in range(8):
        yield long_safe_move((0,i), (1,0), 7)
        yield long_safe_move((7,i), (-1,0), 7)
        yield long_safe_move((i,0), (0,1), 7)
        yield long_safe_move((i,7), (0,-1), 7)

movegrouplist = [a for a in allmovegroups()]
random.shuffle(movegrouplist)

def allmoves():
    for movegroup in movegrouplist:
        for move in movegroup:
            yield move
movelist = list(allmoves())

while True:
    for (a, b) in movelist:
        print coord2code(a), coord2code(b)

```
> 15 votes

# Answer
### 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]

random.seed(seed)

colnames = "abcdefgh"
rownames = "12345678" if color == "w" else "87654321"

def coord2code((col, row)):
    return colnames[col] + rownames[row];

def buildmoves((col, row)):
    # Knight moves
    for x in (1, 2, -2, -1):
        if x+col >= 0 and x+col <= 7:
            for y in (2/x, -2/x):
                if y+row >= 0 and y+row <= 7:
                    yield (x+col, y+row)
    # Bishop moves
    for x in range(1,8):
        if col+x <= 7:
            if row+x <= 7:
                yield (col+x, row+x)
            if row-x >= 0:
                yield (col+x, row-x)
        if col-x >= 0:
            if row+x <= 7:
                yield (col-x, row+x)
            if row-x >= 0:
                yield (col-x, row-x)
    # Rook moves
    for x in range(1,8):
        if col+x <= 7:
            yield (col+x, row)
        if col-x >= 0:
            yield (col-x, row)
        if row+x <= 7:
            yield (col, row+x)
        if row-x >= 0:
            yield (col, row-x)

def allmoves():
    for row in range(8):
        for col in range(8):
            for to in buildmoves((row, col)):
                yield ((row, col), to)

movelist = [(coord2code(a), coord2code(b)) for (a,b) in allmoves()]
random.shuffle(movelist)

while True:
    for (a, b) in movelist:
        print a, b

```
> 25 votes

# Answer
### 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 = [(4, 0), (3, 0), (2, 0), (1, 0), (0, -4), (0, -3), (0, -2), (0, -1), (4, -4), (3, -3), (2, -2), (1, -1), (1, -2), (2, -1)]
colorder = random.sample([2, 3, 4, 5], 4) + random.sample([0, 1, 6, 7], 4)
roworder = [1, 2, 3, 4, 5, 6, 7, 0]

colnames = "abcdefgh"
rownames = "12345678" if color == "w" else "87654321"

def buildmoves((col, row), (x, y)):
    if row+y > 7 or row+y < 0:
        return
    if x == 0:
        yield (col, row+y)
        return
    if col < 4:
        if col+x <= 7:
            yield (col+x, row+y)
        if col-x >= 0:
            yield (col-x, row+y)
    else:
        if col-x >= 0:
            yield (col-x, row+y)
        if col+x <= 7:
            yield (col+x, row+y)

def coord2code((col, row)):
    return colnames[col] + rownames[row];

# Some fixed behavior (counter foolsmate)
print coord2code((6, 1)), coord2code((6, 2))
print coord2code((4, 1)), coord2code((4, 3))
print coord2code((3, 1)), coord2code((3, 3))
print coord2code((6, 2)), coord2code((7, 3))
print coord2code((3, 3)), coord2code((2, 4))

iter = 0
while True:
    iter += 1
    for row in roworder:
        for move in (moveorder if row*(1+iter*random.random()/10)<7 else random.sample(moveorder7, 8)):
            for col in colorder:
                for to in buildmoves((col, row), move):
                    print coord2code((col, row)), coord2code(to)

```
> 22 votes

# Answer
# 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) {
        printf("e2 e3\n");
        printf("d1 h5\n");
        printf("f1 c4\n");
        printf("h5 f7\n");
    }
    else {
        printf("e7 e6\n");
        printf("d8 h4\n");
        printf("f8 c5\n");
        printf("h4 f2\n");
    }
    srand(atoll(argv[2]));
    for ( ;; )
    {
        printf("%c%c %c%c\n", rand() % 8 + 'a', rand() % 8 + '1', rand() % 8 + 'a', rand() % 8 + '1');
    }
}

```

Scholar simply tries for a 4-move checkmate (with a 10% chance of a 2-move check that can result in a forfeit), then moves randomly after that. I tried adding in some nonrandom moves that were more likely to be legal, but at least in the naive way I did it that made the bot worse--more likely to forfeit when in check, I think.
> 17 votes

# Answer
# 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 of ground are also thinned out, so that Blunt Instrument will spend less time contemplating cowardly moves that retreat from the king and more time punching stuff.

I've also switched from using Manhattan distance to Chebyshev, which I should really have used all along. Now, we measure distance as a number of kings' moves rather than rooks' moves. Granted, not every piece moves like the king, but I don't know what piece I'm moving so sod it. If my own king manages to punch a few pieces in the face while we play then so much the better.

# Blunt Instrument

Inspired by Tom Murphy VII PhD's paper on high-performance chess algorithms, I've adapted his "swarm" strategy to this format. Swarm favours moves that put pieces as close to the enemy king as possible, since the king is the most important piece.

Since we don't actually know where the king is, we assume he stays where he is all game. Dodging is unsporting anyway. Stand still and take your punches, king!

Because we don't know whether any move has succeeded, I'll likely start out by making a bunch of pawn moves just to get them into the field, then probably throw the bishops out into the mid field and suicide them against the opposing pawns. I could probably do something more intelligent to do a sensible opening or whatever, but doing intelligent things deviates from the "playing chess with your fists" theme of my approach.

```
#! /usr/bin/python

import sys
import random

_, color, seed = sys.argv[:3]

random.seed(seed)

colnames = "abcdefgh"
rownames = "12345678" if color == "w" else "87654321"
ENEMY_KING = (4, 7)

def coord2code((col, row)):
    return colnames[col] + rownames[row];

def buildmoves((col, row)):
    # Knight moves
    for x in (1, 2, -2, -1):
        if x+col >= 0 and x+col <= 7:
            for y in (2/x, -2/x):
                if y+row >= 0 and y+row <= 7:
                    yield (x+col, y+row)
    # Bishop moves
    for x in range(1,8):
        if col+x <= 7:
            if row+x <= 7:
                yield (col+x, row+x)
            if row-x >= 0:
                yield (col+x, row-x)
        if col-x >= 0:
            if row+x <= 7:
                yield (col-x, row+x)
            if row-x >= 0:
                yield (col-x, row-x)
    # Rook moves
    for x in range(1,8):
        if col+x <= 7:
            yield (col+x, row)
        if col-x >= 0:
            yield (col-x, row)
        if row+x <= 7:
            yield (col, row+x)
        if row-x >= 0:
            yield (col, row-x)

def distance_to_square(coords1, coords2):
    x1, y1 = coords1
    x2, y2 = coords2
    return max(abs(x2-x1), abs(y2-y1))

def sort_key(move):
    from_, to_ = move
    # Our favourite moves are ones that land us on top of the enemy king
    # After that, we like moves that make us closer to the enemy king
    # After that, we like moves that take us a long way from where we started
    # After that, we like moves that move pieces that are a long way from the enemy king
    # After that, we pick at random!
    gained_ground = distance_to_square(from_, ENEMY_KING) - distance_to_square(to_, ENEMY_KING)
    return (distance_to_square(to_, ENEMY_KING), -gained_ground, -distance_to_square(from_, to_), -distance_to_square(from_, ENEMY_KING), random.randint(0, 999999))

def cowardly_filter(move):
    from_, to_ = move
    # Remove all moves that move more than 2 spaces away from the enemy king
    # Eliminate moves that gain no ground with probability 12/16
    # Eliminate moves that lose 1 space with probability 14/16
    # Eliminate moves that lose 2 spaces with probability 15/16
    # I pulled these numbers from my backside and don't know if they're actually good.

    gained_ground = distance_to_square(from_, ENEMY_KING) - distance_to_square(to_, ENEMY_KING)
    if gained_ground > 0:
        return True
    if gained_ground < -2:
        return False
    fudge_factor = random.randint(0, 16)
    # I tried to figure out a nice mathsy way of doing this but it's half past 8 and I want to play Dragon Age.
    if gained_ground == 0 and fudge_factor > 11:
        return True
    if gained_ground == -1 and fudge_factor > 13:
        return True
    if gained_ground ==  -2 and fudge_factor > 14:
        return True
    return False

def gen_all_valid_moves():
    for row in range(8):
        for col in range(8):
            for to in buildmoves((row, col)):
                yield ((row, col), to)

movelist = list(gen_all_valid_moves())

movelist.sort(key=sort_key)

# movelist = [(coord2code(a), coord2code(b)) for (a,b) in all_valid_moves]

while True:
    for (a, b) in filter(cowardly_filter, movelist):
        print coord2code(a), coord2code(b)

```

Thank you Brilliand for letting me shamelessly steal almost all your code.
> 15 votes

# Answer
# 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 well, it has nothing that is particularily tuned towards this challenge, but I'm curious how it will do.

```
all_moves = ['g1 f3 q', 'e2 e4 q', 'g8 f6 q', 'd2 d4 q', 'b1 c3 q', 'e1 h1 q', 'b8 c6 q', 'e8 h8 q', 'e7 e6 q', 'd7 d5 q', 'd7 d6 q', 'e7 e5 q', 'g7 g6 q', 'h2 h3 q', 'c7 c6 q', 'c2 c3 q', 'h7 h6 q', 'a7 a6 q', 'c7 c5 q', 'c2 c4 q', 'f8 e7 q', 'g2 g3 q', 'a2 a3 q', 'd2 d3 q', 'e2 e3 q', 'f2 f4 q', 'f7 f6 q', 'b7 b6 q', 'e4 e5 q','f2 f3 q', 'f3 e5 q', 'b2 b3 q', 'b8 d7 q', 'f1 e1 q', 'f1 c4 q', 'b7 b5 q', 'f1 e2 q', 'f8 g7 q', 'e4 d5 q', 'c1 e3 q', 'f6 e4 q', 'b1 d2 q', 'c8 b7 q', 'f8 e8 q', 'c5 d4 q', 'f1 d3 q', 'c1 g5 q', 'f7 f5 q', 'b2 b4 q', 'c8 d7 q', 'd4 d5 q', 'c8 g4 q', 'f3 d4 q', 'd1 d2 q', 'c4 d5 q', 'e6 e5 q', 'd4 e5 q', 'e6 d5 q', 'c3 d5 q', 'a2 a4 q', 'g2 g4 q', 'f6 d5 q', 'c6 d4 q', 'd6 e5 q', 'e5 d4 q', 'd8 d7 q', 'c1 d2 q', 'd8 e7 q', 'd1 e2 q', 'a7 a5 q', 'h2 h4 q', 'f1 g2 q', 'c8 e6 q', 'a1 d1 q', 'd5 e4 q', 'c6 c5 q', 'f8 d6 q', 'a8 c8 q', 'c1 b2 q', 'd6 d5 q', 'e7 f6 q', 'g8 e7 q', 'c1 f4 q', 'h7 h5 q', 'c3 e4 q', 'e5 e4 q', 'c6 e5 q', 'd8 c7 q', 'g7 g5 q', 'd5 d4 q', 'a8 d8 q', 'g1 h1 q', 'a1 c1 q', 'f8 c5 q', 'g7 f6 q', 'b7 c6 q', 'f4 e5 q', 'g8 g7 q', 'd1 f3 q', 'h4 h5 q', 'f3 g5 q', 'e3 e4 q', 'c3 c4 q', 'f4 f5 q', 'g5 f6 q', 'b2 c3 q', 'c6 d5 q', 'e1 a1 q', 'e3 d4 q','b5 b4 q', 'd3 e4 q', 'g8 h8 q', 'd3 d4 q', 'g6 g5 q', 'g4 g5 q', 'a8 b8 q', 'e2 f3 q', 'f3 f4 q', 'g4 f3 q', 'c8 f5 q', 'f8 b4 q', 'g2 f3 q', 'f1 b5 q', 'f6 f5 q', 'h3 h4 q', 'g1 g2 q', 'e8 a8 q', 'g3 g4 q', 'c3 d4 q', 'a1 b1 q', 'c5 c4 q', 'c4 c5 q', 'd1 c2 q', 'h5 h4 q', 'd5 c4 q', 'a5 a4 q', 'g5 g4 q', 'd8 f6 q', 'b4 b5 q', 'h6 h5 q', 'a6 a5 q', 'f5 f4 q', 'f6 e5 q', 'a4 a5 q', 'f7 e6 q', 'g1 e2 q', 'd7 c6 q', 'e7 d6 q', 'f6 g4 q', 'd4 c5 q', 'f1 d1 q', 'b4 c3 q', 'f5 e4 q', 'e8 e7 q', 'b5 c6 q', 'd8 d5 q', 'f8 d8 q', 'b6 b5 q', 'a1 e1 q', 'd1 d3 q', 'd7 e5 q', 'f2 e3 q', 'e2 d3 q', 'c4 b3 q', 'g1 f1 q', 'h8 g8 q', 'e5 f4 q', 'd1 d4 q', 'e1 e2 q', 'a3 a4 q', 'g1 h2 q', 'f3 e4 q', 'e8 d8 q', 'g8 f8 q', 'g1 f2 q', 'b3 b4 q', 'a8 e8 q', 'd1 e1 q', 'd7 f6 q', 'e5 f6 q', 'f6 d7 q', 'd8 e8 q', 'g8 h7 q', 'd8 b6 q', 'g8 f7 q', 'c3 e2 q', 'e6 f5 q', 'e1 d1 q', 'h6 g5 q','d2 c3 q', 'h1 g1 q', 'g5 h4 q', 'd3 c4 q', 'e4 f5 q', 'f8 f7 q', 'd2 f3 q', 'g4 h5 q', 'g7 h6 q', 'c3 b5 q', 'f1 f2 q', 'h5 g6 q', 'e3 f4 q', 'f6 h5 q', 'd8 d6 q', 'h3 g4 q', 'c4 b5 q', 'g5 f4 q', 'd6 c5 q', 'd2 e4 q', 'e5 e6 q', 'b5 c4 q', 'e8 f8 q', 'f7 g6 q', 'd5 d6 q', 'g4 f5 q', 'c1 b1 q', 'c6 e7 q', 'h4 g3 q', 'f3 h4 q', 'd4 d3 q', 'e5 d6 q', 'h7 g6 q', 'f3 d2 q', 'c4 d3 q', 'd8 c8 q', 'e1 f1 q', 'g6 f5 q', 'c8 b8 q', 'a6 b5 q', 'd2 e3 q', 'f6 g5 q', 'd7 c5 q', 'h5 h6 q', 'g2 h3 q', 'd7 e6 q', 'f2 g3 q', 'c6 b4 q', 'f4 g5 q', 'b4 c5 q', 'e7 f5 q', 'e4 e3 q', 'd5 c6 q', 'f4 g3 q', 'f5 g6 q', 'd1 b3 q', 'h4 g5 q', 'f3 g4 q', 'g3 f4 q', 'c7 d6 q', 'd1 c1 q', 'h5 g4 q', 'h2 g3 q', 'd5 e6 q', 'd4 c3 q', 'e4 f3 q', 'c6 a5 q', 'c5 b6 q', 'a3 b4 q', 'c2 d3 q', 'e4 f6 q', 'd1 d8 q', 'd3 e2 q', 'e8 d7 q', 'f3 g3 q', 'h4 h3 q', 'e7 g6 q', 'd7 b6 q', 'd1 h5 q', 'f5 f6 q','b6 c5 q', 'a4 a3 q', 'f4 f3 q', 'b3 c4 q', 'a5 a6 q', 'c5 b4 q', 'e5 f3 q', 'a4 b5 q', 'd8 d1 q', 'e2 g3 q', 'f5 g4 q', 'e7 d7 q', 'g5 g6 q', 'e8 f7 q', 'd2 c4 q', 'd4 c6 q', 'd6 e7 q', 'g4 g3 q', 'c4 c3 q', 'c5 c6 q', 'a5 b4 q', 'f4 e3 q', 'd3 d2 q', 'c8 c7 q', 'd8 a5 q', 'e7 g5 q', 'e2 d2 q', 'c6 b5 q', 'd6 d7 q', 'f6 g6 q', 'b5 a4 q', 'c7 b6 q', 'c3 a4 q', 'f5 e6 q', 'e2 f4 q', 'b4 b3 q', 'f8 g8 q', 'c5 d6 q', 'c1 c2 q', 'd3 c2 q', 'c2 b3 q', 'f8 c8 q', 'd4 e3 q', 'f6 e7 q', 'a1 f1 q', 'e3 d2 q', 'b5 b6 q', 'e4 d3 q', 'c3 b4 q', 'd4 f3 q', 'e6 e7 q', 'e3 e2 q', 'f3 e2 q', 'f1 g1 q', 'a8 f8 q', 'a4 b3 q', 'd7 e7 q', 'h1 h2 q', 'b7 a6 q', 'f7 e7 q', 'd2 e2 q', 'e7 c5 q', 'h6 g7 q', 'd7 c7 q', 'e5 c6 q', 'c8 d8 q', 'h8 h7 q', 'g6 h5 q', 'e1 d2 q', 'd5 f6 q', 'e7 f7 q', 'c8 a6 q', 'd2 b3 q', 'f1 c1 q', 'f2 e2 q', 'c6 c7 q', 'f3 e3 q', 'd1 d5 q', 'g3 h4 q', 'f6 f7 q','b8 a6 q', 'a5 b6 q', 'd8 d4 q', 'e7 d5 q', 'c1 d1 q', 'c3 c2 q', 'b4 a5 q', 'e6 d7 q', 'f3 f2 q', 'e2 f2 q', 'd2 c2 q', 'a6 a7 q', 'a3 a2 q', 'h8 f8 q', 'g8 h6 q', 'e7 d8 q', 'e5 c4 q', 'a2 b3 q', 'g7 f8 q', 'b3 c2 q', 'h6 h7 q', 'g5 e7 q', 'f1 f3 q', 'e4 d6 q', 'b2 a3 q', 'd8 h4 q', 'e2 d4 q', 'e4 c3 q', 'f6 g7 q', 'g5 h6 q', 'e1 e3 q', 'b1 a3 q', 'd6 c7 q', 'f6 e6 q', 'e1 f2 q', 'e3 f2 q', 'd5 c3 q', 'e7 f8 q', 'h7 h8 q', 'e2 c4 q', 'h1 e1 q', 'c7 d7 q', 'f7 g7 q', 'e2 g4 q', 'd1 g4 q', 'e5 d3 q', 'd1 a4 q', 'h8 e8 q', 'b6 b7 q', 'e5 d7 q', 'b6 c7 q', 'd8 g5 q', 'g7 g8 q', 'g6 g7 q', 'h3 h2 q', 'e4 c5 q', 'g5 e3 q', 'b3 b2 q', 'e3 f3 q', 'h2 h1 q', 'e3 d3 q', 'd4 f5 q', 'e6 f7 q', 'd3 e3 q', 'b7 d5 q', 'f8 f6 q', 'c7 b7 q', 'a7 b6 q', 'c2 d2 q', 'd5 f4 q', 'g3 f3 q', 'g7 e5 q', 'd1 d7 q', 'a8 a7 q', 'd8 f8 q', 'd3 f5 q', 'g7 f7 q', 'e7 e8 q', 'g3 g2 q', 'c4 e6 q','e3 g5 q', 'e7 c6 q', 'f7 f8 q', 'h1 f1 q', 'e3 c5 q', 'd7 d8 q', 'e5 g4 q', 'd3 c3 q', 'f2 g2 q', 'e4 g5 q', 'd7 e8 q', 'e1 e4 q', 'g5 e6 q', 'e6 d6 q', 'd6 c6 q', 'd1 f1 q', 'g4 h3 q', 'd1 d6 q', 'g2 f1 q', 'b3 a4 q', 'e5 g6 q', 'g5 f3 q', 'd8 d2 q', 'e2 d1 q', 'e1 e8 q', 'h3 g2 q', 'b8 c8 q', 'e1 e5 q', 'e6 f6 q', 'c2 b2 q', 'g2 f2 q', 'b6 a5 q', 'e8 e6 q', 'a2 a1 q', 'g6 f6 q', 'f3 g2 q', 'e7 h4 q', 'a7 a8 q', 'b8 b7 q', 'a1 a2 q', 'b5 d7 q', 'g2 g1 q', 'd6 e6 q', 'f2 f1 q', 'e8 e1 q', 'e2 e1 q', 'b1 c1 q', 'c7 c8 q', 'g3 f2 q', 'd2 d1 q', 'd7 b5 q', 'f3 h2 q', 'g6 f7 q', 'b7 e4 q', 'd2 f4 q', 'd5 e7 q', 'd3 b5 q', 'e4 g3 q', 'f4 d6 q', 'e2 f1 q', 'g4 e3 q', 'd5 e3 q', 'e1 e7 q', 'b1 b2 q', 'b7 c8 q', 'd6 f4 q', 'c1 a3 q', 'g4 e6 q', 'h8 d8 q', 'e8 e5 q', 'f5 d3 q', 'c2 c1 q', 'c6 d7 q', 'e4 d2 q', 'd4 e6 q', 'g4 f6 q', 'h8 g7 q', 'c5 e3 q', 'e7 b4 q', 'h5 f4 q','e2 c3 q', 'g4 e2 q', 'h1 d1 q', 'd7 f5 q', 'c4 f7 q', 'd7 c8 q', 'h7 g7 q', 'd8 d3 q', 'e2 h5 q', 'g1 h3 q', 'd5 e5 q', 'd4 e2 q', 'c1 h6 q', 'c5 e4 q', 'g7 h7 q', 'h1 g2 q', 'b7 b8 q', 'h7 g8 q', 'd2 e1 q', 'h2 g2 q', 'e6 c4 q', 'b5 d6 q', 'f6 e8 q', 'g3 h3 q', 'b8 a8 q', 'b2 b1 q', 'f7 e8 q', 'c3 d2 q', 'h2 g1 q', 'g4 e5 q', 'f4 g4 q', 'e5 d5 q', 'e4 f4 q', 'e4 d4 q', 'e8 e2 q', 'd2 g5 q', 'c4 e5 q', 'd4 e4 q', 'b4 d2 q', 'e2 b5 q', 'c4 e2 q', 'h5 f3 q', 'g5 e4 q', 'd4 c4 q', 'f4 e4 q', 'e1 e6 q', 'd2 b4 q', 'b2 d4 q', 'e5 f5 q', 'a5 c4 q', 'e8 e4 q', 'f6 h7 q', 'b1 a1 q', 'd3 g6 q', 'h4 f5 q', 'g2 h2 q', 'g6 h6 q', 'f5 e5 q', 'f5 g5 q', 'g4 f4 q', 'e3 h6 q', 'b6 c4 q', 'd5 c5 q', 'g6 f4 q', 'g5 f7 q', 'd2 c1 q', 'c6 b6 q', 'f6 d4 q', 'g4 h4 q', 'f7 g8 q', 'b2 a2 q', 'c8 c2 q', 'c5 d3 q', 'h3 g3 q', 'd4 b5 q', 'g3 f5 q', 'b6 d5 q', 'b7 f3 q', 'b7 a7 q', 'b5 d3 q','h5 g5 q', 'c3 d3 q', 'g2 e4 q', 'd7 g4 q', 'b6 c6 q', 'c2 e4 q', 'g5 f5 q', 'c7 d8 q', 'e6 g4 q', 'c6 d6 q', 'c7 e5 q', 'b7 c7 q', 'g7 d4 q', 'c4 d6 q', 'f8 b8 q', 'g5 h5 q', 'd5 b6 q', 'h4 g4 q', 'c6 b7 q', 'c1 c7 q', 'h6 g6 q', 'b3 d5 q', 'f1 f4 q', 'c3 b2 q', 'b4 d3 q', 'b2 c1 q', 'b2 c2 q', 'c3 b3 q', 'e5 f7 q', 'a6 b7 q', 'b5 c3 q', 'f8 f5 q', 'f1 b1 q', 'c4 e3 q', 'd7 f8 q', 'h5 f6 q', 'd6 b4 q', 'f2 e1 q', 'f5 d4 q', 'g7 h8 q', 'c5 e7 q', 'f3 d5 q', 'd4 b3 q', 'b2 e5 q', 'd5 b4 q', 'b3 c3 q', 'g6 e5 q', 'a4 c5 q', 'f3 e1 q', 'd8 b8 q', 'd5 c7 q', 'b5 a6 q', 'b4 d6 q', 'h4 f6 q', 'e1 c1 q', 'f5 e3 q', 'b6 d4 q', 'd5 d8 q', 'd2 f1 q', 'b4 a3 q', 'c8 c6 q', 'c5 e6 q', 'd4 c2 q', 'g3 e4 q', 'b4 c6 q', 'b3 c5 q', 'g6 h7 q', 'c8 h3 q', 'd1 b1 q', 'c2 d1 q', 'h6 f5 q', 'c7 e7 q', 'h4 f3 q', 'e8 e3 q', 'c1 c3 q', 'c4 d4 q', 'g3 e5 q', 'd8 a8 q', 'f4 d5 q', 'b8 d8 q','c1 e1 q', 'c8 e8 q', 'c8 c1 q', 'c5 d5 q', 'e8 c8 q', 'b5 c7 q', 'f2 g1 q', 'g3 h2 q', 'a3 b2 q', 'c2 e2 q', 'c5 f2 q', 'b6 a6 q', 'b1 d1 q', 'b8 b2 q', 'c4 a2 q', 'c1 c8 q', 'c4 b4 q', 'f4 d3 q', 'd2 h6 q', 'd1 a1 q', 'c8 c3 q', 'f8 h6 q', 'a7 b7 q', 'c8 c4 q', 'f5 e7 q', 'f3 h5 q', 'c5 b5 q', 'd6 g3 q', 'f5 d6 q', 'c3 d1 q', 'd1 g1 q', 'b7 a8 q', 'f4 e6 q', 'c7 b8 q', 'a5 c7 q', 'd8 g8 q', 'b2 f6 q', 'f1 f7 q', 'd4 d1 q', 'g5 d2 q', 'b4 e7 q', 'a2 b2 q', 'e4 f2 q', 'g4 d7 q', 'd4 f6 q', 'b1 b7 q', 'b3 a3 q', 'b3 d4 q', 'c6 d8 q', 'a6 c5 q', 'f3 h3 q', 'a5 c6 q', 'd2 f2 q', 'f1 f8 q', 'g6 e4 q', 'f8 a8 q', 'h4 e7 q', 'f1 f5 q', 'f6 h4 q', 'c6 e4 q', 'g2 d5 q', 'g4 f2 q', 'e7 c7 q', 'c2 b1 q', 'a3 c4 q', 'f1 f6 q', 'h4 g6 q', 'f8 f4 q', 'e2 c2 q', 'g2 h1 q', 'f1 a1 q', 'd5 f3 q', 'b4 c2 q', 'f4 d2 q', 'f4 e2 q', 'e3 b6 q', 'c5 d7 q', 'f8 f1 q', 'd3 h7 q', 'd7 f7 q','a8 a6 q', 'd3 f3 q', 'h2 g4 q', 'b6 b2 q', 'd7 b7 q', 'b4 c4 q', 'b5 d4 q', 'h5 g3 q', 'c8 c5 q', 'c1 c6 q', 'a5 b5 q', 'e3 g3 q', 'f8 h8 q', 'b2 a1 q', 'b6 d7 q', 'b4 d5 q', 'a4 b4 q', 'b1 a2 q', 'f3 f6 q', 'b1 c2 q', 'b8 a7 q', 'b5 c5 q', 'd2 b2 q', 'b5 e2 q', 'f8 f2 q', 'a4 c2 q', 'f8 f3 q', 'a8 g8 q', 'a4 c3 q', 'd4 d2 q', 'a6 b6 q', 'e4 e2 q', 'b3 a2 q', 'e5 g3 q', 'e4 c6 q', 'b4 a4 q', 'e2 e5 q', 'b8 c7 q', 'b5 a5 q', 'g7 c3 q', 'd6 e4 q', 'f3 d3 q', 'c4 d2 q', 'f3 d1 q', 'h3 f4 q', 'c1 c5 q', 'a1 a3 q', 'c3 e5 q', 'h6 g4 q', 'f4 h6 q', 'f5 h4 q', 'd6 f5 q', 'a6 c4 q', 'f3 c6 q', 'a3 b3 q', 'd7 h3 q', 'a1 g1 q', 'f6 c3 q', 'h5 e2 q', 'd7 a4 q', 'f4 c7 q', 'e5 g7 q', 'f5 d7 q', 'd5 d7 q', 'd5 a5 q', 'd3 e5 q', 'e5 c3 q', 'f6 d8 q', 'a6 c7 q', 'd3 f4 q', 'd5 b7 q', 'c1 c4 q', 'e3 f5 q', 'g6 e7 q', 'e4 g6 q', 'b1 e1 q', 'f6 f3 q', 'h3 g5 q', 'b8 b6 q', 'f6 b2 q','f4 h5 q', 'f3 b7 q', 'e6 g6 q', 'b3 b7 q', 'c8 a8 q', 'g4 h6 q', 'd5 b3 q', 'h5 f7 q', 'f1 h1 q', 'h6 f4 q', 'f5 c2 q', 'a6 b4 q', 'e7 g7 q', 'e7 e4 q', 'g3 h5 q', 'e3 d5 q', 'e6 h3 q', 'c7 a7 q', 'f1 h3 q', 'a1 a7 q', 'g3 e2 q', 'f6 f4 q', 'f3 f5 q', 'c8 f8 q', 'e5 e7 q', 'f5 h6 q', 'd2 a5 q', 'b3 e6 q', 'f3 f7 q', 'b1 b3 q', 'b8 e8 q', 'e4 c2 q', 'b6 a7 q', 'c6 b8 q', 'h7 g5 q', 'e6 f4 q', 'f6 h6 q', 'a5 b3 q', 'c7 d5 q', 'd4 b2 q', 'c2 a2 q', 'c2 f5 q', 'd1 h1 q', 'a8 a1 q', 'd6 f6 q', 'a4 c6 q', 'h8 c8 q', 'g5 h3 q', 'a8 a2 q', 'g5 d8 q', 'd6 c4 q', 'c1 f1 q', 'a3 c2 q', 'a5 c3 q', 'a2 b1 q', 'e5 c7 q', 'd8 h8 q', 'f4 h3 q', 'e6 d4 q', 'a1 a8 q', 'b3 d2 q', 'e6 b3 q', 'd4 b6 q', 'c4 b6 q', 'd3 c5 q', 'f4 g6 q', 'c6 f3 q', 'd5 f7 q', 'b6 d8 q', 'e4 g4 q', 'e5 g5 q', 'c1 a1 q', 'f5 g3 q', 'c7 a5 q', 'e2 g2 q', 'd3 a6 q', 'c7 f4 q', 'd4 f2 q', 'd6 d8 q', 'h6 e3 q','h8 h6 q', 'a6 d3 q', 'a3 b5 q', 'c5 b3 q', 'e3 g4 q', 'e4 b7 q', 'h4 f2 q', 'c2 e3 q', 'e1 g1 q', 'c2 f2 q', 'b7 g2 q', 'a8 a5 q', 'c7 f7 q', 'c2 a4 q', 'e1 b1 q', 'e4 g2 q', 'g8 g6 q', 'g6 h4 q', 'h6 f7 q', 'a1 a4 q', 'c7 e6 q', 'a5 c5 q', 'b6 e3 q', 'c2 d4 q', 'b2 g7 q', 'e3 a7 q', 'd3 b1 q', 'f6 d6 q', 'h5 e5 q', 'd4 g7 q', 'a4 b6 q', 'd3 b3 q', 'c7 a8 q', 'f6 g8 q', 'd3 d1 q', 'a3 c5 q', 'g7 b2 q', 'e7 b7 q', 'e5 b2 q', 'd6 h2 q', 'd3 g3 q', 'a4 c4 q', 'd4 f4 q', 'h1 h3 q', 'e2 e6 q', 'g4 d1 q', 'c6 a7 q', 'd6 b6 q', 'e8 g8 q', 'f4 h4 q', 'd2 d5 q', 'd3 f1 q', 'e2 b2 q', 'e3 c4 q', 'b5 b7 q', 'b6 b4 q', 'a7 b8 q', 'g2 c6 q', 'b4 b2 q', 'd3 d5 q', 'c3 f6 q', 'e6 g5 q', 'c5 a7 q', 'h2 f3 q', 'e8 b8 q', 'h3 f5 q', 'a7 c7 q', 'c3 b1 q', 'a8 h8 q', 'h1 c1 q', 'g1 g3 q', 'f5 h3 q', 'b3 d1 q', 'e5 e3 q', 'e6 c5 q', 'f2 d2 q', 'e3 e5 q', 'd5 f5 q', 'g3 d6 q', 'f7 d7 q','e2 e7 q', 'c5 c7 q', 'd6 f8 q', 'f5 h5 q', 'g6 d3 q', 'c7 c4 q', 'e5 c5 q', 'e7 c8 q', 'e5 e2 q', 'h4 f4 q', 'e3 c3 q', 'd5 d3 q', 'h5 f5 q', 'h3 e6 q', 'd6 d4 q', 'c3 a2 q', 'b6 d6 q', 'a1 a6 q', 'f4 f6 q', 'b8 b4 q', 'b7 d7 q', 'e2 a6 q', 'g3 e3 q', 'e7 a3 q', 'f4 h2 q', 'd7 d4 q', 'h8 h5 q', 'c2 g6 q', 'c3 e3 q', 'a1 h1 q', 'd6 b7 q', 'a2 c2 q', 'g5 g3 q', 'e4 e6 q', 'd7 a7 q', 'c4 c2 q', 'b8 b5 q', 'e3 c1 q', 'c4 a5 q', 'g5 e5 q', 'e6 c6 q', 'a8 b7 q', 'g4 g6 q', 'a8 a3 q', 'c6 a6 q', 'c2 a1 q', 'a8 a4 q', 'g4 e4 q', 'e8 f6 q', 'e4 c4 q', 'd4 d6 q', 'f5 f3 q', 'e6 e8 q', 'a1 a5 q', 'f4 f2 q', 'c3 a3 q', 'c5 a4 q', 'd6 f7 q', 'h7 f6 q', 'b1 f1 q', 'f5 f7 q', 'b8 f8 q', 'e1 g3 q', 'f7 e5 q', 'b3 d3 q', 'f1 g3 q', 'f2 d4 q', 'h6 f8 q', 'c6 e6 q', 'e7 e2 q', 'c4 b2 q', 'a3 d6 q', 'b3 b5 q', 'h5 h7 q', 'f6 f2 q', 'c5 b7 q', 'e3 e1 q', 'h4 e4 q', 'b2 d2 q', 'e6 a2 q','g2 b7 q', 'd2 a2 q', 'f8 g6 q', 'c4 a6 q', 'b1 b4 q', 'd5 g2 q', 'e6 f8 q', 'd4 b4 q', 'g6 e6 q', 'g3 g5 q', 'e8 g6 q', 'h3 f2 q', 'd5 b5 q', 'g5 h7 q', 'e4 h4 q', 'h8 h4 q', 'e5 h5 q', 'c6 a4 q', 'd2 g2 q', 'e4 e1 q', 'e6 e4 q', 'e2 c1 q', 'h3 f3 q', 'd2 d6 q', 'h5 h3 q', 'b8 b3 q', 'c7 c3 q', 'c7 b5 q', 'f7 d5 q', 'f7 h7 q', 'c5 a6 q', 'a1 b2 q', 'd5 d2 q', 'f4 d4 q', 'd3 b2 q', 'c4 e4 q', 'a5 d8 q', 'c5 e5 q', 'b1 b5 q', 'c4 a4 q', 'c7 c2 q', 'a6 e2 q', 'h1 h4 q', 'd7 g7 q', 'b1 b8 q', 'c3 a5 q', 'h4 h6 q', 'f3 c3 q', 'd4 a4 q', 'b8 b1 q', 'h1 h5 q', 'e6 c7 q', 'd5 d1 q', 'e7 e3 q', 'd4 d8 q', 'e3 f1 q', 'b4 a6 q', 'a6 c6 q', 'c5 a5 q', 'e5 e1 q', 'f7 d6 q', 'b1 b6 q', 'd4 d7 q', 'e6 c8 q', 'd2 d8 q', 'd6 b5 q', 'e4 e7 q', 'f5 g7 q', 'c6 c4 q', 'c4 c6 q', 'd3 f2 q', 'a4 d7 q', 'f3 g1 q', 'c7 g3 q', 'g8 g2 q', 'c4 a3 q', 'd7 b8 q', 'g8 e8 q', 'a3 c3 q', 'b5 a3 q','b5 a7 q', 'a5 d2 q', 'f2 h4 q', 'f1 e3 q', 'g8 g5 q', 'c2 c5 q', 'a2 d5 q', 'd6 a3 q', 'd3 b4 q', 'h5 g7 q', 'g1 e1 q', 'c5 c3 q', 'g6 g4 q', 'b3 f7 q', 'f2 e4 q', 'c4 c7 q', 'e5 e8 q', 'g6 f8 q', 'h1 h7 q', 'g4 g7 q', 'a5 a2 q', 'f7 h8 q', 'f2 h2 q', 'd7 d1 q', 'f5 d5 q', 'd6 g6 q', 'c6 a8 q', 'g1 g7 q', 'e3 c2 q', 'c2 c7 q', 'd2 d7 q', 'e8 d6 q', 'b7 e7 q', 'f7 g5 q', 'g5 g2 q', 'c6 c8 q', 'f2 c2 q', 'h6 f6 q', 'f8 e6 q', 'b7 c5 q', 'c3 c5 q', 'g5 c1 q', 'd6 b8 q', 'e1 f3 q', 'a7 d7 q', 'f7 c7 q', 'h8 a8 q', 'c2 b4 q', 'g1 g4 q', 'd1 e3 q', 'h4 h2 q', 'c3 c1 q', 'a5 a3 q', 'c6 e8 q', 'b6 a4 q', 'b4 d4 q', 'h8 h3 q', 'a4 a2 q', 'a5 a7 q', 'c5 f8 q', 'c4 f1 q', 'f4 g2 q', 'f5 h7 q', 'f4 f7 q', 'd4 g4 q', 'b2 c4 q', 'c2 c6 q', 'f1 a6 q', 'b6 f2 q', 'a2 c4 q', 'e7 e1 q', 'd3 d6 q', 'a6 c8 q', 'a3 e7 q', 'c6 g2 q', 'g5 g7 q', 'd7 d2 q', 'g3 f1 q', 'b2 e2 q', 'a6 a8 q','c5 c2 q', 'g3 g6 q', 'h8 h2 q', 'g4 h2 q', 'e2 e8 q', 'h8 b8 q', 'd7 d3 q', 'c3 g7 q', 'e1 d3 q', 'h1 h6 q', 'f3 f1 q', 'f8 a3 q', 'f2 d3 q', 'f7 h5 q', 'c5 a3 q', 'd3 d7 q', 'e6 g7 q', 'f6 f8 q', 'b3 a5 q', 'f6 c6 q', 'e3 h3 q', 'e6 e2 q', 'b6 b3 q', 'g4 g2 q', 'a4 a7 q', 'a4 a6 q', 'g8 g4 q', 'f4 c1 q', 'b4 a2 q', 'e3 e6 q', 'c3 a1 q', 'b4 b6 q', 'd5 a2 q', 'c3 e1 q', 'c3 c7 q', 'b5 d5 q', 'd3 d8 q', 'a5 b7 q', 'd6 d2 q', 'a7 b5 q', 'd6 c8 q', 'g7 f5 q', 'h1 a1 q', 'h6 d2 q', 'a2 d2 q', 'e7 a7 q', 'a3 a1 q', 'd6 d1 q', 'e4 e8 q', 'f3 b3 q', 'g8 d8 q', 'b3 b6 q', 'd5 h5 q', 'f7 f4 q', 'c3 f3 q', 'f2 g4 q', 'e3 e7 q', 'd6 d3 q', 'd8 e6 q', 'b5 b3 q', 'c6 c3 q', 'h7 f7 q', 'h3 f1 q', 'c3 c6 q', 'g3 g7 q', 'g1 d1 q', 'e2 a2 q', 'a4 d1 q', 'a8 c6 q', 'h3 h5 q', 'c6 c2 q', 'd4 h4 q', 'd4 a7 q', 'g1 g5 q', 'g6 g3 q', 'd6 a6 q', 'f5 f2 q', 'h1 h8 q', 'a5 d5 q', 'd5 g5 q','b7 d6 q', 'e4 h7 q', 'b7 f7 q', 'd2 b1 q', 'c2 g2 q', 'h6 h4 q', 'b2 f2 q', 'e8 c6 q', 'c7 g7 q', 'a7 d4 q', 'e5 h2 q', 'd3 a3 q', 'h1 b1 q', 'a6 f1 q', 'g4 c8 q', 'b6 b8 q', 'e6 e3 q', 'f2 f5 q', 'd5 a8 q', 'a7 e7 q', 'e8 c7 q', 'f5 c8 q', 'a3 c1 q', 'h4 g2 q', 'b3 e3 q', 'b4 b7 q', 'a7 c5 q', 'h8 h1 q', 'b2 d3 q', 'e3 g2 q', 'b6 e6 q', 'e1 h4 q', 'g3 c7 q', 'g8 g3 q', 'b6 c8 q', 'a2 b4 q', 'f2 b2 q', 'f3 a8 q', 'e7 h7 q', 'b5 b2 q', 'a4 b2 q', 'e8 h5 q', 'g6 c2 q', 'd3 c1 q', 'a4 d4 q', 'b3 b1 q', 'e6 d8 q', 'h4 d8 q', 'f2 c5 q', 'a5 e5 q', 'g1 g6 q', 'h3 d7 q', 'a7 c6 q', 'a1 c3 q', 'g7 e7 q', 'f7 b7 q', 'a2 e2 q', 'e6 e1 q', 'g3 d3 q', 'b1 d3 q', 'd8 c6 q', 'h2 f2 q', 'g2 f4 q', 'e1 c3 q', 'h3 h6 q', 'e3 d1 q', 'b1 e4 q', 'g6 g2 q', 'h5 d1 q', 'd3 h3 q', 'e7 g8 q', 'c6 f6 q', 'f7 f3 q', 'e6 h6 q', 'a2 e6 q', 'a7 f7 q', 'f2 f7 q', 'c8 g8 q', 'h8 f6 q', 'd4 a1 q','g3 e1 q', 'd6 e8 q', 'e3 b3 q', 'a2 f2 q', 'b5 f1 q', 'f2 f6 q', 'f4 b8 q', 'd1 c3 q', 'f8 d7 q', 'g6 e8 q', 'b7 b4 q', 'h2 e5 q', 'e3 e8 q', 'e2 h2 q', 'f5 b1 q', 'a3 a5 q', 'h6 h8 q', 'h7 e4 q', 'f6 h8 q', 'f7 d8 q', 'a6 d6 q', 'h5 h8 q', 'h2 f4 q', 'a7 e3 q', 'c1 g1 q', 'f7 f2 q', 'e6 b6 q', 'a6 a4 q', 'g2 e2 q', 'g4 d4 q', 'f4 f1 q', 'a8 d5 q', 'c5 c8 q', 'd3 e1 q', 'e5 h8 q', 'f6 a1 q', 'c4 c1 q', 'h3 e3 q', 'a2 c3 q', 'h4 h7 q', 'b7 b3 q', 'h6 h3 q', 'c7 c1 q', 'f7 h6 q', 'b2 b6 q', 'b5 e8 q', 'a7 a4 q', 'f5 f8 q', 'c2 c8 q', 'f7 c4 q', 'a2 a5 q', 'c8 d6 q', 'b2 b5 q', 'b4 f8 q', 'c4 f4 q', 'b4 e1 q', 'a3 d3 q', 'h7 f5 q', 'e2 g1 q', 'a1 d4 q', 'h4 d4 q', 'c7 e8 q', 'c8 h8 q', 'c7 a6 q', 'b3 c1 q', 'h3 h1 q', 'b7 b2 q', 'a3 f8 q', 'b3 f3 q', 'a5 a8 q', 'c1 d3 q', 'a4 a1 q', 'g7 e6 q', 'a8 e4 q', 'g5 d5 q', 'b8 d6 q', 'a4 e4 q', 'b8 e5 q', 'h5 d5 q', 'g6 d6 q','h7 d3 q', 'd2 h2 q', 'b4 e4 q', 'e4 b4 q', 'f4 c4 q', 'h6 e6 q', 'e5 b5 q', 'e4 b1 q', 'b2 b7 q', 'c3 g3 q', 'e1 c2 q', 'h4 e1 q', 'e5 a5 q', 'f6 b6 q', 'd7 h7 q', 'g6 h8 q', 'e4 a8 q', 'f1 d2 q', 'c1 h1 q', 'h4 h1 q', 'c5 f5 q', 'h5 e8 q', 'c4 c8 q', 'g7 g4 q', 'f2 h3 q', 'f2 h1 q', 'a1 e5 q', 'h5 h2 q', 'f3 h1 q', 'f3 f8 q', 'b5 e5 q', 'c8 e7 q', 'h7 e7 q', 'g8 c8 q', 'e5 b8 q', 'd1 f2 q', 'b6 f6 q', 'g7 a1 q', 'g2 g5 q', 'b8 g8 q', 'g2 e3 q', 'f5 c5 q', 'b2 g2 q', 'h3 h7 q', 'f2 d1 q', 'e5 a1 q', 'b5 b8 q', 'd8 f7 q', 'e4 a4 q', 'f6 f1 q', 'b1 g1 q', 'h1 f3 q', 'd6 h6 q', 'c5 c1 q', 'g6 g8 q', 'c2 e1 q', 'c3 c8 q', 'a2 g2 q', 'f2 a2 q', 'a8 c7 q', 'b7 g7 q', 'e8 g7 q', 'h7 h4 q', 'c2 a3 q', 'a6 a3 q', 'e4 h1 q', 'c8 b6 q', 'f7 a7 q', 'a7 g7 q', 'a3 a6 q', 'g1 c1 q', 'f4 f8 q', 'b4 b1 q', 'g1 g8 q', 'f5 f1 q', 'g7 d7 q', 'a6 e6 q', 'b8 h8 q', 'h6 c1 q', 'c4 g4 q','a3 e3 q', 'g7 g3 q', 'e6 a6 q', 'g8 g1 q', 'c4 g8 q', 'h2 e2 q', 'c6 c1 q', 'c6 g6 q', 'f7 f1 q', 'a7 a3 q', 'e3 g1 q', 'g2 d2 q', 'e3 a3 q', 'h2 f1 q', 'h7 f8 q', 'a5 a1 q', 'e8 b5 q', 'h2 d6 q', 'a6 a2 q', 'f7 b3 q', 'a3 a7 q', 'b6 a8 q', 'a2 a6 q', 'g3 g1 q', 'a6 b8 q', 'c5 g5 q', 'c2 h7 q', 'f2 b6 q', 'b1 h1 q', 'h8 e5 q', 'f2 f8 q', 'h8 f7 q', 'c1 e2 q', 'g3 c3 q', 'a4 a8 q', 'g2 g6 q', 'h2 h5 q', 'a8 f3 q', 'e1 b4 q', 'e6 g8 q', 'h3 d3 q', 'h5 c5 q', 'g7 c7 q', 'c7 h7 q', 'a1 c2 q', 'a5 f5 q', 'g2 c2 q', 'g2 a8 q', 'b1 f5 q', 'c1 b3 q', 'b3 g3 q', 'g3 h1 q', 'g4 c4 q', 'b4 f4 q', 'a7 a2 q', 'g8 a8 q', 'c2 h2 q', 'g5 c5 q', 'g7 h5 q', 'a7 h7 q', 'a2 a7 q', 'h6 h2 q', 'h7 d7 q', 'a3 f3 q', 'b4 b8 q', 'a4 f4 q', 'b7 a5 q', 'c7 h2 q', 'h1 e4 q', 'b2 b8 q', 'g1 a1 q', 'a2 h2 q', 'c4 h4 q', 'c5 h5 q', 'b3 a1 q', 'a1 f6 q', 'a5 g5 q', 'h2 d2 q', 'b2 a4 q', 'a5 h5 q','b7 b1 q', 'f3 a3 q', 'g8 b8 q', 'h7 c7 q', 'h3 c8 q', 'g6 c6 q', 'h4 c4 q', 'g7 g2 q', 'b6 g6 q', 'a8 b6 q', 'h4 h8 q', 'g2 b2 q', 'b5 b1 q', 'b3 b8 q', 'h2 c2 q', 'a3 b1 q', 'h7 b7 q', 'g1 b1 q', 'h6 d6 q', 'h7 h3 q', 'b5 f5 q', 'f8 h7 q', 'c3 h3 q', 'f4 b4 q', 'a6 f6 q', 'h2 b2 q', 'g2 g7 q', 'e1 g2 q', 'g5 g8 q', 'd4 h8 q', 'g7 b7 q', 'a5 e1 q', 'b6 b1 q', 'b7 h7 q', 'h8 g6 q', 'b8 f4 q', 'a4 e8 q', 'h7 a7 q', 'h6 g8 q', 'g2 h4 q', 'f1 h2 q', 'a7 c8 q', 'g4 g1 q', 'a7 a1 q', 'h5 h1 q', 'a4 g4 q', 'c5 g1 q', 'b2 h2 q', 'a2 a8 q', 'h2 a2 q', 'f4 a4 q', 'd8 b7 q', 'b7 d8 q', 'h2 h6 q', 'f5 b5 q', 'a2 f7 q', 'd5 g8 q', 'f6 a6 q', 'h3 c3 q', 'a6 a1 q', 'a2 c1 q', 'f5 a5 q', 'd4 g1 q', 'a3 a8 q', 'd1 b2 q', 'b4 g4 q', 'g4 g8 q', 'g8 e6 q', 'h8 d4 q', 'h2 h7 q', 'g2 a2 q', 'a3 g3 q', 'g7 a7 q', 'h3 h8 q', 'c6 h6 q', 'e8 a4 q', 'b2 d1 q', 'd5 h1 q', 'g5 g1 q', 'g3 b3 q','e1 a5 q', 'b1 g6 q', 'a7 f2 q', 'a1 b3 q', 'g1 e3 q', 'b5 g5 q', 'h3 g1 q', 'g3 b8 q', 'a4 h4 q', 'h7 h2 q', 'h1 f2 q', 'a6 g6 q', 'g6 b1 q', 'b7 h1 q', 'h6 c6 q', 'g3 g8 q', 'g4 b4 q', 'b3 h3 q', 'g7 e8 q', 'g8 d5 q', 'h6 h1 q', 'g1 d4 q', 'h1 d5 q', 'f2 a7 q', 'c8 a7 q', 'g6 b6 q', 'g5 b5 q', 'g4 a4 q', 'h5 b5 q', 'a1 g7 q', 'g5 a5 q', 'b4 h4 q', 'h4 b4 q', 'a8 g2 q', 'c3 h8 q', 'b2 h8 q', 'a3 h3 q', 'c6 h1 q', 'h5 a5 q', 'g6 g1 q', 'b5 h5 q', 'b6 h6 q', 'b8 g3 q', 'h1 g3 q', 'c1 a2 q', 'h3 b3 q', 'f7 a2 q', 'a6 h6 q', 'h4 a4 q', 'g3 a3 q', 'g2 e1 q', 'h7 h1 q', 'g2 g8 q', 'h2 h8 q', 'g7 g1 q', 'h3 a3 q', 'g6 a6 q', 'h8 c3 q', 'h6 b6 q', 'b3 g8 q', 'h7 c2 q', 'h6 a6 q', 'h2 c7 q', 'h1 c6 q', 'b6 g1 q', 'g1 c5 q', 'g8 c4 q', 'h8 b2 q', 'h1 b7 q', 'b1 h7 q', 'g8 b3 q', 'g1 b6 q', 'b8 h2 q', 'a1 h8 q', 'a8 h1 q', 'h8 a1 q', 'a2 g8 q', 'g1 a7 q', 'h2 b8 q', 'h7 b1 q','a7 g1 q', 'g8 a2 q', 'h1 a8 q']

def move_stream():
    while True:
        for move in all_moves:
            yield move

for m in move_stream():
    print(m)

```
> 12 votes

# Answer
### 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 fails and it winds up in its Just Everything fallback mode.

```
#! /usr/bin/python

import sys
import random

_, color, seed = sys.argv[:3]

random.seed(seed)

colnames = "abcdefgh"
rownames = "12345678" if color == "w" else "87654321"

def coord2code((col, row)):
    return colnames[col] + rownames[row];

def sendmove((a, b)):
    print coord2code(a), coord2code(b)

def long_safe_move(start, step, length):
    a,b = start
    x,y = step
    i = 0
    while i < length:
        m_start = (a+x*i,b+y*i)
        j = length
        while j > i:
            m_end = (a+x*j,b+y*j)
            if m_end[0] >= 0 and m_end[0] <= 7 and m_end[1] >= 0 and m_end[1] <= 7:
                yield (m_start, m_end)
            j -= 1
        i += 1

captures = ([((x,1),(x+1,2)) for x in range(7)]
         + [((x+1,1),(x,2)) for x in range(7)]
         + [((0,0),(0,1)), ((1,0),(3,1)), ((2,0),(1,1)), ((2,0),(3,1))]
         + [((7,0),(7,1)), ((6,0),(4,1)), ((5,0),(6,1)), ((5,0),(4,1))]
         + [((3,0),(2,1)), ((3,0),(3,1)), ((3,0),(4,1)), ((4,0),(5,1))])
captures.remove(((3,1),(4,2)))
captures.remove(((4,1),(3,2)))
sendmove(((6,1),(6,2)))
captures = [m for m in captures if not (6,1) in m]
for m in captures:
    sendmove(m)
sendmove(((6,0),(5,2)))
captures = ([m for m in captures if not (6,0) in m and m[0] != (5,2)]
         + [((5,2),(7,1)), ((5,2),(3,1))]
         + [((x,2),(x+1,3)) for x in range(7)]
         + [((x+1,2),(x,3)) for x in range(7)])
for m in captures:
    sendmove(m)
sendmove(((5,0),(6,1)))
captures = ([m for m in captures if not (5,0) in m]
         + [((6,1),(5,2))])
for m in captures:
    sendmove(m)
sendmove(((4,0),(6,0)))
captures = ([m for m in captures if not (4,0) in m]
         + [((5,0),(5,1)), ((6,0),(5,1)), ((6,0),(6,1)), ((6,0),(7,1)), ((6,0),(5,0))]
         + [((x,3),(x+1,4)) for x in range(7)]
         + [((x+1,3),(x,4)) for x in range(7)])
for m in captures:
    sendmove(m)
sendmove(((1,1),(1,2)))
captures = [m for m in captures if not (1,1) in m]
for m in captures:
    sendmove(m)
sendmove(((1,0),(2,2)))
captures = ([m for m in captures if not (1,0) in m and m[0] != (2,2)]
         + [((2,2),(0,1)), ((2,2),(4,1))]
         + [((x,4),(x+1,5)) for x in range(7)]
         + [((x+1,4),(x,5)) for x in range(7)])
for m in captures:
    sendmove(m)
sendmove(((2,0),(1,1)))
captures = ([m for m in captures if not (2,0) in m]
         + [((1,1),(2,2))]
         + [((x,5),(x+1,6)) for x in range(7)]
         + [((x+1,5),(x,6)) for x in range(7)])
for m in captures:
    sendmove(m)
for m in captures:
    sendmove(m)
sendmove(((3,1),(3,3)))
sendmove(((3,2),(3,3)))
captures = ([m for m in captures if not (3,1) in m and not (3,2) in m]
         + [((5,2),(3,3))]
         + [((x,6),(x+1,7)) for x in range(7)]
         + [((x+1,6),(x,7)) for x in range(7)])
for m in captures:
    sendmove(m)
for m in captures:
    sendmove(m)
sendmove(((4,1),(4,3)))
sendmove(((4,2),(4,3)))
captures = ([m for m in captures if not (4,1) in m and not (4,2) in m]
         + [((2,2),(4,3))])
for m in captures:
    sendmove(m)
for i in range(8):
    sendmove(((i,6),(i,7)))
for m in captures:
    sendmove(m)
sendmove(((3,3),(3,4)))
captures = ([m for m in captures if not (3,3) in m]
         + [((2,2),(3,4))])
for m in captures:
    sendmove(m)
sendmove(((4,3),(4,4)))
captures = ([m for m in captures if not (3,3) in m]
         + [((5,2),(4,4)), ((5,2),(3,3)), ((2,2),(4,3))])
for m in captures:
    sendmove(m)
captures = [m for m in captures if not (2,2) in m and not (5,2) in m and not (1,1) in m and not (6,1) in m]
for m in long_safe_move((0,7), (1,0), 7):
    sendmove(m)
for m in captures:
    sendmove(m)
for m in long_safe_move((7,7), (-1,0), 7):
    sendmove(m)
for m in captures:
    sendmove(m)
for m in long_safe_move((1,1), (1,1), 6):
    sendmove(m)
captures = [m for m in captures if not (1,1) in m]
for m in captures:
    sendmove(m)
sendmove(((6,1),(6,0)))
sendmove(((7,1),(6,0)))
for m in long_safe_move((6,1), (-1,1), 6):
    sendmove(m)
captures = [m for m in captures if not (6,1) in m]
for m in captures:
    sendmove(m)
sendmove(((2,1),(2,3)))
sendmove(((2,2),(2,3)))
captures = [m for m in captures if not (2,1) in m and not (2,2) in m]
for m in captures:
    sendmove(m)

def buildmoves((col, row)):
    # Knight moves
    for x in (1, 2, -2, -1):
        if x+col >= 0 and x+col <= 7:
            for y in (2/x, -2/x):
                if y+row >= 0 and y+row <= 7:
                    yield (x+col, y+row)
    # Bishop moves
    for x in range(1,8):
        if col+x <= 7:
            if row+x <= 7:
                yield (col+x, row+x)
            if row-x >= 0:
                yield (col+x, row-x)
        if col-x >= 0:
            if row+x <= 7:
                yield (col-x, row+x)
            if row-x >= 0:
                yield (col-x, row-x)
    # Rook moves
    for x in range(1,8):
        if col+x <= 7:
            yield (col+x, row)
        if col-x >= 0:
            yield (col-x, row)
        if row+x <= 7:
            yield (col, row+x)
        if row-x >= 0:
            yield (col, row-x)

def allmoves():
    for row in range(8):
        for col in range(8):
            for to in buildmoves((row, col)):
                yield ((row, col), to)

movelist = [(a,b) for (a,b) in allmoves()]
random.shuffle(movelist)

for (a, b) in movelist:
    if a[1] != 7:
        sendmove((a, b))

for i in range(8):
    sendmove(((i,7),(i,6)))
for i in range(7):
    sendmove(((i,7),(7,i)))
for i in range(1,8):
    sendmove(((i,7),(0,7-i)))
for m in captures:
    sendmove(m)
for m in long_safe_move((0,6), (1,0), 6):
    sendmove(m)
for m in captures:
    sendmove(m)
sendmove(((6,6),(6,7)))
sendmove(((5,6),(5,5)))
sendmove(((4,6),(4,4)))
for m in captures:
    sendmove(m)
for (a, b) in movelist:
    if a[1] < 4 and b[1] < 4:
        sendmove((a, b))
for i in range(3):
    for m in long_safe_move((7-2*i,6), (-1,0), 2):
        sendmove(m)
    for m in long_safe_move((6-2*i,7), (-1,0), 2):
        sendmove(m)
    for m in long_safe_move((5-2*i,5), (-1,0), 2):
        sendmove(m)
    for m in long_safe_move((4-2*i,4), (-1,0), 2):
        sendmove(m)
    for m in captures:
        sendmove(m)

while True:
    for m in movelist:
        sendmove(m)

```
> 9 votes

# Answer
# 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

import random
import sys

_, colour, seed = sys.argv[:3]
random.seed(seed)

files = "abcdefgh"

def colour_move(start, end, flip):
    if colour == "w":
        return (7 - start[0] if flip else start[0], start[1]), (7 - end[0] if flip else end[0], end[1])
    else:
        return (7 - start[0] if flip else start[0], 7 - start[1]), (7 - end[0] if flip else end[0], 7 - end[1])

def stringify_move(start, end):
    return f"{files[start[0]]}{start[1] + 1} {files[end[0]]}{end[1] + 1} q"

# This guarantees that if the piece is not taken, it reaches the final square as quickly as possible.
def safely_make_long_move(start, end):
    file_change = end[0] - start[0]
    rank_change = end[1] - start[1]
    used_squares = [start]
    while used_squares[-1][0] != end[0] or used_squares[-1][1] != end[1]:
        used_squares.append((used_squares[-1][0] + (1 if file_change > 0 else (-1 if file_change < 0 else 0)), used_squares[-1][1] + (1 if rank_change > 0 else (-1 if rank_change < 0 else 0))))
    for i in range(len(used_squares) - 1):
        for j in reversed(range(i + 1, len(used_squares))):
            yield (used_squares[i]), (used_squares[j])
    yield None

def rook_attack(p):
    flip = p == "h"
    # Move pawn forward two spaces.
    yield stringify_move(*colour_move((0, 1), (0, 3), flip))
    track = [(0,0), (0,2), (1,2), (1,7), (0,7), (7,7), (7,6), (1,6), (1,2), (0,2), (0,0)]
    for i in range(len(track) - 1):
        move_gen = safely_make_long_move(track[i], track[i+1])
        while True:
            move = next(move_gen)
            if move:
                yield stringify_move(*colour_move(*move, flip))
            else:
                break
    yield None

def bishop_attack(p):
    flip = p == "f"
    # Move pawn forward two spaces.
    yield stringify_move(*colour_move((3, 1), (3, 2), flip))
    track = [(2,0), (3,1), (2,2), (7,7), (6,6), (5,7), (4,6), (3,7), (2,6), (1,7), (0,6), (2,4), (1,3), (3,1), (2,0)]
    for i in range(len(track) - 1):
        move_gen = safely_make_long_move(track[i], track[i+1])
        while True:
            move = next(move_gen)
            if move:
                yield stringify_move(*colour_move(*move, flip))
            else:
                break
    yield None

def queen_attack(p):
    flip = False
    # Move pawn forward two spaces.
    yield stringify_move(*colour_move((4, 1), (4, 2), flip))
    track = [(3,0), (7,4), (7,7), (0,7), (0,5), (7,5), (7,4), (4,1)]
    for i in range(len(track) - 1):
        move_gen = safely_make_long_move(track[i], track[i+1])
        while True:
            move = next(move_gen)
            if move:
                yield stringify_move(*colour_move(*move, flip))
            else:
                break
    yield None

def knight_attack(p):
    flip = p == "g"
    # Move pawn forward two spaces.
    track = [(1,0), (2,2), (1,4), (2,6), (0,7), (1,5), (3,6), (5,7), (6,5), (7,7), (5,6), (3,7), (1,6), (2,4), (0,3), (2,2), (1,0)]
    for i in range(len(track) - 1):
        yield stringify_move(*colour_move(track[i], track[i+1], flip))
    yield None

# Just Everything's code:
colnames = "abcdefgh"
rownames = "12345678" if colour == "w" else "87654321"

def coord2code(col, row):
    return colnames[int(col)] + rownames[int(row)]

def buildmoves(col, row):
    # Knight moves
    for x in (1, 2, -2, -1):
        if x+col >= 0 and x+col <= 7:
            for y in (2/x, -2/x):
                if y+row >= 0 and y+row <= 7:
                    yield (x+col, y+row)
    # Bishop moves
    for x in range(1,8):
        if col+x <= 7:
            if row+x <= 7:
                yield (col+x, row+x)
            if row-x >= 0:
                yield (col+x, row-x)
        if col-x >= 0:
            if row+x <= 7:
                yield (col-x, row+x)
            if row-x >= 0:
                yield (col-x, row-x)
    # Rook moves
    for x in range(1,8):
        if col+x <= 7:
            yield (col+x, row)
        if col-x >= 0:
            yield (col-x, row)
        if row+x <= 7:
            yield (col, row+x)
        if row-x >= 0:
            yield (col, row-x)

def allmoves():
    for row in range(8):
        for col in range(8):
            for to in buildmoves(row, col):
                yield ((row, col), to)

movelist = [(coord2code(*a), coord2code(*b)) for (a,b) in allmoves()]
random.shuffle(movelist)

# Avoid Scholar
print("g2 g3")
print("g7 g6")

# Choose random piece to attempt to kill the enemy with.
used_piece = ["a", "b", "c", "d", "f", "g", "h"]
random.shuffle(used_piece)
while True:
    # Try to kill off their pieces by sending one piece at a time in to attack
    for p in used_piece:
        if p in ["a", "h"]:
            move_gen = rook_attack(p)
        elif p in ["b", "g"]:
            move_gen = knight_attack(p)
        elif p in ["c", "f"]:
            move_gen = bishop_attack(p)
        elif p == "d":
            move_gen = queen_attack(p)
        while True:
            move = next(move_gen)
            if move:
                print(move)
            else:
                break
    # Break out of possible checks by trying every possible move once.

    for (a, b) in movelist:
        print(a, b, "q")

```

Apologies for the somewhat messy code. Backline does reasonably well; against the current field it placed first in my tests, with 107 of 160 possible points.
> 8 votes

# Answer
# BlindMoveMaker1

BlindMoveMaker1 follows a genetic approach. During a game BlindMoveMaker1 uses a constant move list with fixed order which was evolved by a genetic algorithm (GA) off line. BlindMoveMaker1 simply cycles through the move list repeatedly. A move list starts with an opening part of 200 moves, followed by a main part of 1792 moves.

The opening part is a list of genetically picked moves (from the set of all possible moves) and move order. The main part is guaranteed to contain every possible move (not to lose because of a forfeit) but in a genetically tuned order.

Each move list was developed for white. When playing black each move is re-coded for black (e.g. turns 'e2 e4' into 'e7 e5').

The move lists were evolved off line by my GA playing against my beloved enemies (so far): Pokey, Prickly and Backline as sparring partners.

My GA is designed in such a way that the opening part is in the center of the genetic mutating (and crossover) storm while trying to evolve better move lists.

This GA is still running on my laptop. This way I hope to find even better move lists until the deadline.

Until now, it self-learned how to resist Pokey's/Prickly's early checkmate attempts.

```
import java.util.Random;
// Version 2.0
public class BlindMoveMaker1 {
    public static void main(String[] argv) {
        String list[] = {
                /* fitness      conf id           gen */
                /* 0.4862317      31 94e0a298    "d6c8 a4b3 e5b2 c1e1 h5h8 g6a6 c2c3 d6h2 c1h1 g2g5 c1f1 b1b8 d1d6 f3e5 d3d8 e6e2 g4g7 d6c7 d1b2 h6h4 c6c8 f7f3 c5b5 e1f3 b1a1 d6b8 e6f7 f3h1 h8e5 e1h1 b7a6 f6g5 a4b5 f2a2 f1e1 c2c1 d2f2 f7g7 a2a8 b6g6 h7h2 f2f3 b6d6 d5d1 c1c6 g2d2 f7g8 c1c2 e1c2 h6e6 d4d6 b4a2 g8d8 c4g8 e8h8 h3f2 c3h3 c5c6 c5f5 d4d1 d7c8 h2f4 c1a3 f3a8 b1e1 e7g6 h6d6 d4d2 d7b6 a2b2 h7g5 c6h1 b7f3 a8g2 f4a4 c1c5 d5b6 h5e8 f1h2 f6f3 a6b8 c4g8 e7e1 b7d7 f3h3 b7b3 b2b5 c6g2 g4g7 a3a4 g5d2 a3f3 b5a3 f1c4 h2f3 h2g4 g5h5 h7h3 b1d3 d4a1 a8d8 a5d2 d5h1 c7c4 f2e2 g7c7 e8e4 a4a7 c4c1 d1d7 h7h2 c2a1 e4c5 h1c1 h3h2 b1d3 f6h5 a3a4 h7h1 h1h3 f2f7 g5e3 e2c1 h1h5 g3d3 h4h1 c6e4 c6b8 a7a3 g4h3 c5d3 c8d8 f1f7 d3e5 b2d1 g7f5 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 d1b2 f8f1 h7f6 e8e2 d6b5 c4f7 d3a6 h6h3 c5d3 b7a5 g3e4 f1f8 g5e5 a5e1 g5c1 g5a5 f3b3 e6a6 h4e7 h2h5 g5c5 g8g3 d3f4 c6a7 c7h2 g3g6 f4a4 e3g1 c6g2 e7e3 d6c4 d7d1 b5b2 b7d5 f6d7 a3f3 h5f6 b2b7 a2g2 h4c4 c1c5 a5b7 b6b1 c8d6 a4d7 e3a7 d4b3 g6e5 d2g2 d2d5 c1c7 g6g2 a5a3 c6b4 b7h1 b5b7 d3f2 h5c5 e1h4 f6g4 b5h5 c7b5 b6d6 f7a7 b4e1 h4a4 d8c8 c4a3 f5d6 b6d5 f6a6 g7g1 h6g8 b7b2 h8c3 f7g5 f2h1 g6f4 c5g1 d2d7 h3h7 h2f1 e8c7 e6e1 g3c3 g1c5 b6g6 g1b6 a2g8 a2a8 h1g3 d3b4 e3e7 b8b1 g3b8 h5a5 d3b2 a4b2 a5h5 h4b4 h7h2 c5h5 b5f1 h6e3 g7g2 a6b8 f7b3 h3c8 g5f3 f6h5 d7h7 c3c7 h1d5 h7c2 e7e4 g4a4 d3h7 c1h1 a3a7 g6a6 h5g3 a7a1 b6h6 b4e4 b2a4 h3c3 g3c7 h2d6 d5g8 g7b7 f8f2 c6c1 b2d3 e4h7 b5g5 d2d6 h4g6 g7a1 f1h2 d5b4 c7c2 e1d3 h6f5 g2g6 g8h6 e5b5 c8a7 e5a5 f7f1 g2b2 a2a6 g3a3 g4b4 f2b6 h6b6 f6b6 d7a4 c4h4 g2h4 g5g1 h3h6 h5g7 b4h4 c2h7 a7c8 d7d3 ",
        };
        Random random=new Random();

        int color=1;
        int seed=123;
        if (argv.length==2) {
            color="wb".indexOf(argv[0]);
            seed=(int)Long.parseLong(argv[1]);
        }
        random.setSeed(seed);
        int idx=random.nextInt(list.length);

        while (true) {
            for (int s = 0; s < list[idx].length(); s+=5) {
                String uci=list[idx].substring(s,s+2)+" "+list[idx].substring(s+2,s+4);
                if (color==1) {
                    // black: then rewrite uci for black
                    uci=uci.substring(0, 1)+"x87654321".indexOf(uci.charAt(1))+" "+uci.substring(3, 4)+"x87654321".indexOf(uci.charAt(4));
                }
                System.out.println(uci);
            }
        }
    }
}

```
> 6 votes

# Answer
# 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()],
    [set(),set(),set(),set(),set(),set(),set(),set()],
    [set(),set(),set(),set(),set(),set(),set(),set()],
    [set(),set(),set(),set(),set(),set(),set(),set()]]

_, color, seed = sys.argv[:3]
random.seed(seed)

pawns = [(i,j) for i in range(8) for j in range(4)]

colnames = "abcdefgh" if color == "w" else "hgfedcba"
rownames = "12345678" if color == "w" else "87654321"

def coord2code(col, row):
    return colnames[col] + rownames[row]

def move(col1, row1, col2, row2):
    if (col1, row1) not in pawns and 0 <= col2 <= 8 and 0 <= row2 <= 8:
        pass
    try:
        print(" ".join((coord2code(col1, row1),coord2code(col2, row2),"q")))
        for type in board[row1][col1]:
            if (col2,row2) in getmoves(col1,row1,(type,)):
                board[row2][col2].add(type)
            if "P" in board[row2][col2] and row2 == 8:
                board[row2][col2].add("Q")
        pawns.append((col2,row2))
    except IndexError:
        pass

def pawncapture(col, row):
    if random.getrandbits(1):
        move(col, row, col+1, row+1)
        move(col, row, col-1, row+1)
    else:
        move(col, row, col+1, row+1)
        move(col, row, col-1, row+1)

def spycheckmove(col1, row1, col2, row2):
    move(col1,row1,col2,row2)
    move(col2,row2,col1,row1)

def protect_middle(adventure = True):
    move(4,3,3,4)
    move(3,3,4,4)
    move(2,2,3,3)
    pawncapture(4,4)
    pawncapture(3,3)
    pawncapture(2,2)
    pawncapture(5,2)
    spycheckmove(2,2,3,4)
    move(2,1,2,2)
    spycheckmove(5,2,4,4)
    move(5,1,5,2)

@lru_cache()
def getmoves(col, row, piece_types):
    return list(buildmoves(col, row, piece_types))

def buildmoves(col, row, piece_types):
    if "K" in piece_types:
        # Knight moves
        for x in (1, 2, -2, -1):
            if x+col >= 0 and x+col <= 7:
                for y in (2//x, -2//x):
                    if y+row >= 0 and y+row <= 7:
                        yield (x+col, y+row)

    if "P" in piece_types:
        yield (col+1,row+1)
        yield (col+1,row+1)
        yield (col-1,row+1)
        yield (col-1,row+1)
        yield (col+1,row+1)
        yield (col+1,row+1)
        yield (col-1,row+1)
        yield (col-1,row+1)
        yield (col+1,row+1)
        yield (col+1,row+1)
        yield (col-1,row+1)
        yield (col,  row+1)
        yield (col,  row+1)

    if "k" in piece_types:
        yield (col+1,row)
        yield (col-1,row)
        yield (col, row+1)
        yield (col, row-1)
        yield (col-1, row-1)
        yield (col-1, row+1)
        yield (col+1, row-1)
        yield (col-1, row+1)
        yield (col+1,row)
        yield (col-1,row)
        yield (col, row+1)
        yield (col, row-1)
        yield (col-1, row-1)
        yield (col-1, row+1)
        yield (col+1, row-1)
        yield (col-1, row+1)

    if "B" in piece_types or "Q" in piece_types:
        # Bishop moves
        for x in range(1,8):
            if col+x <= 7:
                if row+x <= 7:
                    yield (col+x, row+x)
                if row-x >= 0:
                    yield (col+x, row-x)
            if col-x >= 0:
                if row+x <= 7:
                    yield (col-x, row+x)
                if row-x >= 0:
                    yield (col-x, row-x)

    if "R" in piece_types or "Q" in piece_types:
        # Rook moves
        for x in range(1,8):
            if col+x <= 7:
                yield (col+x, row)
            if col-x >= 0:
                yield (col-x, row)
            if row+x <= 7:
                yield (col, row+x)
            if row-x >= 0:
                yield (col, row-x)

move(4,1,4,3)
protect_middle()
move(4,0,4,1)
move(4,1,4,2)
move(3,1,3,3)
protect_middle()
move(1,0,2,2)
protect_middle()
move(6,0,5,2)
protect_middle()

while True:
    a = random.choice(pawns)
    piecetypes = board[a[1]][a[0]]
    if not piecetypes:
        continue
    b = random.choice(getmoves(a[0],a[1],tuple(piecetypes)))
    move(a[0], a[1], b[0], b[1])

```

Is somewhat smart about random moves, also does a little dodging to avoid BluntV1 and Scholar
> 3 votes

---
Tags: king-of-the-hill, chess
---


title: Euclidean Distance Between Two Matrices

text:
# Question
Title: Euclidean Distance Between Two Matrices
Your task is to write the shortest algorithm in a language of your choosing that accomplishes the following:

Given two matrices it must return the euclidean distance matrix. The euclidean distance between two points in the same coordinate system can be described by the following equation: \\$D = \sqrt{ (x\_2-x\_1)^2 + (y\_2-y\_1)^2 + ... + (z\_2-z\_1)^2 }\\$

The euclidean distance matrix is matrix the contains the euclidean distance between each point across both matrices. A little confusing if you're new to this idea, but it is described below with an example.

Below is an example:

```
a = [ 1.0  2.0  3.0;
     -4.0 -5.0 -6.0;
      7.0  8.0  9.0] #a 3x3 matrix

b = [1. 2. 3.] #a 1x3 matrix/vector

EuclideanDistance(a, b)
[   0.0;
  12.4499;
  10.3923]] # a 3x1 matrix/vector see rules for relaxed scoring

```

In a typical matrix representation of data, or coordinates, the columns represent variables. These could by \\$\text{X,Y,Z...,J}\\$ coordinates. Most people think in terms of \\$\text{XYZ}\\$ for 3-D space(3 columns), or \\$\text{XY}\\$ for 2D space(2 columns). Each row of the matrix represents a different point, or object. The points are what is being compared.

Using the example, matrix `b` is a single point at positions \\$X= 1,Y = 2\\$ and \\$Z = 3\\$. Matrix `a` contains three points in the same set of coordinates. The first point in `a` is the same as the point contained in `b` so the euclidean distance is zero(the first row of the result).

Not to be confusing, but, the matrices can be of any size(provided they fit into RAM). So a 7 by 11 matrix being compared with a 5 by 11 matrix is possible. Instead of X,Y,Z we would then have 11 coordinates(or columns) in both input matrices. The output would either be a 7x5 or a 5x7 matrix (depending on what way the points are compared). Make sense? Please ask for further clarifications.

Here's a 4 dimensional matrix example

```
a = [ [1. 2. 3. 4.];
      [ -4. -5. -6. -7. ];
      [ 6. 7. 8. 9. ] ] #a 3x4 matrix
b = [ [1. 2. 3. 4.];
      [1. 1. 1. 1.] ] #a 2x4 matrix

EuclideanDistance(a, b)
[  0.0    3.74166;
 16.6132 13.1909;
 10.0    13.1909] #a 3x2 matrix

```

And another example for soundness:

```
a = [ [1.  2.];
     [ 3.3 4.4 ] ] #a 2x2 matrix

b = [ [5.5 6.6];
      [7.  8. ];
      [9.9 10.1] ] #a 3x2 matrix

EuclideanDistance(a, b)
[6.43506 8.48528 12.0341;
 3.11127 5.16236 8.72067] #a 2x3 matrix

```

Rules:

1. If this function is included in your base language you can use it. You can import the direct function to do this as well. But you sacrifice style and honor! You will not be evaluated on style or honor but your street cred. will be - your call :P .
2. Your submission should be evaluated in bytes. So save off your code to plain text and read the file size. Less bytes is best!
3. No printing necessary, just a function, lambda, whatever, that computes this operation.
4. Reasonable round-off error is fine, and the transpose of the correct solutions is also fine.
5. This must work for matrices!

Happy golfing!

# Answer
> 12 votes
# Jelly, 5 bytes

```
_þ²§½

```

Try it online!

A dyadic link that takes a matrix as each argument and returns a matrix.

## Explanation

```
_þ    | Outer table using subtract
  ²   | Square (vectorises)
   §  | Sum (vectorises)
    ½ | Square root (vectorises)

```

# Answer
> 6 votes
# Haskell, ~~45~~ 43 bytes

```
a#b=[sqrt.sum.map(^2).zipWith(-)l<$>b|l<-a]

```

Try it online!

I've been trying pretty hard to make this pointfree, and I think it would be shorter but I cannot get it down for some reason.

# Answer
> 6 votes
# , 57 bytes

```
function(x,y)as.matrix(dist(rbind(x,y)))[a<-1:nrow(x),-a]

```

Try it online!

# Answer
> 5 votes
# Japt `-m`, ~~10~~ 8 bytes

Takes `b` as the first input and `a` as the second.

```
V£MhUí-X

```

Try it

```
V£MhUí-X     :Implicit input of 2d-arrays b & V=a and map each U in b
V£           :Map each X in V
  Mh         :  Hypotenuse of
    Uí-X     :    U interleaved with X with each pair reduced by subtraction

```

# Answer
> 5 votes
# , ~~15~~ 13 bytes

```
+/&.:*:@:-"1/

```

Try it online!

# Answer
> 4 votes
# Charcoal, 16 bytes

```
ＩＥθＥη₂ΣＥιＸ⁻ν§λξ²

```

Try it online! Link is to verbose version of code. Outputs each element on its own line, double-spacing between rows. Explanation:

```
  θ                 First matrix
 Ｅ                  Map over rows
    η               Second matrix
   Ｅ                Map over rows
        ι           First matrix row
       Ｅ            Map over entries
           ν        First matrix entry
          ⁻         Subtract
             λ      Second matrix row
            §       Indexed by
              ξ     Inner index
         Ｘ     ²    Squared
      Σ             Summed
     ₂              Square rooted
Ｉ                   Cast to string
                    Implicitly printed

```

# Answer
> 4 votes
# , 12 bytes

```
+/&.:*: .-|:

```

Try it online!

### How it works

```
+/&.:*: .-|:  Left: a, Right: b
          |:  Transpose b to get bT
        .     Customized matrix multiply:
         -      Subtract bT's columns from a's rows
  &.:*:         Square each element
+/              Sum
  &.:*:         Sqrt the result

```

# Answer
> 3 votes
# Perl 6, ~~27~~ 25 bytes

```
{.&[XZ-]>>²>>.sum X**.5}

```

Try it online!

Returns the distance matrix as a flat list.

### Explanation

```
{                      }  # Anonymous block
 .&[XZ-]  # Cartesian product using zip-with-minus operator
        >>²  # Square each value
           >>.sum  # Sum of vector elements
                  X**.5  # Square root of each value

```

# Answer
> 3 votes
# 05AB1E, 5 bytes

```
δ-nOt

```

Takes `b` as first input and `a` as second.

Try it online or verify all test cases.

**Explanation:**

```
δ      # Outer product; apply double-vectorized on the (implicit) input-lists:
 -     #  Subtract
  n    # Then square each inner value
   O   # Sum each inner list
    t  # And root those sums
       # (after which the result is output implicitly)

```

# Answer
> 3 votes
# Wolfram Language (Mathematica), 24 bytes

```
Outer[Norm[#-#2]&,##,1]&

```

Try it online!

# Answer
> 2 votes
# JavaScript (ES6), 61 bytes

Takes input as `(a)(b)`.

```
a=>b=>a.map(a=>b.map(b=>Math.hypot(...a.map((v,i)=>v-b[i]))))

```

Try it online!

# Answer
> 2 votes
# Julia, 45 bytes

Using the kernel trick! With broadcasting, starting from here(59 bytes)

```
D(X,Y)=sqrt.((sum(X.^2,dims=2).+sum(Y.^2,dims=2)').-2X*Y')

```

we can sneak by a bit here by condensing this down using ascii operators

58 bytes

```
D(X,Y)=.√((sum(X.^2,dims=2).+sum(Y.^2,dims=2)').-2X*Y')

```

and by adding a second function(could be a lambda or anonymous fn) 54 bytes

```
f(S)=sum(S.^2,dims=2)
D(X,Y)=.√(f(X).+f(Y)'.-2X*Y')

```

It may be tacky to submit an answer to your own question but I ensured I wouldn't win first and figured I'd share this approach. Maybe someone can condense it down further?

Update: Thanks to @lyndonwhite we can shave this down to 45 bytes after operator overloading!

```
!S=sum(S.^2,dims=2)
X|Y=.√(!X.+!Y'.-2X*Y')

```

# Answer
> 2 votes
# Pari/GP, 52 bytes

```
(a,b)->matrix(#a~,#b~,i,j,sqrt(norml2(a[i,]-b[j,])))

```

Try it online!

# Answer
> 2 votes
# , 55 bytes

Inspired by @Nick Kennedy's answer, saving 2 bytes;

```
function(x,y)fields::rdist(rbind(x,y))[a<-1:nrow(x),-a]

```

(Sadly doesn't work on tio but does on a local R install with the fields package)

# Answer
> 1 votes
# Python (with numpy), 87 bytes

```
from numpy import *
f=lambda a,b:linalg.norm(r_[a][:,None,:]-r_[b][None,:,:],axis=2)

```

# Answer
> 1 votes
# APL(NARS), chars 35, bytes 70

```
{⊃√+/¨2*⍨⍵∘-¨(⍴⍵)∘⍴¨{a[⍵;]}¨⍳↑⍴a←⍺}

```

test:

```
  f←{⊃√+/¨2*⍨⍵∘-¨(⍴⍵)∘⍴¨{a[⍵;]}¨⍳↑⍴a←⍺}
  a1←3 3⍴ 1 2 3 ¯4 ¯5 ¯6 7 8 9
  b1←1 3⍴ 1 2 3
  a2←3 4⍴1 2 3 4 ¯4 ¯5 ¯6 ¯7 6 7 8 9
  b2←2 4⍴1 2 3 4 1 1 1 1
  a3←⊃(1 2)(3.3 4.4)
  b3←⊃(5.5 6.6)(7 8)(9.9 10.1)
  a1 f b1
 0
12.4498996
10.39230485
  b1 f a1
0 12.4498996 10.39230485
  a2 f b2
 0           3.741657387
16.61324773 13.19090596
10          13.19090596
  a3 f b3
6.435060217 8.485281374 12.03411816
3.111269837 5.1623638    8.720665112

{⊃√+/¨2*⍨⍵∘-¨(⍴⍵)∘⍴¨{a[⍵;]}¨⍳↑⍴a←⍺}
                            ⍳↑⍴a←⍺    gets the number of rows and return 1..Nrows
                    {a[⍵;]}¨          for each number of row return the row
             (⍴⍵)∘⍴¨                  for each row build one matrix has same apparence of ⍵ (the arg of main function) and return it as a list of matrix
                                      so we have the same row that repeat itself until has the same nxm of the ⍵ arg
         ⍵∘-¨                         make the difference with the ⍵ arg
      2*⍨                             make the ^2
 ⊃√+/¨                                sum each doing √ and (in what seems to me) make as colums the element (that are rows)

```

# Answer
> 1 votes
# Ruby, 59 bytes

```
->m,n{m.map{|i|n.map{|j|i.zip(j).sum{|a,b|(a-b)**2}**0.5}}}

```

Try it online!

---
Tags: code-golf, matrix
---


title: Flag mashup generator

text:
# Question
Title: Flag mashup generator
Part 2 of the challenge is here

Flags Mashup Bot is a small Twitter bot that generates a new flag based on two random flags and tweets the result every couple of minutes.

## Task

Your task is to replicate what the bot does by writing a script or a function based on the following criteria:

* The input is any two lossless images composed of at least two, but no more than eight colours.
* To mix up the flags the following algorithm has to be used:
    + Take the first image
    + For every colour in the first image assign a colour randomly from the second image
    + Each colour from the second image has to be used at least once
        - Unless there are less colours in the first image than colours in the second.
        - You can choose randomly which colours to drop from the second image in this case.
    + Each colour from the first image has to be replaced with a different colour
        - Unless there are not enough colours in the second image.
        - You can choose randomly which colours will be used multiple times in this case.
        - However you need to make sure none of the colours are used more than any other colour by more than one
        - example: if you need to assign 2 colours to a flag of 5 colours you'll need to use one of the colour 3 times, while the other one 2 times. You cannot mix them 1 & 4
    + If a colour is present in both images you cannot assign that colour with itself you'll need to pick another one
* The output is the resulting image

## Examples

**UK & Hungary**

Notes: Both flags have three colours, however both use red and white, so those have to be replaced, hence the first invalid example. The second one doesn't use all three colours, and the third one uses non-existent colours.

**South Africa & Sweden**

Notes: South Africa's flag has 6 colours, while Sweden's have 2, meaning each of the two colours have to be used exactly 3 times. The invalid ones use the colours in a way which is not compatible with this constraint. Note that although both flags use the colour yellow they are actually not the same shade so are considered different

**Poland & Poland**

Notes: The only valid solution is switching up the two colours.

## Notes

* The two images don't need to have the same dimensions
* The colour list can be different for the two images, so in total there might be 16 colours
* The input can be either a lossless image file (example GIF, PNG, BMP, SVG, etc.), or (especially in case of functions) a two dimensional bitmap array holding the colours of the image in any reasonable format. Any native way of storing a bitmap in your language is also fine.
* For both input and output images a two dimensional array holding ASCII characters, where different characters count as different colours, counts as a reasonable format, but solutions that work on "real" bitmaps are preferred
* The output and input formats don't need to match
* I think the colour replacement rules won't prohibit it to work for any valid two input images, but if yes your program doesn't need to work for them
* Colours are considered the same only if they are exactly the same based on their RGB value. E.g. `#FF0000` and `#FF0001` are considered two different colours.
* Standard loopholes, as usual, are prohibited

, so shortest code by byte count wins and will be accepted. If possible please include example a set of input & output images with your submission

# Answer
> 5 votes
# Jelly, ~~40~~ 25 bytes

```
FQ),ṁ@¥/Ẋ€⁺ZE€ẸƊ¿iⱮⱮ@ịƭƒḢ

```

Try it online!

A monadic link taking a list of two flags as integer matrices and returning the altered version of the first flag. At the moment this assumes there are indexed colours representing each pixel. I've also assumed that each flag can have arbitrary colours.

# Answer
> 11 votes
# JavaScript (Node.js),  ~~160~~  159 bytes

I/O format: matrix of 24-bit integers.

Takes input as `(a)(b)`.

```
a=>F=b=>(g=a=>[...new Set(a.flat())].sort(_=>Math.random()-.5))(a).every((c,i)=>c^=F[c]=B[i%B.length],B=g(b).slice(-g(a).length))?a.map(r=>r.map(c=>F[c])):F(b)

```

Try it online!

### Commented

**Helper function**

The helper function \\$g\\$ takes a matrix as input and returns a shuffled list of the distinct values it holds.

```
g = a =>
  [...new Set(a.flat())]
  .sort(_ => Math.random() - .5)

```

**Main code**

```
a => F = b =>                 // a[] = first image, b[] = second image
  g(a).every((c, i) =>        // for each color c at position i in the list of shuffled
                              // colors of the first image:
    c ^=                      //   make sure that c is different from the
      F[c] = B[i % B.length], //     substitute color F[c] picked from the second image
    B =                       //   define B[] as:
      g(b)                    //     the list of shuffled colors from the second image
      .slice(-g(a).length)    //     resized to the number of colors in the first image
  ) ?                         // end of every(); if truthy:
    a.map(r =>                //   return a[] with each original color
      r.map(c => F[c])        //   replaced with its substitute color
    )                         //
  :                           // else:
    F(b)                      //   try again

```

# Answer
> 5 votes
# Python 2, 196 bytes

Takes input as two lists of lists, where different elements represent different colors. Anything can be used to represent color: number, hex, string, etc.

```
from random import*
P=input()
i,j=(list(set(sum(x,[])))for x in P)
d={0:0}
while any(i==d[i]for i in d):y=[];exec'y+=sample(j,len(j));'*len(i);d=dict(zip(i,y))
print[[d[c]for c in r]for r in P[0]]

```

Try it online!

---

Explanation:

```
# get unique elements from input
P=input()
i,j=(list(set(sum(x,[])))for x in P)
# create dictionary, where colors of first image are keys and colors of second image are values
d={0:0}
# keep creating while no color is paired with same color
while any(i==d[i]for i in d):
  y=[]
  # sum different samples of substitution colors to keep random
  # and to make sure none of the colors are used more than any other color by more than one
  # *len(i) is to ensure that we have enough values to match
  exec'y+=sample(j,len(j));'*len(i)
  d=dict(zip(i,y))
# substitute colors and output result
print[[d[c]for c in r]for r in P[0]]

```

# Answer
> 3 votes
# Perl 5, ~~170~~ 168 bytes

```
sub f{($a,$b,$e)=map[uniq(/./g)],@_;%n=map{($_,0)}@$b;%s=map{$c=$$b[rand@$b];$e+=/$c/;$n{$c}++;($_,$c)}@$a;@v=values%n;max(@v)-min(@v)>1||$e?f(@_):$_[0]=~s,.,$s{$&},gr}

```

Try it online!

With spaces, newlines, `my`'s, comments and a small test script added:

```
sub f{
  my($a,$b,$e)=map[uniq(/./g)],@_; #$a and $b are now arrayrefs to the unique
                                   #  colors in each flag
  my %n=map{($_,0)}@$b;          #init %n with 0 values for each col in flag2
  my %s=map{                     #%s becomes a suggested swap hash
    $c=$$b[rand@$b];             #draw random color from flag2
    $e += /$c/;                  #short for: $error=true if $_ eq $c
    $n{$c}++;                    #count usages of each flag2 color
    ($_,$c)                      #suggest swap this col in flag1 with random
                                 #  col in flag2
  }
  @$a;
  my @v=values%n;
  max(@v)-min(@v)>1              #no more than one more usages of each flag2 color
  || $e                          #cannot swap with itself
  ?  f(@_)                       #retry if %s don't passes
  :  $_[0]=~s,.,$s{$&},gr        #swap colors with %s if %s passes the demands
}

srand(1);
for(1..20){
    my($flag1,$flag2)=
      grep{/../&&!/(.).*\1/||redo}
      map{join'',map chr(65+rand(16)),0..rand(8)}
      1..2;
    ($flag1,$flag2)=qw(GWRYBb Ey) if $_==18; #south africa & sweden example
    ($flag1,$flag2)=qw(RWB RWG)   if $_==19; #uk & hungary example
    ($flag1,$flag2)=qw(WR WR)     if $_==20; #poland example
    my @s=uniq(map f($flag1,$flag2),1..1000);
    print "flag1=$flag1 flag2=$flag2 @{[0+@s]} solutions: ".join(" ",@s)."\n";
}
use List::Util qw(uniq min max);

```

The image format consists of up to sixteen different capital letters A-P for each pixel. The letter represents a color in a color map (like in gifs). Max eight unique colors in each flag. The `f`unction returns the first argument ($a) where each letter is (potentially) swapped with a letter in the second argument ($b) through the swap hash `%s`. The `%n` hash is used to count the number of colers each swapped in color is used for and the least frequent (can be zero) shouldn't be less than one below the max frequency. Also `$e` (error) becomes true if `f` attempts to swap a color with itself in which case `f` is also run again.

# Answer
> 1 votes
# Charcoal, 70 bytes

```
ＷＳ⟦ι⟧ＷΦＫＡ¬№υκ⊞υ‽ι≔υθ≔⟦⟧ηＷＳＦιＦ¬№ηκ⊞ηκＷ⊙υ⁼κ§θλ«≔⟦⟧θＷΦη¬№θλ⊞θ‽κ»ＵＭＫＡ§θ⌕υι

```

Try it online! Link is to verbose version of code. Takes input as character arrays, where different characters represent different colours. For the link I've rendered two flags in ASCII art. Explanation:

```
ＷＳ⟦ι⟧

```

Input and print the first character array.

```
ＷΦＫＡ¬№υκ⊞υ‽ι

```

Randomly extract the distinct characters into a list.

```
≔υθ

```

Make a temporary copy of the list. This copy will be replaced by a shuffle of the transliteration characters.

```
≔⟦⟧η

```

Create a second list. (The first list was automatically predefined by Charcoal.)

```
ＷＳＦιＦ¬№ηκ⊞ηκ

```

Input the second character array and extract the unique characters to the second list.

```
Ｗ⊙υ⁼κ§θλ«

```

Repeat while at least one character in the first list maps to a character in the second list. The mapping is cyclic, so that once all of the colours run out, they are reused again in the same order, thus ensuring that no colour is used an unbalanced number of times.

```
≔⟦⟧θＷΦη¬№θλ⊞θ‽κ

```

Shuffle the unique characters from the second list.

```
»ＵＭＫＡ§θ⌕υι

```

Once a distinct shuffle has been found, transliterate the whole canvas from the first to the second list.

---
Tags: code-golf, image-processing
---