

#CHINESE CHECKERS GAME TEMPLATE PLUS#
Duplicate the bottom B.Y line with a plus space and dot, minus a B and Y until there are no B and Y left.Duplicate the topmost G line with a plus space, minus a G until there is only one G.Create the last G line and the first B.Y line (delimited by markers ijk and actual used letetrs are RPO).The main steps in the generation are the followings:
#CHINESE CHECKERS GAME TEMPLATE CODE#
This is impractical but you can run the code as is as one file with the -s flag, keeping the # markers and maybe changing them to newlines in the output for readability if you wish. Use Template Let's have some fun Challenge your friends and colleagues to a game of Chinese Checkers. Įach line should go to its own file and # should be changed to newline in the file. Chinese checkers template Challenge your friends to a game of Chinese Checkers. The bounding rectangle requires that we do this for x in the closed interval and y in the closed interval. If two or more are, we're outside the board, and print a space.If exactly one is, we're in one of the six outer triangles, and print the letter corresponding to the index.If none are, we're in the center and print a dot.So, we can determine what region we're in by which of are greater than n. 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. Noting that x and y must have the same parity, or otherwise it's off-checkerboard and we should print a space. We can convert Cartesian coordinates to triangular ones as a = (x+y)/2 (Here, the lattice points are drawn as hexagons.) The idea is to use triangular coordinates, in which the triangular lattice corresponds to integer triples (a,b,c) with a+b+c=0. Rather than explaining this mess of code, I'll try to say the idea behind it. This is, in retrospect, the wrong approach for Python, but I'm posting it here in case someone can make use of it. This is code-golf: the shortest code in bytes wins. No other extra (leading, trailing) whitespace is permitted.

Output may optionally have a trailing newline. have exactly enough trailing spaces to fill out the pattern to a perfect rectangle of width 6 * N + 1.Output the checkerboard pattern to STDOUT (you may alternately return it as a string if your submission is a function). Your code should take a positive integer representing the size of the board, via STDIN, ARGV, or function argument.

Since it's really a pain to type all that by hand, let's write a program (or function) to do it! Details We'll measure the size of a board by the side length of its triangular starting locations: the board above is size 4. To make it more interesting, we can also change the size. for empty spots and the letters GYORPB for the six colored starting locations: G We can create an ASCII-art representation of this board, using. The game of Chinese checkers is played on a board with spaces in the shape of a six-pointed star:
