# Tag Info

56

Python 2, 41 38 bytes print'ldiagrhkt'[int(input(),35)%2::2] 3 bytes thanks to Mego for string interlacing Takes input like "g6". That's light and dark intertwined.

46

GS2, 17 15 bytes de♦dark•light♠5 The source code uses the CP437 encoding. Try it online! Verification $xxd -r -ps <<< 6465046461726b076c696768740635 > chess.gs2$ wc -c chess.gs2 15 chess.gs2 $gs2 chess.gs2 <<< b1 light How it works d Add the code points of the input characters. e Compute the sum's ... 33 Whitespace, 45 bytes Try it online! By the way, here is a proof that the ⌈n²/2⌉ formula is correct. We can always place at least ⌈n²/2⌉ wazirs: just lay them out in a checkerboard pattern! Assuming the top-left tile is white, there are ⌈n²/2⌉ white ... 27 Min: 12 bitsMax: Avg: Had and thought last night that I could possibly make it even smaller. x Colour to play next (0 -> Black, 1-> White) 1 Only King left? 00000 Position of White King (0 -> A1 ... 63 -> H8) 00000 Position of Black King 01 00000 11111 WK:A1, BK:H2 (Black to play) 11 00000 11111 WK:A1, BK:H2 (White to play) The result ... 26 Hexagony, 34 32 bytes ,},";h;g;;d/;k;-'2{=%<i;\@;trl;a Unfolded and with annotated execution paths: Diagram generated with Timwi's amazing HexagonyColorer. The purple path is the initial path which reads two characters, computes their difference and takes it modulo 2. The < then acts as a branch, where the dark grey path (result 1) prints dark and ... 25 Python 2, 35 bytes lambda x,y:50/(8+x*x/7-x+y*y/7-y)-4 Try it online! Python 2, 39 bytes lambda x,y:50/(8-x*(7-x)/5-y*(7-y)/5)-4 Try it online! Takes inputs 0-indexed. The expression x*(7-x)/5 takes the coordinate values 0..7 to [0, 1, 2, 2, 2, 2, 1, 0] (min(x,7-x,2) does the same, but is longer.) Summing this for x and y gives the right pattern but ... 25 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 C, 650 600 n=8,t=65,s,f,x,y,p,e,u=10,w=32,z=95;char a,b="RNBKQBNR";v(){p=a[s]&z;y=f/u-s/u;x=f-s-y*u;e=x*x+y*y;n=s%u/8|f%u/8|a[s]/w-t/w|a[f]/w==t/w|!(p==75&e<3|p>80&x*y==0|p%5==1&x*x==y*y|p==78&e==5|p==80&x*(z-t)>0&(a[f]-w?e==2:e==1|e==4&s%5==1));if(!n&&p-78)for(e=(f-s)/abs(x*x>y*y?x:y),x=s;(x+=e)-f;... 21 CJam, 18 bytes r:-)"lightdark"5/= Online demo Dissection r e# Read a token of input :- e# Fold -, giving the difference between the two codepoints ) e# Increment, changing the parity so that a1 is odd "lightdark"5/ e# Split the string to get an array ["light" "dark"] = e# Index with wrapping, so ... 21 JavaScript (Node.js), 191 ... 166 164 bytes Saved 2 bytes thanks to @grimy. Returns the $N$th term. n=>(g=(x,y)=>n--?g(Buffer('QPNP1O?O@242Q3C3').map(m=c=>g[i=4*((x+=c%6-2)*x>(y+=c%7-2)*y?x:y)**2,i-=(x>y||-1)*(i**.5+x+y)]|i>m||(H=x,V=y,m=i))&&H,V,g[m]=1):m+1)(1,2) Try it online! or See a formatted version How? ... 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 = [... 19 JavaScript (Node.js), 144 138 125 74 73 70 bytes f=(x,n=2,c=0)=>x%n?x-!c?f(x,n+1)/(n%4>2?n/=~c&1:n%4)**c:1:f(x/n,n,c+1) Try it online! -4 byte thanks @Arnauld! Original approach, 125 bytes a=>(F=(x,n=2)=>n*n>x?[x,0]:x%n?F(x,n+1):[n,...F(x/n,n)])(a).map(y=>r-y?(z*=[,1,.5,p%2?0:1/r][r%4]**p,r=y,p=1):p++,z=r=p=1)&&z Try it ... 18 Python 2, 53 40 lambda x,y,p,q:y-2<q>=abs(x-p)+q/7+y/8*5 The king has coordinates (x, y) and the pawn (p, q). There are three significant cases: The pawn is on rank 7 and the king on rank 8. To capture the pawn, the king must be on the same file or an adjacent one. Result: q = 7 ⋀ y = 8 → |x - p| ≤ 1 The pawn is on rank 7. To capture the pawn,... 18 Python 2, 52 bytes f=lambda n:n<6orn%100in'18349276167294381'*f(n/10) Checks that any two consecutive digits are in the string '18349276167294381'. To get consecutive digits, rather than doing zip(n,n[1:]), the function repeatedly checks the last two digits and removes the last digit. 17 192 bits (worst case) Here's a very simple storage scheme that should cope with arbitrary pawn promotions, and never requires more than 64 + 4 × 32 = 192 bits: The first 64 bits store a bitboard that tells where the pieces are (but not what they are). That is, we store one bit for each square of the chessboard (starting at square a1, then b1, c1, ... 17 sed, 37 s/[1357aceg]//g /^.$/{clight q} cdark Explanation s/[1357aceg]//g removes all odd-indexed coordinates. The resulting pattern buffer then has length of 1 for "light" or length of 0 or 2 for "dark". /^.$/ matches the 1-length patterns, changes the pattern to "light" and quits. Otherwise the pattern is changed to "dark". 17 MATL, 17 14 13 12 bytes Thanks to @Neil for 1 byte off! 8:HZ^ZP5X^=s Input is 1-based. Try it online! Explanation This computes the Euclidean distance from the input to each of the 64 positions in the chessboard, and finds how many of those values equal the square root of 5. Since the coordinates are integer values, we can be sure that the two ... 16 I'm not complaining about upvotes, but to be fair... my solution here isn't actually all that great. Ugoren's is better, apart from lacking unicode support. Be sure to look at all the answers before voting, if you've come across this question only now!Anyway. Haskell, 893 888 904 952 (without castling) 862 (without pawn double-moves) (You didn't specify ... 16 Jelly, 19 15 14 bytes Doȷ’d3ạ2\P€=2P Try it online! or verify all test cases. How it works Doȷ’d3ạ2\P€=2P Main link. Argument: n (integer) D Convert n to base 10 (digit array). ȷ Yield 1000. o Logical OR. This replaces each 0 with 1000. ’ Decrement each digit. d3 Divmod; replace each ... 16 Oasis, 3 bytes k>v Try it online! square - increment - integer halve 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) { case 'w': color = WHITE; break; case 'b': color = BLACK; break; default: assert(0); } if(color == WHITE) { ... 15 Pyth, 22 21 bytes -1 byte by @Sp3000 fn%Chz3%sCMT2sM*<G8S8 Under the function %Chz3, dark hashes to 1, light to 0, and both to 2. If we take the parity of the sum of the ords of a chess square (that is, a1 -> [97, 33] -> (97 + 33)%2 = 0, dark squares go to 0, and light to 1. This allows us to filter by inequality. fn%Chz3%sCMT2sM*<G8S8 ... 15 Retina, 13 bytes \d$* / ¶ | Try it online! Explanation The first part (note the trailing space): \d $* is to convert a to the specific number of spaces. Retina has a$* feature to repeat. The way it works is: <num>$*<char> if there is no <num>, Retina will assume$& or the matched string, in this case the matched number. The ...

15

Mathematica 63 43 bytes With 20 bytes saved thanks to suggestions by Martin Ender! EdgeCount[8~KnightTourGraph~8,#+1+8#2/<->_]& The above finds the number of squares that are 1 hop away from the given cell on the complete knights tour graph. g=KnightTourGraph[8,8,VertexLabels->"Name",Axes->True] displays the complete knight's tour graph,...

14

160 bits worst case After posting my previous answer 22 bytes, I began to wonder if we could get down to 21 bytes. However when I saw Peter Taylor's amazing 166 bytes I thought "Hang on, it looks like five 32-bit words could be possible!" So after quite a lot of thought, I came up with this: 159.91936391 bytes (a pretty tight fit!) This level of ...

14

Pyth, 18 bytes @c2"lightdark"iz35 Interpret the input as a base 35 number, chop lightdark in half, print.

14

Python 2, 105 bytes lambda b:sum(b[i+d::d][:(8,7-i%8,i%8)[d%8%5]].find('1')*int(c)>0for i,c in enumerate(b)for d in[1,7,8,9]) Try it online! Explanation We take the input as a string of 64 characters '0' or '1'. Using step slices, we cast four "lines of sight" from every queen we encounter. For example, when i = 10 and d = 7, marking the ...

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 ...

13

177 bits worst case This algoritm, while hardly simple, gives a 177 bits worst case (184b=23B in practice), 13b (16b=2B) best case scenario when there's just 2 kings left. Bit Description 1 Turn (0=white 1=black) 2- 7 White king position (2-4=letter, 5-7=number) 8- 13 Black king position (8-10=letter, 11-13=number) 14- 75 Which squares ...

13

Python 3, 1166 1071 993 bytes I only realized I needed to stop kings from moving into check after I had otherwise finished, but here's my submission anyways h=abs m=range l=print o=" " a=o*8 j=[list(s)for s in["RNBKQBNR","P"*8,a,a,a,a,"p"*8,"rnbkqbnr"]] u=False v=lambda c:(c.lower()==c)==u while 1: l("b"if u else"w") for b in j:l(*b) q,r,s,t=[int(i)for ...

Only top voted, non community-wiki answers of a minimum length are eligible