Chinese checkerboard
Python 2, 152



n=input();x=N=2*n
while~N&lt;x:s='';y=n*3;exec"a=x+y;q=[0,a&gt;N,x-y&gt;N,-x&gt;n,-a&gt;N,y-x&gt;N,x&gt;n,1];s+=' BYROPG.'[q.index(sum(q)&lt;~a%2*3)];y-=1;"*(y-~y);print s;x-=1


This is, in retrospect, the wrong approach for Python, but I'm posting it here in case someone can make use of it. Rather than explaining this mess of code, I'll try to say the idea behind it.

The idea is to use triangular coordinates, in which the triangular lattice corresponds to integer triples (a,b,c) with a+b+c=0.



(Here, the lattice points are drawn as hexagons.)

We can convert Cartesian coordinates to triangular ones as

a = (x+y)/2
b = (x-y)/2
c = -x


noting that x and y must have the same parity, or otherwise it's off-checkerboard and we should print a space.

In triangular coordinates, the bounding lines of the six-sided star have equations: a==n, b==n, c==n, a==-n, b==-n, c==-n.

So, we can determine what region we're in by which of [a,b,c,-a,-b,-c] are greater than n.


If none are, we're in the center and print a dot.
If exactly one is, we're in one of the six outer triangles, and print the letter corresponding to the index.
If two or more are, we're outside the board, and print a space.


The bounding rectangle requires that we do this for x in the closed interval [-2*n,2*n] and y in the closed interval [-3*n,3*n].