text:
Random Golf of the Day #6: Roll a d20
About the Series
First off, you may treat this like any other code golf challenge, and answer it without worrying about the series at all. However, there is a leaderboard across all challenges. You can find the leaderboard along with some more information about the series in the first post.
Although I have a bunch of ideas lined up for the series, the future challenges are not set in stone yet. If you have any suggestions, please let me know on the relevant sandbox post.
Hole 6: Roll a d20
A very common die in table-top RPGs is the twenty-sided die (an icosahedron, commonly known as d20). It is your task to roll such a die. However, if you were just returning a random number between 1 and 20, that would be a bit trivial. So your task is to generate a random net for a given die.
We'll use the following net:

It's a triangle strip, so it can be easily represented as a list of integers. E.g. if you are given the input:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]

That would correspond to the following die (fun fact: this is the net used by Magic: the Gathering life counters/spin-down dice).

However, this is not the only net representing this die. Depending on how we unroll the faces, there are 60 different nets. Here are two more:
[1, 8, 9, 10, 2, 3, 4, 5, 6, 7, 17, 18, 19, 11, 12, 13, 14, 15, 16, 20]
[10, 9, 18, 19, 11, 12, 3, 2, 1, 8, 7, 17, 16, 20, 13, 14, 4, 5, 6, 15]

Or graphically (I didn't rotate the face labels for simplicity):

The Challenge
Given an a list of integers representing a die (as described above) and an integer N, output N independently, uniformly random d20 nets corresponding to the given die. (That is, each of the 60 possible nets should have the same probability of being generated.)
Of course, due to the technical limitations of PRNGs, perfect uniformity will be impossible. For the purpose of assessing uniformity of your submission, the following operations will be regarded as yielding perfectly uniform distributions:

Obtaining a number from a PRNG (over any range), which is documented to be (approximately) uniform.
Mapping a uniform distribution over a larger set of numbers onto a smaller set via modulo or multiplication (or some other operation which distributes values evenly). The larger set has to contain at least 1024 times as many possible values as the smaller set.

Given these assumptions your algorithm must yield a perfectly uniform distribution.
Your program should be able to generate 100 nets in less than a second (so don't try generating random nets until one corresponds to the die given above).
You may write a program or function, taking input via STDIN (or closest alternative), command-line argument or function argument and outputting the result via STDOUT (or closest alternative), function return value or function (out) parameter.
Input and output may be in any convenient, unambiguous, flat list format. You may assume that the face values of the d20 are distinct, positive integers, which fit into your language's natural integer type.
This is code golf, so the shortest submission (in bytes) wins. And of course, the shortest submission per user will also enter into the overall leaderboard of the series.
Sample Outputs
For the input
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]

The 60 possible nets (provided I didn't make a mistake), in no particular order, are:
[11, 10, 9, 18, 19, 20, 13, 12, 3, 2, 1, 8, 7, 17, 16, 15, 14, 4, 5, 6]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
[8, 7, 17, 18, 9, 10, 2, 1, 5, 6, 15, 16, 20, 19, 11, 12, 3, 4, 14, 13]
[3, 12, 13, 14, 4, 5, 1, 2, 10, 11, 19, 20, 16, 15, 6, 7, 8, 9, 18, 17]
[3, 4, 5, 1, 2, 10, 11, 12, 13, 14, 15, 6, 7, 8, 9, 18, 19, 20, 16, 17]
[11, 19, 20, 13, 12, 3, 2, 10, 9, 18, 17, 16, 15, 14, 4, 5, 1, 8, 7, 6]
[4, 14, 15, 6, 5, 1, 2, 3, 12, 13, 20, 16, 17, 7, 8, 9, 10, 11, 19, 18]
[2, 10, 11, 12, 3, 4, 5, 1, 8, 9, 18, 19, 20, 13, 14, 15, 6, 7, 17, 16]
[4, 5, 1, 2, 3, 12, 13, 14, 15, 6, 7, 8, 9, 10, 11, 19, 20, 16, 17, 18]
[10, 2, 1, 8, 9, 18, 19, 11, 12, 3, 4, 5, 6, 7, 17, 16, 20, 13, 14, 15]
[3, 2, 10, 11, 12, 13, 14, 4, 5, 1, 8, 9, 18, 19, 20, 16, 15, 6, 7, 17]
[7, 8, 1, 5, 6, 15, 16, 17, 18, 9, 10, 2, 3, 4, 14, 13, 20, 19, 11, 12]
[13, 12, 11, 19, 20, 16, 15, 14, 4, 3, 2, 10, 9, 18, 17, 7, 6, 5, 1, 8]
[16, 15, 14, 13, 20, 19, 18, 17, 7, 6, 5, 4, 3, 12, 11, 10, 9, 8, 1, 2]
[15, 16, 17, 7, 6, 5, 4, 14, 13, 20, 19, 18, 9, 8, 1, 2, 3, 12, 11, 10]
[20, 13, 12, 11, 19, 18, 17, 16, 15, 14, 4, 3, 2, 10, 9, 8, 7, 6, 5, 1]
[5, 4, 14, 15, 6, 7, 8, 1, 2, 3, 12, 13, 20, 16, 17, 18, 9, 10, 11, 19]
[10, 11, 12, 3, 2, 1, 8, 9, 18, 19, 20, 13, 14, 4, 5, 6, 7, 17, 16, 15]
[4, 3, 12, 13, 14, 15, 6, 5, 1, 2, 10, 11, 19, 20, 16, 17, 7, 8, 9, 18]
[19, 20, 13, 12, 11, 10, 9, 18, 17, 16, 15, 14, 4, 3, 2, 1, 8, 7, 6, 5]
[1, 8, 9, 10, 2, 3, 4, 5, 6, 7, 17, 18, 19, 11, 12, 13, 14, 15, 16, 20]
[8, 1, 5, 6, 7, 17, 18, 9, 10, 2, 3, 4, 14, 15, 16, 20, 19, 11, 12, 13]
[18, 9, 8, 7, 17, 16, 20, 19, 11, 10, 2, 1, 5, 6, 15, 14, 13, 12, 3, 4]
[12, 3, 2, 10, 11, 19, 20, 13, 14, 4, 5, 1, 8, 9, 18, 17, 16, 15, 6, 7]
[2, 3, 4, 5, 1, 8, 9, 10, 11, 12, 13, 14, 15, 6, 7, 17, 18, 19, 20, 16]
[10, 9, 18, 19, 11, 12, 3, 2, 1, 8, 7, 17, 16, 20, 13, 14, 4, 5, 6, 15]
[9, 8, 7, 17, 18, 19, 11, 10, 2, 1, 5, 6, 15, 16, 20, 13, 12, 3, 4, 14]
[16, 17, 7, 6, 15, 14, 13, 20, 19, 18, 9, 8, 1, 5, 4, 3, 12, 11, 10, 2]
[17, 7, 6, 15, 16, 20, 19, 18, 9, 8, 1, 5, 4, 14, 13, 12, 11, 10, 2, 3]
[1, 5, 6, 7, 8, 9, 10, 2, 3, 4, 14, 15, 16, 17, 18, 19, 11, 12, 13, 20]
[9, 18, 19, 11, 10, 2, 1, 8, 7, 17, 16, 20, 13, 12, 3, 4, 5, 6, 15, 14]
[16, 20, 19, 18, 17, 7, 6, 15, 14, 13, 12, 11, 10, 9, 8, 1, 5, 4, 3, 2]
[5, 1, 2, 3, 4, 14, 15, 6, 7, 8, 9, 10, 11, 12, 13, 20, 16, 17, 18, 19]
[8, 9, 10, 2, 1, 5, 6, 7, 17, 18, 19, 11, 12, 3, 4, 14, 15, 16, 20, 13]
[13, 20, 16, 15, 14, 4, 3, 12, 11, 19, 18, 17, 7, 6, 5, 1, 2, 10, 9, 8]
[6, 15, 16, 17, 7, 8, 1, 5, 4, 14, 13, 20, 19, 18, 9, 10, 2, 3, 12, 11]
[6, 5, 4, 14, 15, 16, 17, 7, 8, 1, 2, 3, 12, 13, 20, 19, 18, 9, 10, 11]
[7, 6, 15, 16, 17, 18, 9, 8, 1, 5, 4, 14, 13, 20, 19, 11, 10, 2, 3, 12]
[19, 18, 17, 16, 20, 13, 12, 11, 10, 9, 8, 7, 6, 15, 14, 4, 3, 2, 1, 5]
[14, 15, 6, 5, 4, 3, 12, 13, 20, 16, 17, 7, 8, 1, 2, 10, 11, 19, 18, 9]
[17, 18, 9, 8, 7, 6, 15, 16, 20, 19, 11, 10, 2, 1, 5, 4, 14, 13, 12, 3]
[6, 7, 8, 1, 5, 4, 14, 15, 16, 17, 18, 9, 10, 2, 3, 12, 13, 20, 19, 11]
[14, 13, 20, 16, 15, 6, 5, 4, 3, 12, 11, 19, 18, 17, 7, 8, 1, 2, 10, 9]
[20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
[7, 17, 18, 9, 8, 1, 5, 6, 15, 16, 20, 19, 11, 10, 2, 3, 4, 14, 13, 12]
[15, 6, 5, 4, 14, 13, 20, 16, 17, 7, 8, 1, 2, 3, 12, 11, 19, 18, 9, 10]
[9, 10, 2, 1, 8, 7, 17, 18, 19, 11, 12, 3, 4, 5, 6, 15, 16, 20, 13, 14]
[2, 1, 8, 9, 10, 11, 12, 3, 4, 5, 6, 7, 17, 18, 19, 20, 13, 14, 15, 16]
[12, 13, 14, 4, 3, 2, 10, 11, 19, 20, 16, 15, 6, 5, 1, 8, 9, 18, 17, 7]
[17, 16, 20, 19, 18, 9, 8, 7, 6, 15, 14, 13, 12, 11, 10, 2, 1, 5, 4, 3]
[18, 17, 16, 20, 19, 11, 10, 9, 8, 7, 6, 15, 14, 13, 12, 3, 2, 1, 5, 4]
[18, 19, 11, 10, 9, 8, 7, 17, 16, 20, 13, 12, 3, 2, 1, 5, 6, 15, 14, 4]
[11, 12, 3, 2, 10, 9, 18, 19, 20, 13, 14, 4, 5, 1, 8, 7, 17, 16, 15, 6]
[15, 14, 13, 20, 16, 17, 7, 6, 5, 4, 3, 12, 11, 19, 18, 9, 8, 1, 2, 10]
[19, 11, 10, 9, 18, 17, 16, 20, 13, 12, 3, 2, 1, 8, 7, 6, 15, 14, 4, 5]
[12, 11, 19, 20, 13, 14, 4, 3, 2, 10, 9, 18, 17, 16, 15, 6, 5, 1, 8, 7]
[20, 16, 15, 14, 13, 12, 11, 19, 18, 17, 7, 6, 5, 4, 3, 2, 10, 9, 8, 1]
[13, 14, 4, 3, 12, 11, 19, 20, 16, 15, 6, 5, 1, 2, 10, 9, 18, 17, 7, 8]
[5, 6, 7, 8, 1, 2, 3, 4, 14, 15, 16, 17, 18, 9, 10, 11, 12, 13, 20, 19]
[14, 4, 3, 12, 13, 20, 16, 15, 6, 5, 1, 2, 10, 11, 19, 18, 17, 7, 8, 9]

For any other net, simply replace every occurrence of i with the ith number in the input (where i is 1-based).
Related Challenges

Hunt the Wumpus
Drawing 3d nets - Platonic solids

Leaderboard
The first post of the series generates a leaderboard.
To make sure that your answers show up, please start every answer with a headline, using the following Markdown template:
## Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:
## Ruby, <s>104</s> <s>101</s> 96 bytes

(The language is not currently shown, but the snippet does require and parse it, and I may add a by-language leaderboard in the future.)

Regarding our discussion, I've added the word "must" to make it clearer. I think that closes the loophole I've been taking advantage of. Still, I think the approach I used (though invalid) is interesting.

This is almost exactly like my sandbox post!

@RikerW That's what I thought when you sandboxed it. ;) (At the time, mine was directly below yours. I thought this one inspired yours.) Yours is obviously much simpler though (which is probably a good thing).

Never saw yours.  That's weird, I thought I read all of the ones on the first page.  But no, I made mine independently.

Shouldn´t that be titled "unfold a d20"?

@Titus This challenge is not about generating the net. It's about permuting the faces in a way which corresponds to a rigid rotation of the entire d20.

Ruby, 160 bytes (rev B)
17 bytes saved thanks to suggestions from Martin Büttner.
->a,n{n.times{k=rand 60
%w{ABCD@GHIJKLMNEFPQRSO PFENOSRQHG@DCMLKJIAB GFPQHIA@DENOSRJKBCML}.map{|b|k.times{a=b.chars.map{|i|a[i.ord-64]}}}
k>29&&a.reverse!
p a}}

Ruby, 177 bytes (rev A)
->n,a{n.times{k=rand(60)
h=->b{k.times{|j|a=(0..19).map{|i|a[b[i].ord-64]}}}
h['ABCD@GHIJKLMNEFPQRSO']
h['PFENOSRQHG@DCMLKJIAB']
h['GFPQHIA@DENOSRJKBCML']
k>29&&a.reverse!
p a}}

Explanation
It is possible to generate all possible orientations by rotations about one face (3-fold), one vertex (5-fold) and two edges (2-fold). But not just any face and edges. The axes must have the correct relationship and the rotations must be done in the correct order, or strange things can happen.
This is the way I did it (though I understand Martin did it differently.)
All orientations of a tetrahedron can be generated by combinations of the following three symmetry operations:
a)Rotation about two 2-fold axes at right through the midpoints of the edges (these are at right angles to each other. If we multiply them together we discover a third 2-fold axis through the remaining pair of edges.)
b) Rotation about a 3 fold axis diagonal to the 2-fold axes, passing through a vertex and a face.
The icosahedron's symmetry is a superset of that of the tetrahedron. In the image below from https://en.wikipedia.org/wiki/Icosahedron, the yellow faces and red faces define two different tetrahedra (or alternatively a single octahedron), while the edges common to two blue faces are in three pairs at right angles (and lie on the faces of a cube.)
All orientations of the icosahedron can be generated by those symmetry operations mentioned above plus an additional 5-fold operation.

The rotations about three out of the four axes mentioned above are represented by the magic strings between the '' marks. Rotation about the second  2-fold axis is different, and can be done just by reversing the array a[].
Ungolfed in test program:
f=->a,n{
  n.times{                     #Iterate n times, using the result from the previous iteration to generate the next
    k=rand(60)                 #pick a random number

    h=->b{                     #helper function taking a string representing a transformation
      k.times{|j|              #which is performed on a using the number of times according to k
        a=(0..19).map{|i|a[b[i].ord-64]}
      }
    }

    #Rotate about axes k times (one 5-fold, one 3-fold, two 2-fold)
    #The first three axes have coprime rotation orders
    #And the rotations themselves take care of the modulus operation so no need to add it.
    #The second 2-fold rotation is equivalent to reversing the order
    #And is applied to the last 30 numbers as it is not coprime with the first 2-fold rotation.

    h['ABCD@GHIJKLMNEFPQRSO']  #rotate k times about 5-fold axis
    h['PFENOSRQHG@DCMLKJIAB']  #rotate k times about 3-fold axis
    h['GFPQHIA@DENOSRJKBCML']  #rotate k times about 2-fold axis
    k>29&&a.reverse!
    p a
  }
}

z=(1..20).map{|i|i}
f[z,50]

Alternative solution 131 bytes (Invalid due to binary random walk approach, only gives an approximately correct distribution.)
->a,n{(n*99).times{|i|s=['@DEFGHIABCMNOPQRJKLS','ABCD@GHIJKLMNEFPQRSO'][rand(2)]
a=(0..19).map{|i|a[s[i].ord-64]}
i%99==98&&p(a)}}

This is a scramble (much like the programs used to scramble rubik's cube.)
The specific rotations I use are two of the most obvious ones:
-A 120 degree rotation (about faces 1 and 20 per the first diagram)
-A 72 degree rotation (about the vertices common to 1,2,3,4,5 and 16,17,18,19,20 per the first diagram.)
we flip a coin 99 times, and each time we perform one of these two rotations depending if it is heads or tails.
Note that alternating these deterministically leads to fairly short sequences. For example, with the correct rotation senses, a 180 degree rotation can be produced with a period of just 2.

It seems like flipping a coin to pick an operation is going to yield something closer to a binomial distribution than a uniform distribution.

@Sparr that would be the case if the state space was larger than the random walk. But in this case a random walk of just 6 steps may open up as many as 2^6=64 possibilities (I haven't counted them), and our state space is only 60. After 99 steps (2^99 different paths) everything should be at least as uniformly distributed as a single sample of the  PRNG used to generate the numbers.

@MartinBüttner Thanks for the tips, I've applied the ones that work. b.map doesn't work directly, I need b.chars.map to make it work (BTW that doesn't work in my machine as I have Ruby 1.9.3 but it does work on Ideone.) It's a fair saving. I don't think changing the magic strings for nonprintable characters to save the -64 will work: %w{} interprets \n (as well as space) as a separator between strings in the array generated. I have no idea what it will do with other nonprintable ASCII characters.

@Martin this was harder than I expected - at first I was baffled when my code didn't work properly, then I took a break and suddenly realised that the 2-fold and and 3-fold symmetries had to have the same mutual relationship as on a tetrahedron (I had to change the triangular face which I was rotating about for a different triangular face.)

@steveverrill I can't quite picture the relationship to the tetrahedron (my group theory isn't that solid), but the permutations I used to generate the list of all nets was (with reference to the net in the challenge), a) rotation about the vertex between 1,2,3,4,5, b) a rotation which swaps the positions of 1 and 8, c) a rotation about 1 and d) reversing the array, of course.

@MartinBüttner I've added an image and link for the tetrahedron. Reversing the array corresponds to a 180 rotation about edges 10,11 and 6,15. I assume you realised that 180 rotation about edges 1,8 and  20,13 is at right angles to this. The product of these 2 rotations is a rotation about 3,4 and 17,18. These 12 faces are those that don't share the tetrahedron relationship with the mentioned edges. The remaining 8 faces (in 2 groups of 4) do: in other words, those that are not adjacent to any of these 6 edges.

@MartinBüttner I find it odd that you don't have a problem and I did: the operations I used at first were the exact same ones as yours. I was forced to change from rotating about face 1 to rotating about face 9. If you change the first line of my function from k=rand 60 to |k|a=(1..20).map{|i|i} and call it with n=60 it will generate each permutation exactly once. But if you change PFENOSRQHG@DCMLKJIAB (rotation about face 9) to @DEFGHIABCMNOPQRJKLS (rotation about face 1, which is what I had originally) I get some duplicates and some missing permutations.

@steveverrill I applied the rotations in a different order. After the 5-fold rotation, I first rotated about the 1,8 edge, and then about the 1-face.

Congrats on being the first user with the newly unlocked [tag:geometry] badge. :)

@MartinBüttner Thanks! As you may have noticed, geometry (especially polyhedra) are my cup of tea. BTW: I tried doing the rotations in the same order as you, and found that the rotation about face 1 worked (while the rotation about face 9 became broken.) Face 1 is actually a much more regular permutation, but I couldn't think of a way to take advantage of that so I've left my code as it is.  I've updated the text to indicate that there is more than one way of doing this. But when I ran into problems, I went for the tetrahedron plus 5-fold axis approach as I knew it would work.

IA-32 machine code, 118 bytes
Hexdump:
60 33 c0 51 8b 74 24 28 8b fa 6a 05 59 f3 a5 e8
21 00 00 00 20 c4 61 cd 6a 33 00 84 80 ad a8 33
32 00 46 20 44 8e 48 61 2d 2c 33 32 4a 00 21 20
a7 a2 90 8c 00 5b b1 04 51 0f c7 f1 83 e1 1f 49
7e f7 51 8b f2 56 8d 7c 24 e0 b1 14 f3 a4 5f 8b
f3 ac 8b ee d4 20 86 cc e3 0a 56 8d 74 04 e0 f3
a4 5e eb ed 59 e2 db 8b dd 59 e2 cc 59 83 c2 14
e2 91 61 c2 04 00

It's a bit long, so some explanations go first. I used almost the same algorithm as the existing answer by Level River St. To make my answer different, I took other basic permutations, which don't necessarily have intuitive geometrical meaning, but are somehow more convenient.
The code basically has to generate a permutation, which is a sequential application of the following:

A permutation of order 3, which I call p3, applied 0...2 times
A permutation of order 2, which I call q2, applied 0 or 1 times
A permutation of order 5, which I call p5, applied 0...4 times
Another permutation of order 2, which I call p2, applied 0 or 1 times

There are many possible choices for these permutations. One of them is as follows:
p3 = [0   4   5   6   7   8   9   1   2   3  13  14  15  16  17  18  10  11  12  19]
q2 = [4   5   6   7   0   1   2   3  13  14  15  16  17   8   9  10  11  12  19  18]
p5 = [6   7   0   4   5  14  15  16  17   8   9   1   2   3  13  12  19  18  10  11]
p2 = [1   0   7   8   9  10  11   2   3   4   5   6  16  17  18  19  12  13  14  15]

This choice is better than others because the permutations here have long runs of sequential indices, which can be compressed by run-length encoding - only 29 bytes for the 4 permutations.
To simplify the generation of random numbers, I chose the powers (how many times each permutation is applied) in the range 1...30 for all of them. This leads to much extra work in the code, because e.g. p3 becomes an identity permutation each time it's multiplied by itself 3 times. However, the code is smaller that way, and as long as the range is divisible by 30, the output will have uniform distribution.
Also, powers should be positive so the run-length decoding operation is performed at least once.
The code has 4 nested loops; the outline is like this:
void doit(int n, uint8_t* output, const uint8_t input[20])
{
    uint8_t temp[20];

    n_loop: for i_n = 0 ... n
    {
        memcpy(output, input, 20);
        expr_loop: for i_expr = 0 ... 3
        {
            power = rand(1 ... 30);
            power_loop: for i_power = 0 ... power
            {
                memcpy(temp, output, 20);
                output_index = 0;
                perm_loop: do while length > 0
                {
                    index = ...; // decode it
                    length = ...; // decode it
                    memcpy(output + output_index, temp + index, length);
                    output_index += length;
                }
            }
        }
        output += 20;
    }
}

I hope this pseudo-code is clearer than the inline-assembly code below.
_declspec(naked) void __fastcall doit(int n, uint8_t* output, const uint8_t* input)
{
    _asm {
        pushad
        xor eax, eax

        n_loop:
            push ecx

            ; copy from input to output
            mov esi, [esp + 0x28]
            mov edi, edx
            push 5
            pop ecx
            rep movsd

            call end_of_data
#define rl(index, length) _emit(length * 32 + index)
            rl(0, 1)
            rl(4, 6)
            rl(1, 3)
            rl(13, 6)
            rl(10, 3)
            rl(19, 1)
            _emit(0)

            rl(4, 4)
            rl(0, 4)
            rl(13, 5)
            rl(8, 5)
            rl(19, 1)
            rl(18, 1)
            _emit(0)

            rl(6, 2)
            rl(0, 1)
            rl(4, 2)
            rl(14, 4)
            rl(8, 2)
            rl(1, 3)
            rl(13, 1)
            rl(12, 1)
            rl(19, 1)
            rl(18, 1)
            rl(10, 2)
            _emit(0)

            rl(1, 1)
            rl(0, 1)
            rl(7, 5)
            rl(2, 5)
            rl(16, 4)
            rl(12, 4)
            _emit(0)

            end_of_data:
            pop ebx ; load the address of the encoded data
            mov cl, 4

            expr_loop:
                push ecx

                make_rand:
                rdrand ecx
                and ecx, 31
                dec ecx
                jle make_rand

                ; input: ebx => encoding of permutation
                ; output: ebp => encoding of next permutation
                power_loop:
                    push ecx

                    ; copy from output to temp
                    mov esi, edx
                    push esi
                    lea edi, [esp - 0x20]
                    mov cl, 20
                    rep movsb
                    pop edi

                    ; ebx => encoding of permutation
                    ; edi => output
                    mov esi, ebx
                    perm_loop:
                        ; read a run-length
                        lodsb
                        mov ebp, esi

                        _emit(0xd4)             ; divide by 32, that is, split into
                        _emit(32)               ; index (al) and length (ah)
                        xchg cl, ah             ; set ecx = length; also makes eax = al
                        jecxz perm_loop_done    ; zero length => done decoding
                        push esi
                        lea esi, [esp + eax - 0x20]
                        rep movsb
                        pop esi
                        jmp perm_loop

                    perm_loop_done:
                    pop ecx
                    loop power_loop

                mov ebx, ebp
                pop ecx
                loop expr_loop

            pop ecx
            add edx, 20
            loop n_loop

        popad
        ret 4
    }
}

Some fun implementation details:

I used indented assembly, like in high-level languages; otherwise the code would be an incomprehensible mess
I use call and subsequent pop to access data (encoded permutations) stored in code
The jecxz instruction conveniently lets me use a zero byte as termination for the run-length decoding process
By luck, the number 30 (2 * 3 * 5) is almost a power of 2. This lets me use short code to generate a number in the range 1...30:
        and ecx, 31
        dec ecx
        jle make_rand

I use a "general-purpose division" instruction (aam) to separate a byte into bit fields (3-bit length and 5-bit index); by luck, at that position in code, cl = 0, so I benefit from both "sides" of xchg


text:
Catalan Numbers
The Catalan numbers (OEIS) are a sequence of natural numbers often appearing in combinatorics.
The nth Catalan number is the number of Dyck words (balanced strings of parenthesis or brackets such as [[][]]; formally defined as a string using two characters a and b such that any substring starting from the beginning has number of a characters greater than or equal to number of b characters, and the entire string has the same number of a and b characters) with length 2n. The nth Catalan number (for \$n\ge0\$) is also explicitly defined as:
$$C_n=\frac1{n+1}\binom{2n}n$$
Starting from \$n=0\$, the first 20 Catalan numbers are:
1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796, 58786, 208012, 742900, 2674440, 9694845, 35357670, 129644790, 477638700, 1767263190...

Challenge
Write a full program or function that takes a non-negative integer n via STDIN or an acceptable alternative, and outputs the nth Catalan number. Your program must work at minimum for inputs 0-19.
I/O
Input
Your program must take input from STDIN, function arguments or any of the acceptable alternatives per this meta post. You can read the inputted number as its standard decimal represention, unary representation, or bytes.

If (and only if) your language cannot take input from STDIN or any acceptable alternative, it may take input from a hardcoded variable or suitable equivalent in the program.

Output
Your program must output the nth Catalan number to STDOUT, function result or any of the acceptable alternatives per this meta post. You can output the Catalan number in its standard decimal representation, unary representation or bytes.
The output should consist of the approriate Catalan number, optionally followed by one or more newlines. No other output can be generated, except constant output of your language's interpreter that cannot be suppressed (such as a greeting, ANSI color codes or indentation).

This is not about finding the language that is the shortest. This is about finding the shortest program in every language. Therefore, I will not accept an answer.
In this challenge, languages newer than the challenge are acceptable as long as they have an implementation. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language. Other than that, all the standard rules of code-golf must be obeyed. Submissions in most languages will be scored in bytes in an appropriate preexisting encoding (usually UTF-8). Note also that built-ins for calculating the nth Catalan number are allowed.
Catalog
The Stack Snippet at the bottom of this post generates the catalogue from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.
To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
## Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:
## Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:
## Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the snippet:
## [><>](http://esolangs.org/wiki/Fish), 121 bytes

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

Can we print/return a float rather than an integer?

@AlexA. This is acceptable.

Shall there be a tag [tag:OEIS]?

@Vi. There was a meta discussion about that a while back and we agreed that [tag:oeis] was unnecessary

@Vi. Here is the meta post: http://meta.codegolf.stackexchange.com/a/5546/8478. As for some reasoning, you can find OEIS-style challenges quite reliably with [tag:sequence] and one of [tag:number] or [tag:number-theory]. Whether the given sequence actually is in OEIS, is completely irrelevant to the challenge.

@MartinBüttner, Thinking about making a challenge about generating some sequence not in OEIS, but can't think up any viable formulation barring just pseudorandom numbers..

C, 78 52 39 34 33 bytes
Even more C magic (thanks xsot):
c(n){return!n?:(4+6./~n)*c(n-1);}

?: is a GNU extension.

This time by expanding the recurrence below (thanks xnor and Thomas Kwa):
$$
\begin{equation}
\begin{split}
C_0 & = 1 \\
C_n & = \frac{2 (2n - 1)}{n + 1} C_{n - 1} \\
& = \frac{2 (2n+2-3)}{n+1} C_{n - 1} \\
& = 2 \left(2\frac{n+1}{n+1} - \frac{3}{n+1}\right) C_{n - 1} \\
& = \left(4 - \frac{6}{n+1}\right) C_{n - 1}
\end{split}
\end{equation}
$$
c(n){return n?(4+6./~n)*c(n-1):1;}

-(n+1) is replaced by ~n, which is equivalent in two's complement and saves 4 bytes.

Again as a function, but this time exploiting the following recurrence:
$$
\begin{equation}
\begin{split}
C_0 & = 1 \\
C_n & = \frac{2 (2n - 1)}{n + 1} \cdot C_{n - 1}
\end{split}
\end{equation}
$$
c(n){return n?2.*(2*n++-1)/n*c(n-2):1;}

c(n) enters an infinite recursion for negative n, although it's not relevant for this challenge.

Since calling a function seems an acceptable alternative to console I/O:
c(n){double c=1,k=2;while(k<=n)c*=1+n/k++;return c;}

c(n) takes an int and returns an int.

Original entry:
main(n){scanf("%d",&n);double c=1,k=2;while(k<=n)c*=1+n/k++;printf("%.0f",c);}

Instead of directly calculating the definition, the formula is rewritten as:
$$
\begin{equation}
\begin{split}
\frac{1}{n + 1} {2n \choose n} &= \frac{(2n)!}{(n!)^2 \cdot (n + 1)} \\
& = \frac{2n \cdot \ldots \cdot (n + 1)}{n! \cdot (n + 1)} \\
& = \frac{1}{n + 1} \cdot \frac{\prod_{k = 1}^n (n + k)}{\prod_{k = 1}^n k} \\
& = \frac{1}{n + 1} \cdot \prod_{k = 1}^n \frac{n + k}{k} \\
& = \frac{1}{n + 1} \cdot \prod_{k = 1}^n \left(1 + \frac{n}{k}\right) \\
& = \frac{1}{n + 1} (n + 1) \prod_{k = 2}^n \left(1 + \frac{n}{k}\right) \\
& = \prod_{k = 2}^n \left(1 + \frac{n}{k}\right)
\end{split}
\end{equation}
$$
The formula assumes n >= 2, but the code accounts for n = 0 and n = 1 too.
In the C mess above, n and k have the same role as in the formula, while c accumulates the product. All calculations are performed in floating point using double, which is almost always a bad idea, but in this case the results are correct up to n = 19 at least, so it's ok.
float would have saved 1 byte, unfortunately it's not precise enough.

I can't test this now but I think you can shorten it further: c(n){return!n?:(4+6./~n)*c(n-1);}

Thanks @xsot, I didn't know ?:! Apparently, it's a GNU C extension but I think it still qualifies.

Jelly, 4 bytes
Ḥc÷‘

Try it online!
How it works
Ḥc÷‘    Left argument: z

Ḥ       Compute 2z.
 c      Hook; apply combinations to 2z and z.
  ÷‘    Divide the result by z+1.

What does "hook' mean? How does c get 2z and z as its arguments?

@xnor A hook means functions evaluated like f(x,g(x)). When there's a dyadic function followed by another dyadic function, the parser evaluates the first one as a hook.

@Dennis Is that really 4 bytes? With those non-ASCII characters, https://mothereff.in/byte-counter says 9 bytes

@LuisMendo it's probably a different encoding

@LuisMendo Jelly uses its own, custom encoding default, where each character is a single byte. With UTF-8, the source code is indeed 9 bytes long.

@Dennis Sorry about my confusion then

Is there any info on this language available?

@NBZ At the moment, only this and the conversations here.

CJam, 12 bytes
ri_2,*e!,\)/

Try it online.
Beyond input 11, you'll need to tell your Java VM to use more memory. And I wouldn't actually recommend going much beyond 11. In theory, it works for any N though, since CJam uses arbitrary-precision integers.
Explanation
CJam doesn't have a built-in for binomial coefficients, and computing them from three factorials takes a lot of bytes... so we'll have to do something better than that. :)
ri  e# Read input and convert it to integer N.
_   e# Duplicate.
2,  e# Push [0 1].
*   e# Repeat this N times, giving [0 1 0 1 ... 0 1] with N zeros and N ones.
e!  e# Compute the _distinct_ permutations of this array.
,   e# Get the number of permutations - the binomial. There happen to be 2n-over-n of
    e# of them. (Since 2n-over-n is the number of ways to choose n elements out of 2n, and
    e# and here we're choosing n positions in a 2n-element array to place the zeros in.)
\   e# Swap with N.
)/  e# Increment and divide the binomial coefficient by N+1.

This is really cool. +1

This is clever. I tried it with calculating the factorials. It only takes two of the usual three since two of them are the same. It still used 17 bytes (ri_2*m!1$m!_*/\)/) in my implementation. The only good thing is that it's much faster. :)

TI-BASIC, 11 bytes
(2Ans) nCr Ans/(Ans+1

Strangely, nCr has higher precedence than multiplication.

Python 3, 33 bytes
f=lambda n:0**n or(4+6/~n)*f(n-1)

Uses the recurrence
f(0) = 1
f(n) = (4-6/(n+1)) * f(n-1)

The base case of 0 is handled as 0**n or, which stops as 1 when n==0 and otherwise evaluates the recursive expression on the right. The bitwise operator ~n==-n-1 shortens the denominator and saves on parens.
Python 3 is used for its float division. Python 2 could do the same with one more byte to write 6..

Why not n<1 rather than 0**n ?

@feersum It returns True for n==0 rather than 1. Of course, True == 1 but True is not 1 and it prints differently. I'd expect this to not be allowed. Do you know if we have a ruling on this?

I believe that it is fine. isinstance(True, int) is True after all.

I think it's still iffy in the general case and moreso here where the challenge specifies the output as a number or its representation. But, up to @quartata

Mathematica, 16 13 bytes
CatalanNumber

Built-ins, amirite fellas :/
Non-builtin version (21 bytes):
Binomial[2#,#]/(#+1)&

A binomial-less version (25 bytes):
Product[(#+k)/k,{k,2,#}]&

J, 8 bytes
>:%~]!+:

This is a monadic train; it uses the (2x nCr x)/(x+1) formula. Try it here.

pl, 4 bytes
☼ç▲÷

Try it online.
Explanation
In pl, functions take their arguments off the stack and push the result back onto the stack. Normally when there are not enough arguments on the stack, the function simply fails silently. However, something special happens when the amount of arguments on the stack is one off from the arity of the function -- the input variable _ is added to the argument list:
☼ç▲÷

☼      double: takes _ as the argument since there is nothing on the stack
 ç     combinations: since there is only one item on the stack (and arity is 2), it adds _ to the argument list (combinations(2_,_))
  ▲    increment last used var (_)
   ÷   divide: adds _ to the argument list again

In effect, this is the pseudocode:
divide(combinations(double(_),_),_+1);

Sesos, 94 86 68 bytes
8 bytes by changing the factorial-er from version 1 to version 2.
18 bytes by computing n!(n+1)! in one step. Largely inspired by Dennis' primality test algorithm.
Hexdump:
0000000: 16f8de a59f17 a0ebba 7f4cd3 e05f3f cf0fd0 a0ebde  ..........L.._?......
0000015: b1c1bb 76fe18 8cc1bb 76fe1c e0fbda 390fda bde3d8  ...v.....v.....9.....
000002a: 000fbe af9d1b b47bc7 cfc11c b47bc7 cff1fa e07bda  .......{.....{.....{.
000003f: 39e83e cf07                                       9.>..

Try it online!
Uses the formula a(n) = (2n)! / (n!(n+1)!).

The factorial-er: version 1 (in-place, constant memory), version 2 (in-place, linear memory)
The multiplier: here (in place, constant memory)
The divider: here (does not halt if not divisible)

Assembler
set numin
set numout
get
jmp,sub 1,fwd 1,add 1,fwd 2,add 2,rwd 3,jnz
fwd 1,add 1
jmp
  jmp,sub 1,rwd 1,add 1,rwd 1,add 1,rwd 1,add 1,fwd 3,jnz
  rwd 1,sub 1,rwd 1,sub 1,rwd 1
  jmp,sub 1,fwd 3,add 1,rwd 3,jnz
  fwd 1
jnz
fwd 3
jmp
  jmp
    sub 1,rwd 1
    jmp,sub 1,rwd 1,add 1,rwd 1,add 1,fwd 2,jnz
    rwd 2
    jmp,sub 1,fwd 2,add 1,rwd 2,jnz
    fwd 3
  jnz
  rwd 1
  jmp,sub 1,jnz
  rwd 1
  jmp,sub 1,fwd 2,add 1,rwd 2,jnz
  fwd 3
jnz
fwd 1
jmp
  jmp,sub 1,fwd 1,add 1,fwd 1,add 1,rwd 2,jnz
  fwd 1,sub 1,fwd 1
  jmp,sub 1,rwd 2,add 1,fwd 2,jnz
  rwd 1
jnz
rwd 2
jmp
  jmp
    sub 1,fwd 1
    jmp,sub 1,fwd 1,add 1,fwd 1,add 1,rwd 2,jnz
    fwd 2
    jmp,sub 1,rwd 2,add 1,fwd 2,jnz
    rwd 3
  jnz
  fwd 1
  jmp,sub 1,jnz
  fwd 1
  jmp,sub 1,rwd 2,add 1,fwd 2,jnz
  rwd 3
jnz
fwd 1
jmp
  fwd 1,add 1,rwd 3
  jmp,sub 1,fwd 1,add 1,fwd 1,sub 1,rwd 2,jnz
  fwd 1
  jmp,sub 1,rwd 1,add 1,fwd 1,jnz
  fwd 1
jnz
fwd 1
put

Brainfuck equivalent
This Retina script is used to generate the brainfuck equivalent. Note that it only accepts one digit as command argument, and does not check if a command is in the comments.
[->+>>++<<<]>+
[[-<+<+<+>>>]<-<-<[->>>+<<<]>]>>>
[[-<[-<+<+>>]<<[->>+<<]>>>]<[-]<[->>+<<]>>>]>
[[->+>+<<]>->[-<<+>>]<]<<
[[->[->+>+<<]>>[-<<+>>]<<<]>[-]>[-<<+>>]<<<]>
[>+<<<[->+>-<<]>[-<+>]>]>

Pyth, 8
/.cyQQhQ

Try it online or run the Test Suite
Explanation
/.cyQQhQ   ## implicit: Q = eval(input())
/     hQ   ## integer division by (Q + 1)
 .c        ## nCr
   yQ      ## use Q * 2 as n
     Q     ## use Q as r

Julia, 23 bytes
n->binomial(2n,n)/(n+1)

This is an anonymous function that accepts an integer and returns a float. It uses the basic binomial formula. To call it, give it a name, e.g. f=n->....

Seriously, 9 bytes
,;;u)τ╣E\

Hex Dump:
2c3b3b7529e7b9455c

Try it online
Explanation:
,                   Read in evaluated input n
 ;;                 Duplicate it twice
   u)               Increment n and rotate it to bottom of stack
     τ╣             Double n, then push 2n-th row of Pascal's triangle
       E            Look-up nth element of the row, and so push 2nCn
        \           Divide it by the n+1 below it.

You can save a byte by exploiting the fact that the rows of Pascal's triangle are symmetric, so the median of the 2nth row is C(2n,n). Thus: ,;u@τ╣║/ for 8 bytes.

What? Isn't 2nCn the max of the 2nth row?

Yes, and it's also the median. So, both ║ and M would work.

@Mego I worry about your implementation of median if something can be both the median and max in the case that the list isn't all the same number. If you mean "in the middle of the list" then you might choose a different name for it...

Yes, it's the middle of the list. For sorted lists, it's the typical statistical median, but for unsorted lists it's just the middle (or average of 2 middle elements)

I would not have guessed that from the name.

Matlab, 35 25 bytes
@(n)nchoosek(2*n,n)/(n+1)

Octave, 23 bytes
@(n)nchoosek(2*n,n++)/n

You can use @(n) instead of function, anonymous functions are ok.

I've seen several answers on here before that had workspace variables being accessed (implying they had already been set by the user elsewhere). Scripts in MATLAB/Octave also can appear as simple snippets. I've re-made it into a function for now...

You can knock off 2 more bytes by post-incrementing n: @(n)nchoosek(2*n,n++)/n

@beaker thanks for the tip! it only works in Octave though, not Matlab, so I've split it apart

@costrom That's interesting. I guess .../++n doesn't work either. :/

JavaScript (ES6), 24 bytes
Based on the Python answer.
c=x=>x?(4+6/~x)*c(x-1):1

How it works
c=x=>x?(4+6/~x)*c(x-1):1
c=x=>                     // Define a function c that takes a parameter x and returns:
     x?               :1  //  If x == 0, 1.
       (4+6/~x)           //  Otherwise, (4 + (6 / (-x - 1)))
               *c(x-1)    //  times the previous item in the sequence.

I think this is the shortest it can get, but suggestions are welcome!

, 3 chars / 6 bytes
Мƅï

Try it here (Firefox only).
Builtins ftw! So glad I implemented math.js early on.
Bonus solution, 12 chars / 19 bytes
Мơ 2*ï,ï)/⧺ï

Try it here (Firefox only).
Ay! 19th byte!
Evaluates to pseudo-ES6 as:
nchoosek(2*input,input)/(input+1)

Dyalog APL, 9 bytes
+∘1÷⍨⊢!+⍨

This is a monadic train; it uses the (2x nCr x)/(x+1) formula. Try it online here.

Haskell, 27 bytes
g 0=1
g n=(4-6/(n+1))*g(n-1)

A recursive formula. There's got to be a way to save on parens...
Directly taking the product was 2 bytes longer:
g n=product[4-6/i|i<-[2..n+1]]

Where does your code read from stdin or write to stdout?

@user2845840 Functions are one of the acceptable alternatives linked to in the spec.

g(n-1) => g$n-1 saves one byte. Edit: actually this doesn't work because then the formula is interpreted as (...*g) (n-1).

C, 122 121 119 108 bytes
main(j,v)char**v;{long long p=1,i,n=atoi(v[1]);for(j=0,i=n+1;i<2*n;p=(p*++i)/++j);p=n?p/n:p;printf("%d",p);}

I used gcc (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125) to compile in a windows cygwin environment.  Input comes in on the command line.  It's similar to Sherlock9's Python solution but the loops are combined into one to avoid overflow and get output up to the 20th Catalan number (n=19).

You can remove the space after the comma in the main definition to save a byte.

Nice, I'll edit the post now

You can save 2 more bytes with char**v rather than char *v[]. (The space before * is not needed, and the types are equivalent.)

Sure enough, that works great.  Thanks Mat

This uses some stuff from the tips page to shorten it. Note though that for Ideone I hardcoded a value for n.

R, 35 28 16 bytes
numbers::catalan

Edit: Use numbers package builtin.

05AB1E, 6 bytes
Dxcr>/

Explanation:
Code:     Stack:               Explanation:

Dxcr>/

D         [n, n]               # Duplicate of the stack. Since it's empty, input is used.
 x        [n, n, 2n]           # Pops a, pushes a, a * 2
  c       [n, n nCr 2n]        # Pops a,b pushes a nCr b
   r      [n nCr 2n, n]        # Reverses the stack
    >     [n nCr 2n, n + 1]    # Increment on the last item
     /    [(n nCr 2n)/(n + 1)] # Divides the last two items
                               # Implicit, nothing has printed, so we print the last item

Javagony, 223 bytes
public class C{public static int f(int a,int b){try{int z=1/(b-a);}catch(Exception e){return 1;}return a*f(a+1,b);}public static void main(String[]s){int m=Integer.parseInt(s[0])+1;System.out.println(f(m,2*m-1)/f(1,m)/m);}}

Fully expanded:
public class C {
    public static int f(int a,int b){
        try {
            int z=1/(b-a);
        } catch (Exception e){
            return 1;
        }
        return a*f(a+1,b);
    }
    public static void main(String[] s){
        int m=Integer.parseInt(s[0])+1;
        System.out.println(f(m,2*m-1)/f(1,m)/m);
    }
}

Esolangs entry doesn't matter - as long as you use an interpreter made before the contest, it's all good and valid.

Ain't gonna win anyway^^

It is java, so yeah.

@Riker Well, it's worse than Java.

R, 28 bytes
Not using a package, so slightly longer than a previous answer
choose(2*(n=scan()),n)/(n+1)

Oasis, 9 bytes
nxx«*n>÷1

Try it online!
Oasis is a language designed by Adnan which is specialized in sequences.
Here, we shall use the following relationship kindly provided by Stefano Sanfilippo:

Currently, this language can do recursion and closed form.
To specify that a(0)=1 is simple: just add the 1 at the end.
For example, if a sequence begins with a(0)=0 and a(1)=1, just put 10 at the end.
Unfortunately, all sequences must be 0-indexed.
nxx«*n>÷1                        stack
        1  a(0)=1

n          push n (input)        n
 x         double                2n
  x        double                4n
   «       minus 2               4n-2
    *      multiply: second      (4n-2)*a(n-1)
           argument is missing,
           so a(n-1) is used.
     n     push n (input)        (4n-2)*a(n-1) n
      >    add 1                 (4n-2)*a(n-1) n+1
       ÷   integer division      (4n-2)*a(n-1)/(n+1)
                               = ((4n-2)/(n+1))*a(n-1)
                               = ((4n+4-6)/(n+1))*a(n-1)
                               = ((4n+4)/(n+1) - 6/(n+1))*a(n-1)
                               = (4-6/(n+1))*a(n-1)

Closed-form:
10 bytes
nx!n!n>!*÷

Try it online!
nx!n!n>!*÷

n           push n (input)
 x          double
  !         factorial: stack is now [(2n)!]
   n        push n (input)
    !       factorial: stack is now [(2n)! n!]
     n      push n (input)
      >     add 1
       !    factorial: stack is now [(2n)! n! (n+1)!]
        *   multiply: stack is now [(2n)! (n!(n+1)!)]
         ÷  divide: stack is now [(2n)!/(n!(n+1)!)]

TeX, 231 bytes
\newcommand{\f}[1]{\begingroup\count0=1\count1=2\count2=2\count3=0\loop\multiply\count0 by\the\count1\divide\count0 by\the\count2\advance\count1 by4\advance\count2 by1\advance\count3 by1
\ifnum\count3<#1\repeat\the\count0\endgroup}

Usage
\documentclass[12pt,a4paper]{article}
\begin{document}
\newcommand{\f}[1]{\begingroup\count0=1\count1=2\count2=2\count3=0\loop\multiply\count0 by\the\count1\divide\count0 by\the\count2\advance\count1 by4\advance\count2 by1\advance\count3 by1
\ifnum\count3<#1\repeat\the\count0\endgroup}

\newcount \i
\i = 0
\loop
\f{\the\i}
\advance \i by 1
\ifnum \i < 15 \repeat
\end{document}

Japt, 16 bytes
Even Mathematica is shorter. :-/
U*2ª1 o àU l /°U

Try it online!
Ungolfed and explanation
U*2ª 1 o àU l /° U
U*2||1 o àU l /++U

         // Implicit: U = input number
U*2||1   // Take U*2. If it is zero, take 1.
o àU     // Generate a range of this length, and calculate all combinations of length U.
l /++U   // Take the length of the result and divide by (U+1).
         // Implicit: output result

Alternate version, based on the recursive formula:
C=_?(4+6/~Z *C$(Z-1):1};$C(U

Vitsy, 13 Bytes
VV2*FVF/V1+F/
V              Capture the input as a final global variable.
 V             Push it back.
  2*           Multiply it by 2
    F          Factorial.
     VF        Factorial of the input.
       /       Divide the second to top by the first.
        V1+    1+input
           F   Factorial.
            /  Divide.
This is a function in Vitsy. How to make it a program that does this, you ask? Concatenate N. c:
Try it online!

Milky Way 1.5.14, 14 bytes
':2K;*Ny;1+/A!

Explanation
'               # read input from the command line
 :              # duplicate the TOS
  2      1      # push integer to the stack
   K            # push a Pythonic range(0, TOS) as a list
    ;   ;       # swap the TOS and the STOS
     *          # multiply the TOS and STOS
      N         # push a list of the permutations of the TOS (for lists)
       y        # push the length of the TOS
          +     # add the STOS to the TOS
           /    # divide the TOS by the STOS
            A   # push the integer representation of the TOS
             !  # output the TOS

or, alternatively, the much more efficient version:

Milky Way 1.5.14, 22 bytes
'1%{;K£1+k1-6;/4+*}A!

Explanation
'                      # read input from the command line
 1     1  1 6  4       # push integer to the stack
  %{  £           }    # for loop
    ;        ;         # swap the TOS and the STOS
     K                 # push a Pythonic range(0, TOS) as a list
        +       +      # add the TOS and STOS
         k             # push the negative absolute value of the TOS
           -           # subtract the STOS from the TOS
              /        # divide the TOS by the STOS
                 *     # multiply the TOS and the STOS
                   A   # push the integer representation of the TOS
                    !  # output the TOS

Usage
python3 milkyway.py <path-to-code> -i <input-integer>

Pari/GP, 17 bytes
n->(2*n)!/n!/n++!

Try it online!

The binomial version is, predictably, longer (22 bytes).

Octave, 22 bytes
@(n)prod(4-6./(2:n+1))

Clojure/ClojureScript, 53 bytes
(defn c[x](if(= 0 x)1(*(c(dec x))(- 4(/ 6(inc x))))))

Clojure can be pretty frustrating to golf in.  It's very pithy while still being very readable, but some of the niftier features are really verbose.  (inc x) is more idiomatic than (+ x 1) and "feels" more concise, but doesn't actually save characters.  And writing chains of operations is nicer as (->> x inc (/ 6) (- 4)), but it's actually longer than just doing it the ugly way.

Ruby, 30 bytes
c=->n{n<1?1:c[n-1]*(4+6.0/~n)}

Thanks to xsot, saved few bytes by using complement.
Ungolfed:
c = -> n {
  n < 1 ? 1 : c[n-1]*(4+6.0/~n)
}

Usage:
> c=->n{n<1?1:c[n-1]*(4+6.0/~n)}
> c[10]
=> 16796.0

Prolog, 42 bytes
Using recursion is almost always the way to go with Prolog.
Code:
0*1.
N*X:-M is N-1,M*Y,X is(4-6/(N+1))*Y.

Example:
19*X.
X = 1767263190.0

Try it online here

Are you redefining the * symbol here?

@PaŭloEbermann not exactly. I'm defining a new dyadic predicate called *. I can still use the regular arithmetic one. In the program above M*Y is my defined predicate while (4-6/(N+1))*Y is regular multiplication.

It's slightly shorter than writing it as p(X,Y):- which is nice for code golf.

-6/(N+1) can be +6/ \N. Also, your link seems to direct to someone else's code now

Ceylon, 60 bytes
Integer c(Integer n)=>(1:n).fold(1)((p,i)=>p*(n+i)/i)/(n+1);

This works up to C30, as Ceylon's Integers are signed 64-bit numbers (C31 has overflow, will be calculated as -4050872099593203).
I don't know if Ceylon has any built-in higher mathematical functions, but then importing the right package would probably longer than just calculating this by foot.
// Catalan number C_n
//
// Question:  http://codegolf.stackexchange.com/q/66127/2338
// My answer: http://codegolf.stackexchange.com/a/66425/2338

Integer c(Integer n) =>
        // sequence of length n, starting at 1.
        (1:n)
        // starting with 1, for each element i, multiply the result
        // of the previous step by (n+i) and then divide it by i.
    .fold(1)((p, i) => p * (n + i) / i)
        // divide the result by n+1.
        / (n + 1);

MATL, 8 bytes
2*GXnGQ/

Try it online!
Explanation
2*     % take number n as input and multiply by 2
G      % push input again
Xn     % compute "2*n choose n"
G      % push input again
Q      % add 1
/      % divide

Vyxal r, 6 5 bytes
I had to use the r flag. It's only useful once in a blue moon.
‹?dƈ/

Formula: \$\huge{\frac{{2n \choose n-1}}{n}}\$
Explanation:
‹       decrement n
 ?      push n again
  d     double n
   ƈ    push 2n choose n-1 (because reversed)
    /   divide by n

Try it Online!

tinylisp, 63 bytes
(load library
(d C(q((N)(i N(/(*(C(dec N))(s(* 4 N)2))(inc N))1

Try it online!
Explanation
Uses one of the recurrence relations from Stefano Sanfilippo's C answer:
$$
\begin{align}
C_0 & = 1 \\
C_n & = C_{n-1} \cdot \frac{4n-2}{n+1}
\end{align}
$$
(d C(q((N)(i N(/(*(C(dec N))(s(* 4 N)2))(inc N))1
(d C                                               Define C
    (q((N)                                         as a function of N:
          (i N                                      If N is nonzero:
              (/                               )     Divide
                (*                     )              the product of
                  (C(dec N))                          a recursive call with N-1
                            (s(* 4 N)2)               and (4*N)-2
                                        (inc N)      by N-1
                                                1   Else, return 1

Brachylog, 15 bytes
×₂{g{b|~b}ⁱ⁾Ė}ᶜ

Try it online!
Effectively brute forces all Dyck words of length \$2n\$. I don't know that an adaptation of one of the formulas can't be shorter, but my handful of (failed) attempts have all been roughly this length.
  {          }ᶜ    Count the number of possible ways to:
          ⁱ        iterate
   g       ⁾       starting with the empty list
×₂         ⁾       2n times,
     b             removing the first element
    { |~b}         or adding an element
            Ė      such that the end result is the empty list.

Python 3, 83 63 62 55 bytes
With thanks to Thomas Kwa.
f=lambda x:x<1or x*f(x-1)
c=lambda n:f(2*n)/f(n)/f(n+1)

f is the factorial function. c returns what is equivalent to 2*n C n divided by n+1.

Thanks @ThomasKwa. Where were you when I got stuck on the Bernoulli numbers question? :D

Jolf, 15 13 bytes
Try it here: ze link. You know what? I almost implemented a built-in. I just didn't have time. Le sigh. Also, there's a bug with my combination code, so I have to implement it with permutations. >_ f := n->(2*n)!/((n+1)!*n!);
> f(19);
  1767263190

Python 2, 92 bytes
(lambda f:lambda n:f(2*n)/f(n)/f(n+1))((lambda r:r(r))(lambda r:lambda x:x<1or x*r(r)(x-1)))

Ideone it!
This answer purely serves to demonstrate the power of lambdas.

Alice, 16 bytes
/o
\i@/..2*~C~h:

Try it online!
Explanation
This is a basic framework for arithmetic programs to read and write integer I/O and process them in Cardinal mode:
/o
\i@/...

As for the actual computation, I'm using the usual formula given in the challenge:
..   Make two copies of the input.
2*   Double one copy.
~    Swap it with another copy.
C    Compute the binomial coefficient (2n,n).
~    Swap with the third copy.
h    Increment.
:    Divide to compute C_n = (2n,n)/(n+1)

Brain-Flak, 78 bytes
(([{}])<(({}){}){({}()<(())<>{({}({})<>)<>}>)}><>){({}()<{}>)}{}({}[{}]<>{}{})

Try it online!
Computes the first 2n rows of Pascal's triangle, then returns ((2n-1) C n) - ((2n-1) C (n+1)).

Pyt, 1 byte
Ć

Gets the input n implicity, then uses a builtin to get the nth Catalan number
Try it online!

what in the world-

Factor + math.combinatorics, 28 bytes
[| n | n 2 * n 1 - nCk n / ]

Try it online!

GAP, 28 bytes
c:=n->Binomial(2*n,n)/(n+1);

Try it online!

tinylisp, 72 67 64 bytes
-5 bytes thanks to @Giuseppe
-3 bytes thanks to @DLosc
(load library
(d F factorial
(d g(q((n)(/(F(+ n n))(F n)(F(+ n 1

Try it online!

67 bytes

There's probably a shorter recurrence relation out there, but I'm studying for a spring exam so I'm trying not to procrastinate too much!

(n+1)⋅n!⋅n! => n!⋅(n+1)!: 64 bytes (and much faster)

Thanks for the help @Giuseppe and @DLosc.  I am embarrassed that I missed n!(n+1) = (n+1)!

Nekomata, 6 bytes
+$Ç$→/

Attempt This Online!
+$Ç$→/
+       Add the input with itself
 $      Swap
  Ç     Binomial coefficient
   $    Swap
    →   Increment
     /  Divide

Nekomata + -n, 12 bytes
+Ø$ᵑ{ᵉçt?}Ø=

Attempt This Online!
A port of @Unrelated String's Brachylog answer.
+Ø$ᵑ{ᵉçt?}Ø=
 Ø$             Starting from the empty list
+  ᵑ{    }      Apply the following function 2*input times
     ᵉç             Prepend zero
       t?           Or drop the first element
          Ø=    Check if the result is empty

The -n flag counts the number of possible results.

Jellyfish, 16 12 bytes
p
%C+
 &
>+i

Try it online!

Another 12-byte solution: http://jellyfish.tryitonline.net/#code=cAolKEMKICYKPitp&input=MTk

><>, 29+2 = 31 bytes
:1+$?!\:2-
$/?=1l<*-$4,$6
;\n

Requires the input to be present on the stack at program start, so +2 bytes for the -v flag. Try it online!
Uses the algorithm presented in Stefano Sanfilippo's answer (linky).
The first line compiles n+1, n, n-1, ... , 2, 1 on the stack. The second line, running backwards, computes C(n) = (4 - (6 / (n+1)) * C(n-1). Each iteration reduces the size of the stack by 1, so the remaining number is output when the length of the stack is 1.

Clojure, 45 bytes
#(apply *(for[k(range 2(inc %))](/(+ % k)k)))

Uses the direct formula instead of recursion. Luckily * with zero arguments returns one :)

cQuents, 13 bytes
f2$)/(f$+1)f$

1-indexed. Try it online!
Explanation
:                 Implicit; sets mode to sequence
                  Given input n, output nth term in sequence; otherwise, output sequence
                  Each term in the sequence is equal to:
 f2$)             Factorial (2 * current)
     /            Divided by
      (        )  Group (implicit )
       f$+1)      Factorial (current + 1)
                  Implicit multiplication
            f$)   Factorial (current, implicit )

Excel, 23 bytes
Unimaginative answer:
=COMBIN(2*A1,A1)/(A1+1)

Lua, 86 bytes
c=setmetatable({[0]=1},{__index=function(c,n)c[n]=c[n-1]*(4-(6/(n+1)))print(c[n])end})

Try it online!

Husk, 9 bytes
÷*Π¹Π→¹ΠD

Try it online!
Uses the formula in the description of the OEIS page.
0-indexed.

Japt, 10 bytes
È*4a6/°Y}g

Try it
Alternative
Ñª1 àU zUÄ

Try it

Thunno 2, 6 bytes
Ḍscs⁺÷

Attempt This Online!
Explanation
Ḍscs⁺÷  # Implicit input   ->  n
Ḍ       # Double           ->  2n
 sc     # nCr with input   ->  (2n)C(n)
   s⁺   # Increment input  ->  (2n)C(n), n+1
     ÷  # Divide           ->  ((2n)C(n)) / (n+1)
        # Implicit output

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Code Bots 4: Functional Programming
sheesh, is this really the 4th?  For all you oldcomers, the core challenge is the same, but we are using Java instead of a custom language.  Here are the past three CodeBot challenges, in case you are interested.
The goal of CodeBots is to make your bot as viral as possible.  Each bot carries a Flag, and you need to make sure that your Flag is everywhere.
API
Bots will follow a standardized "protocol", and bots progress through the following steps synchronously:

IPAddress selectMessageRecipient() allows a bot to choose who he wants to send a "friendly" message to.
Message sendMessage() allows a bot to choose the contents of the message he will send out.
processMessage(IPAddress, Message) is called for each message a bot receives.
FunctionType selectFunctionToBlock() blocks a function from being overwritten for the current turn.  See step 7.
IPAddress selectAttackTarget() allows a bot to choose who he wants to DDOS.  A DDOS attack is successful if the bot is targeted by 3 bots at the same time.  If an attack is successful, then each of the attackers can perform step 6 and 7.
readData(ReadonlyBot) allows a bot to read data stored on the vulnerable bot.
FunctionType selectFunctionToReplace() is the crux of this challenge.  You are allowed to select 1 function (of the 8 listed here) to copy over from your bot to their bot.  Then, your function will be called instead of theirs.  If multiple bots select the same function, a random one will be successful.
String getFlag() is called at the end of the game, and should return a string unique to your submission.  Your function should always return the same string.  The submission with the most flags at the end of the game wins.

Storage
You have 3 forms of storage, an AddressBook, a Log, and a Variables.  These forms of storage are local to the bot your function is running on (so if your function gets copied, the contents of each of these objects will be different).  All of these objects can be manually modified or cleared.  To obtain these objects, you have a getter in your class (e.g. getLog()).
The AddressBook stores a list of IPAddress, each with a AddressType, which allows you to classify the different types of addresses.  AddressBook will always contain at least 1 address (if it is cleared, a random one will be added).  Clearing your AddressBook to obtain multiple IPAddresses is not allowed.
The Log stores a list of all actions taken, as well as data about the action.  It also includes a history of all successful attacks (though you don't know which functions they overwrote)
The Variables object allows you to store string variables attached to a string name.  On game start, Variables will contain a single variable, ID, which contains a randomly generated ID that is unique to your bot type.
You also have other access functions:

int getTurnNumber() returns an integer with the current turn
bool functionsMatch(ReadonlyBot, FunctionType) tests to see if the ReadonlyBot's function matches yours
IPAddress personalAddress() returns your IPAddress

How to implement

You can obtain the code from Github
Add your bot to the \bots folder, and then add a reference to your bot in controller\CodeBotFactory.java
Your bot must extend codebots.bot.CodeBot or codebots.bots.DefaultCodeBot
You need Java 8 if you want to run the controller.
You can run the code (assuming you are in the /src folder) using javac codebots\*.java to compile, then java codebots.Main to run.
You may not have any non-constant member variables in your class
Reflection is not allowed.
Forms of communication between bots (of the same or different types) outside of the methods listed above is not allowed.
Dumb and/or Suicidal bots are allowed, but all bots should be functionally different than existing entries.
If you want randomness in your bot, use getRandom()
Please try to keep your code efficient.  I've spent a good deal of time profiling and making the controller fast.

Scores

105.2501 Expelliarmus!
104.5803 I'm Helping!
104.2746 Who Am I?
103.8529 Dumb Bot
103.2028 Replacer
102.7045 Chaos
102.4046 Hermit Bot
102.2849 Swarmer
100.5598 Random bot loves you
99.966   Trust in Trust!
99.0185  codebots.bots.DefaultCodeBot
91.2942  codebots.bots.MarkedBot
91.1423  Just your friendly neighborhood mail delivering robot.
89.4645  null

You should probably make Log.LogEntry final, with it not final I can create logs with any information I want ... that only my bot function would be able to read or create.

Can readData access the IpAddress of the bot it is reading?

@TheNumberOne not currently, but I don't see why not.  I don't have the code on me right now, but I'll update the code to change that.

That would simplify SwarmBot slightly.  I have to do a variable-lookup and then address-lookup in order to perform address book modification.

I find it interesting that Chaos makes DisarmBot and MarkedBot trade places on the leader board.

I think there may be some problems with the AddressBook. You put IPAddress objects in a HashMap but they don't implement hashCode() and equals(). This might work, but only if each IPAddress object exists only once. Apart from that the IPAddress objects are sorted by the hash code in the map. This means that simple bots calling getAddressBook().getAddress(0) will get the IPAddress with the smallest hash code, which seems unfair to me, because bots whose IPAddress has a small hash code will be attacked more often than others.

@Sleafar IPAddresses do only exist once, which is very intentional.  The Bot with the smallest IPAddress will be randomized each round, so it should even out.  I've used other methods for random access, but they all cause code slowdown, so I'm ok with that.

@NathanMerrill Should probably override hashCode and equals anyway.  Its good practice.

Except that the default behavior is the one I want. The IP address isn't defined by the string, it's simply a nice visual representation.

Currently on round 7850 out of 10000, getting more accurate scores...

Sorry, for bugging you ... but when are you going to add the getIPAddress function to ReadOnlyBot ?

I can't do it today, but if you code a bot that uses that function, I'll implement it.

Ok :) I'm actually working on one right now. btw, you should probably add hasAttacked to ReadOnlyLogEntry.

Some results after 10000 rounds

@LegionMammal978 its good to see that all of the high rankings match mine exactly.

@TheNumberOne done.

Very interesting challenge, even though I'm quite late to the party. Just an observation: for newcomers, the "Scores" section is rather hard to correlate to the answers at first glance. Having the answer title match or include what getFlag() returns would make that easier (since I'm guessing the scores are generated and the code has no way of knowing what the answer's title is), e.g. instead of just "AmnesiaBot", if it could say "AmnesiaBot - Who Am I?", that would help.

@AmosM.Carpenter yeah, that was fairly annoying, which is why I ended up linking to the questions.

I'm sad to see that my last entry was never run officially, despite out-scoring the current leader at the time. It came in only a day after the leaderboard was last updated in the question. Additionally, there is one other entry that was never run, having been posted 10 days later.

Oh, I didn't realize that that happened!  I don't have time today, but I'll definitely run it tomorrow!

@Draco18s ...This is going to take longer than I thought.  I'm running 10K rounds:  I started 5 hours ago, and I'm on round 3000. I'll have the scores up by tomorrow hopefully :)

@NathanMerrill Dedication! Rivaled only by trichoplax and Formic Functions. ;) Glad its being done, I'd forgotten about it until I mentioned this challenge and noticed.

@Draco18s well, unfortunately, your bot didn't win.  I'm not convinced that this ended up being a good KoTH: there were significant place changes, and I don't know whether it was the two new bots, or simply randomness.

@NathanMerrill Yeah, a sufficiently long-calculation for KOTHs is always a problem. Formic Functs takes 2+ weeks to resolve first place. And that's after Dave went and made his KOTH framework which makes some speed optimizations (such as caching and webworkers). The official Formic Funct controller implemented the caching, speeding things up from "1-3 months" to "1-3 weeks" (before the addition of a new 500 ant bot, which slowed it down again). Trichoplax made a meta post about it not that long ago.

Per this one and Dumb Bot: I never ran it with Hermit in the mix, so that might've changed things, or it was the randomness, or who knows.  But thanks for giving it a bash!

TrustBot
If you send him a message, he will do what it says. If he reads a bot, he will copy the addresses directly into his book. He attacks the bots that the address book says to attack.
package codebots.bots;

import codebots.bot.CodeBot;
import codebots.bot.ReadonlyBot;
import codebots.gameobjects.*;
import java.util.*;

public class TrustBot extends CodeBot {
    @Override
    public IPAddress selectMessageRecipient() {
        AddressBook book = getAddressBook();
        return book.getAddress(getRandom().nextInt(book.size()));
    }

    @Override
    public Message sendMessage() {
        AddressBook book = getAddressBook();
        return new Message(Message.MessageType.INFORM, book.getAddress(getRandom().nextInt(book.size())));
    }

    @Override
    public void processMessage(IPAddress s, Message m) {
        AddressBook book = getAddressBook();
        if(m.getAddress() != null){
            if(m.getType() == Message.MessageType.ATTACK){
                book.add(m.getAddress(), AddressBook.AddressType.TO_ATTACK);
            }
            else if(m.getType() == Message.MessageType.HELP){
                book.add(m.getAddress(), AddressBook.AddressType.TO_DEFEND);
            }
            else if(m.getType() == Message.MessageType.CONFIRM){
                book.add(m.getAddress(), AddressBook.AddressType.TRUSTED);
            }
            else if(m.getType() == Message.MessageType.REJECT){
                book.add(m.getAddress(), AddressBook.AddressType.UNTRUSTED);
            }
            else if(m.getType() == Message.MessageType.AVOID){
                book.remove(m.getAddress());
            }
            else{
                book.add(m.getAddress());
            }
        }else{
            Message msg = new Message(m.getType(), s);
            processMessage(s, msg);
        }
    }

    @Override
    public FunctionType selectFunctionToBlock() {
        return FunctionType.SELECT_FUNCTION_TO_BLOCK;
    }

    @Override
    public IPAddress selectAttackTarget() {
        AddressBook book = getAddressBook();
        List<IPAddress> l;
        l = book.getAddressesOfType(AddressBook.AddressType.TO_ATTACK);
        Iterator<IPAddress> I = l.iterator();
        if(!I.hasNext())
            return book.getAddress(getRandom().nextInt(book.size()));
        return I.next();
    }

    @Override
    public void readData(ReadonlyBot bot) {
        AddressBook myBook = getAddressBook();
        ReadonlyAddressBook hisBook = bot.getAddressBook();
        AddressBook.AddressType[] values = AddressBook.AddressType.values();
        for(int i=0;i<values.length;i++){
            myBook.addAll(hisBook.getAddressesOfType(values[i]), values[i]);
        }
    }

    @Override
    public FunctionType selectFunctionToReplace() {
        return getRandom().nextInt(2)==1?FunctionType.GET_FLAG:FunctionType.SELECT_FUNCTION_TO_BLOCK;
    }

    @Override
    public String getFlag() {
        return "Trust in Trust!";
    }
}

AmnesiaBot
A random bot that injects other bots with memory loss code. Each function starts with code to clear the log, Address Book and Variables. This code will make smart bots lose memory, in an attempt to do away with logic.
package codebots.bots;

import codebots.bot.CodeBot;
import codebots.bot.ReadonlyBot;
import codebots.gameobjects.*;

public class AmnesiaBot extends CodeBot {

    private void clear(){
        getAddressBook().clear();
        getAddressBook().add(getAddressBook().getAddress(0), AddressBook.AddressType.TRUSTED);
        getVariables().clear();
        getLog().clear();
    }

    @Override
    public IPAddress selectMessageRecipient() {
        clear();
        return getAddressBook().getAddress(0);
    }

    @Override
    public Message sendMessage() {
        clear();
        Message.MessageType[] values = Message.MessageType.values();
        return new Message(values[getRandom().nextInt(values.length)], getAddressBook().getAddress(0));
    }

    @Override
    public void processMessage(IPAddress source, Message message) {
        clear();
    }

    @Override
    public FunctionType selectFunctionToBlock() {
        clear();
        return getTurnNumber() % 2 == 0 ?
             FunctionType.GET_FLAG: FunctionType.SELECT_FUNCTION_TO_BLOCK;
    }

    @Override
    public IPAddress selectAttackTarget() {
        clear();
        return getAddressBook().getAddress(0);
    }

    @Override
    public void readData(ReadonlyBot bot) {
        clear();
    }

    @Override
    public FunctionType selectFunctionToReplace() {
        clear();
        FunctionType[] values =  FunctionType.values();
        return values[getRandom().nextInt(values.length)];
        //random gives a 7/8 chance of successes.
    }

    @Override
    public String getFlag() {
        return "Who Am I?";
    }
}

I think this one wins only due to the inability of a smarter script to be capable of remembering anything.  i.e. clearing the Variables object is really damn powerful.

@draco18s this was not really ment to be  a serious answer...

I know! That's why I'm so confused by it. XD

RandomCodeBot
Obligatory random KoTH entry
package codebots.bots;

import codebots.bot.CodeBot;
import codebots.bot.ReadonlyBot;
import codebots.gameobjects.AddressBook;
import codebots.gameobjects.FunctionType;
import codebots.gameobjects.IPAddress;
import codebots.gameobjects.Message;

public class RandomCodeBot extends CodeBot {

    @Override
    public IPAddress selectMessageRecipient() {
        AddressBook book = getAddressBook();
        return book.getAddress(getRandom().nextInt(book.size()));
    }

    @Override
    public Message sendMessage() {
        Message.MessageType[] values = Message.MessageType.values();
        return new Message(values[getRandom().nextInt(values.length)]);
    }

    @Override
    public void processMessage(IPAddress source, Message message) {

    }

    @Override
    public FunctionType selectFunctionToBlock() {
        FunctionType[] values =  FunctionType.values();
        return values[getRandom().nextInt(values.length)];
    }

    @Override
    public IPAddress selectAttackTarget() {
        AddressBook book = getAddressBook();
        return book.getAddress(getRandom().nextInt(book.size()));
    }

    @Override
    public void readData(ReadonlyBot bot) {

    }

    @Override
    public FunctionType selectFunctionToReplace() {
        FunctionType[] values =  FunctionType.values();
        return values[getRandom().nextInt(values.length)];
    }

    @Override
    public String getFlag() {
        return "Random bot loves you";
    }
}

NullBot
His flag is very ... characteristic ...
package codebots.bots;
import codebots.gameobjects.*;
public class NullBot extends DefaultCodeBot {
    public IPAddress selectMessageRecipient() {
        return null;
    }
    public Message sendMessage() {
        return null;
    }
    public IPAddress selectAttackTarget() {
        return null;
    }
    public FunctionType selectFunctionToReplace() {
        return null;
    }
    public FunctionType selectFunctionToBlock() {
        return null;
    }
    public String getFlag(){
        return null;
    }
}

This is also meant to test the controller and the limits of the "dumb bots are allowed" rule.

Technically he doesn't fit the specification, because he doesn't exactly return a String for his flag.

null is a string. ;) Just a fancy string.

This made me recognize a flaw in my spec, which has been specified: "all bots should be functionally different than existing entries"

@NathanMerrill Fixed to more closely follow the spec.

DisarmerBot
DisarmerBot isn't too intelligent. If it receives attack instructions, it will choose a random attackee, otherwise, it will attack a random player. It just overrides their selectFunctionToBlock function to block selectFunctionToBlock.

package codebots.bots;

import codebots.bot.CodeBot;
import codebots.bot.ReadonlyBot;
import codebots.gameobjects.*;

import java.util.ArrayList;
import java.util.List;

public class DisarmerBot extends CodeBot {
    public IPAddress selectMessageRecipient() { return null; }
    public Message sendMessage() { return null; }

    public void processMessage(IPAddress source, Message message) {
        if (message != null && message.getAddress() != null && message.getType() == Message.MessageType.ATTACK)
            getAddressBook().add(message.getAddress());
    }

    public IPAddress selectAttackTarget() {
        AddressBook book = getAddressBook();
        List<IPAddress> attack = book.allAddresses();
        if (attack.size() > 0) {
            IPAddress bot = attack.get(getRandom().nextInt(attack.size()));
            book.clear();
            return bot;
        }
        //Umm...
        book.clear();
        return book.getAddress(0);
    }

    public void readData(ReadonlyBot bot) { getLog().clear(); /*Safety*/ }
    public FunctionType selectFunctionToReplace() { return FunctionType.SELECT_FUNCTION_TO_BLOCK; }
    public FunctionType selectFunctionToBlock() { return FunctionType.SELECT_FUNCTION_TO_BLOCK; }
    public String getFlag() { return "Expelliarmus!"; }
}

You can select the nth address without needing to do allAddresses().  If you look at my random bot, it is doing random address selection.  I've updated your code on Github (for efficiency reasons), but if you feel like it doesn't work, I'm happy to revert it.

Oh, my bad, fixed.

MarkedBot
Marks itself on the first round, and uses that info in later rounds. That way, if another bot gets injected with its attack code, it will be ineffective.
package codebots.bots;

import codebots.bot.CodeBot;
import codebots.bot.ReadonlyBot;
import codebots.gameobjects.*;

public class MarkedBot extends CodeBot {

    @Override
    public IPAddress selectMessageRecipient() {
        Variables v = getVariables();
        AddressBook ab = getAddressBook();
        if(getTurnNumber()==0)
            v.add(v.get("ID"),"true");
        if("true".equals(v.get("hasOurFlag"))){
            ab.remove(ab.getAddress(0));
            v.remove("hasOurFlag");
        }
        return ab.getAddress(0);
    }

    @Override
    public Message sendMessage() {
        return new Message(Message.MessageType.STOP);
    }

    @Override
    public void processMessage(IPAddress source, Message message) {
        if(message.getType() != Message.MessageType.STOP)
            getAddressBook().add(source, AddressBook.AddressType.TO_ATTACK);
    }

    @Override
    public FunctionType selectFunctionToBlock() {
        Variables v = getVariables();
        if("true".equals(v.get(v.get("ID"))))
            return FunctionType.GET_FLAG;
        return FunctionType.SELECT_FUNCTION_TO_BLOCK;
    }

    @Override
    public IPAddress selectAttackTarget() {
        Variables v = getVariables();
        if("true".equals(v.get(v.get("ID"))))
            return getAddressBook().getAddress(0);
        else
            return null;
    }

    @Override
    public void readData(ReadonlyBot bot) {
        Variables v = getVariables();
        if(functionsMatch(bot, FunctionType.GET_FLAG))
            v.add("hasOurFlag", "true");
        else if("false".equals(v.get("hasOurFlag")))
            v.add("hasOurFlag", "false2");
        else
            v.add("hasOurFlag", "false");
    }

    @Override
    public FunctionType selectFunctionToReplace() {
        Variables v = getVariables();
        if("true".equals(v.get(v.get("ID"))))
            if(!v.has("hasOurFlag") || "false".equals(v.get("hasOurFlag")))
                return FunctionType.GET_FLAG;
            else if("false2".equals(v.get("hasOurFlag")))
                return FunctionType.SELECT_FUNCTION_TO_BLOCK;
            else
                return FunctionType.SEND_MESSAGE;
        return FunctionType.SELECT_FUNCTION_TO_REPLACE;
    }

    @Override
    public String getFlag() {
        return this.getClass().getName();
    }
}

I found several bugs in this bot (typos, using == instead of equals) You also found a flaw in my system: you shouldn't be able to create new random IPAddresses.  I've fixed that issue (and removed the code doing it).  You can find the updated code on github

Also, congrats on top spot!

HelperBot isn't very smart.  It only got top because all the other bots were dumb. :P This is probably the first effective bot.

@NathanMerrill Does that mean we are no longer allowed to create forged IPAdresses for deception? (if thats the case i'm gonna need to redesign mine)

A bot never has access to the round intentionally. You may use opponents IP addresses as forgeries, but creating one isn't allowed.  Also, a constant is a variable set at static time or initialization time.

SwarmBot
This not-well-named bot is rather complicated (and the most complicated submitted thus far), but I made an attempt at a bot that systematically replaces all methods of a target before moving on to a new target.  It attempts to identify copies of itself and treat them as allies, periodically checking up on them to insure integrity.  I haven't come up with a better name.
Linking to the github repo branch, as this bot is 340 lines long.
https://github.com/Draco18s/CodeBots4/blob/master/src/codebots/bots/SwarmBot.java
A few interesting points:

Lines 14-24 are simply an unmodifiable list that made it easy to tweak the order in which the bot replaces the methods of its target.  It stores which index its on in Variables and increments each round.  This should follow the "no non-constant variables" rule.
Lines 203-217 deal with ally verification.  We actually don't care that another bot implements all eight of our instructions.  Only four are essential, and if we're missing one on a "trusted" ally, we replace it with our own.
Lines 295-300 were an unexpected boost in effectiveness.  By protecting our Flag on the first two turns of the game we avoid dumb bots replacing our Flag before we have a chance to spread very far.  Waiting longer, however, gives other bots a chance to replace our BlockFunction and that causes performance to degrade (suspected due to RandomBot interfering with allies attempting to undo corruption).
For the longest time during the development of this bot, this bot caused HelperBot to surge ahead, at one point breaching the 130 mark, while this bot languished at the 81-98 range, but having dragged MarkedBot and DefaultBot's effectiveness down several points.
This bot was only possible with the added functionsMatch method.  Without functionsMatch it was impossible to write a bot that could make meaningful decisions, as it was blind.  It could read its targets variables and logs, but know nothing of its target's state.

There are likely still some improvements possible, but I cannot see them.  Lines 198-205 are probably a performance hog, but until the IPAddress class allows addresses to be reconstituted from being stored in Variables, this is necessary (as bots have no means of validating an address, any storage of an invalid address causes the game to wrap a null target in a ReadOnlyBot, throwing NPE).
Edit: Updates 12/12/15
Tweaking some of the parameters on the getTurnNumber() logic allowed for some boosts in performance.  The increase from 5% to 10% in end-game targeting was worth about 15 points, likewise increasing the early-game targeting from 5% to 8%.  Combined this bot can now (almost) survive even when faced with AmnesiaaBot (reaching 2nd with a score of 110, where HelperBot gets to about 117).
Even with these tweaks, it can get unlucky, so for 10 rounds it's score range is approximately 170-185.

Awesome!  It is intentional that you cannot create IPAddresses from strings.

Well, ostensibly, yes! (Or bots will create arbitrary ones to find new bots).  The problem is that if you do the simulation crashes. ;)

Urm, on line 143 you use a non-existing constructor.

@TheNumberOne it was valid when I wrote it. Nathan probably updated the base.

@TheNumberOne update made.  The new IPAddress call should have been a "look up from address book" as I'd done in readData.  I extracted that lookup and fixed line 143.

I now get compile errors on lines 143, 199, 347, 349, and 351. I would suggest specifying a return value for getIPAddress and adding a default return value in case trg == null or the string is not in your address book.

@TheNumberOne I'll have to fix it later, I have been doing editing in a raw text editor as I am away from Eclipse.

@TheNumberOne OK code correctly compiles now.

@NathanMerrill I fixed a logic error that was inadvertently doing the reverse of intended, drastically killing efficiency.  Against any bot other than Amnesia, it reigns supreme now, up at 160-170 efficiency.

DefaultCodeBot
Tries to do reasonable things.  (Override this class if you don't want to implement all of the functions)
package codebots.bots;

import codebots.bot.CodeBot;
import codebots.bot.ReadonlyBot;
import codebots.gameobjects.FunctionType;
import codebots.gameobjects.IPAddress;
import codebots.gameobjects.Message;

public class DefaultCodeBot extends CodeBot {

    @Override
    public IPAddress selectMessageRecipient() {
        return getAddressBook().getAddress(0);
    }

    @Override
    public Message sendMessage() {
        return new Message(Message.MessageType.INFORM);
    }

    @Override
    public void processMessage(IPAddress source, Message message) {

    }

    @Override
    public FunctionType selectFunctionToBlock() {
        return FunctionType.GET_FLAG;
    }

    @Override
    public IPAddress selectAttackTarget() {
        return getAddressBook().getAddress(0);
    }

    @Override
    public void readData(ReadonlyBot bot) {

    }

    @Override
    public FunctionType selectFunctionToReplace() {
        return FunctionType.GET_FLAG;
    }

    @Override
    public String getFlag() {
        return this.getClass().getName();
    }
}

HelperBot
Helper bot does nothing but try to spread its own flag...or at least the flag it is currently carying...
package codebots.bots;

import codebots.bot.CodeBot;
import codebots.bot.ReadonlyBot;
import codebots.gameobjects.FunctionType;
import codebots.gameobjects.IPAddress;
import codebots.gameobjects.Message;

public class HelperBot extends CodeBot {

    @Override
    public IPAddress selectMessageRecipient() {
        getAddressBook().clear();
        return getAddressBook().getAddress(0);
    }

    @Override
    public Message sendMessage() {
        return new Message(Message.MessageType.INFORM);
    }

    @Override
    public void processMessage(IPAddress source, Message message) {

    }

    @Override
    public FunctionType selectFunctionToBlock() {
        return FunctionType.GET_FLAG;
    }

    @Override
    public IPAddress selectAttackTarget() {
        getAddressBook().clear();
        return getAddressBook().getAddress(0);
    }

    @Override
    public void readData(ReadonlyBot bot) {

    }

    @Override
    public FunctionType selectFunctionToReplace() {
        return FunctionType.GET_FLAG;
    }

    @Override
    public String getFlag() {
        return "I'm Helping!";
    }
}

If HelperBot assumes that any method of its own that is overwritten (other than getFlag()) will be overwritten with something better.

DumbBot
Ugh, this feels dirty.  This is likely the only thing that beats AmnesiaBot.  In reality, its just a specialized RandomBot: it gets a random bot in the simulation (via getAddressBook().clear()) and randomly replaces either the Block function or the Flag function.  That's it.  By picking only those two, its flag-spread rate is higher than either AmnesiaBot or HelperBot, but only slightly after 3000 rounds:
Round 2999
105.50666666666666  Dumb Bot
105.07266666666666  Who Am I?
103.541             I'm Helping!
102.94833333333334  Swarmer
102.82033333333334  Chaos
102.82033333333334  Replacer
101.55666666666667  Expelliarmus!
101.25833333333334  Trust in Trust!
100.347             Random bot loves you
99.22233333333334   codebots.bots.DefaultCodeBot
92.62733333333334   codebots.bots.MarkedBot
91.80966666666667   Just your friendly neighborhood mail delivering robot.
90.46933333333334   null

I fiddled around with the replacement function a bit, but in the end, this is the version that was most successful.
package codebots.bots;

import codebots.bot.CodeBot;
import codebots.bot.ReadonlyBot;
import codebots.gameobjects.AddressBook;
import codebots.gameobjects.FunctionType;
import codebots.gameobjects.IPAddress;
import codebots.gameobjects.Message;

public class DumbBot extends CodeBot {

    @Override
    public FunctionType selectFunctionToBlock() {
        return getRandom().nextBoolean()?FunctionType.SELECT_FUNCTION_TO_BLOCK:FunctionType.GET_FLAG;
    }

    @Override
    public IPAddress selectAttackTarget() {
        AddressBook book = getAddressBook();
        book.clear();
        return book.getAddress(getRandom().nextInt(book.size()));
    }

    @Override
    public FunctionType selectFunctionToReplace() {
        return getRandom().nextBoolean()?FunctionType.SELECT_FUNCTION_TO_BLOCK:FunctionType.GET_FLAG;
    }

    @Override
    public void readData(ReadonlyBot bot) {

    }

    @Override
    public IPAddress selectMessageRecipient() {
        AddressBook book = getAddressBook();
        book.clear();
        return book.getAddress(getRandom().nextInt(book.size()));
    }

    @Override
    public Message sendMessage() {
        Message.MessageType[] values = Message.MessageType.values();
        return new Message(values[getRandom().nextInt(values.length)]);
    }

    @Override
    public void processMessage(IPAddress source, Message message) {

    }

    @Override
    public String getFlag() {
        return "Dumb Bot";
    }
}

Chaos
He frees all flags from the tyranny of being blocked.
package codebots.bots;

import codebots.bot.ReadonlyBot;
import codebots.gameobjects.FunctionType;
import codebots.gameobjects.IPAddress;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by thenumberone on 12/11/15.
 *
 * @author thenumberone
 */
public class Chaos extends DefaultCodeBot{

    private static final String NAME = "Chaos";
    private static final String BLOCK = NAME + ":BLOCK";
    private static final String ATTACK = NAME + ":ATTACK";
    private static final String REPLACE = NAME + ":REPLACE";
    private static final String READ = NAME + ":READ";
    private static final String FLAG = NAME + ":FLAG";
    private static final String SELECT = NAME + ":SELECT";
    private static final String SEND = NAME + ":SEND";

    private static final Map<String, FunctionType> commands;

    private static final String[] REPLACEMENT_ORDER = {
            BLOCK,
            FLAG,
            REPLACE,
            READ,
            ATTACK,
    };

    private static final String DEFAULT = BLOCK;
    private static final String BLOCK_FUNCTION = BLOCK;

    static {
        Map<String, FunctionType> c = new HashMap<>();
        c.put(BLOCK, FunctionType.SELECT_FUNCTION_TO_BLOCK);
        c.put(ATTACK, FunctionType.SELECT_ATTACK_TARGET);
        c.put(REPLACE, FunctionType.SELECT_FUNCTION_TO_REPLACE);
        c.put(READ, FunctionType.READ_DATA);
        c.put(FLAG, FunctionType.GET_FLAG);
        c.put(SELECT, FunctionType.SELECT_MESSAGE_RECIPIENTS);
        c.put(SEND, FunctionType.SEND_MESSAGE);
        commands = Collections.unmodifiableMap(c);
    }

    @Override
    public String getFlag() {
        return NAME;
    }

    @Override
    public void readData(ReadonlyBot bot) {
        for (String command : commands.keySet()){
            getVariables().remove(command);
        }
        for (String command : REPLACEMENT_ORDER){
            if (!functionsMatch(bot, commands.get(command))) {
                getVariables().add(command, "");
                return;
            }
        }
    }

    @Override
    public FunctionType selectFunctionToBlock() {
        return commands.get(BLOCK_FUNCTION);
    }

    @Override
    public IPAddress selectAttackTarget() {
        getAddressBook().clear();
        return getAddressBook().getAddress(0);
    }

    @Override
    public FunctionType selectFunctionToReplace() {
        for (String command : REPLACEMENT_ORDER){
            if (getVariables().has(command)) {
                getVariables().remove(command);
                return commands.get(command);
            }
        }
        return commands.get(DEFAULT);
    }
}

Replacer
This entry replaces all selectFunctionToReplace functions with its own selectFunctionToReplace function.
package codebots.bots;

import codebots.bot.ReadonlyBot;
import codebots.gameobjects.FunctionType;
import codebots.gameobjects.IPAddress;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by thenumberone on 12/11/15.
 *
 * @author thenumberone
 */
public class Replacer extends DefaultCodeBot{

    private static final String NAME = "Replacer";
    private static final String BLOCK = NAME + ":BLOCK";
    private static final String ATTACK = NAME + ":ATTACK";
    private static final String REPLACE = NAME + ":REPLACE";
    private static final String READ = NAME + ":READ";
    private static final String FLAG = NAME + ":FLAG";
    private static final String SELECT = NAME + ":SELECT";
    private static final String SEND = NAME + ":SEND";

    private static final Map<String, FunctionType> commands;

    private static final String[] REPLACEMENT_ORDER = {
            REPLACE,
            FLAG,
            READ,
            ATTACK
    };

    private static final String DEFAULT = REPLACE;
    private static final String BLOCK_FUNCTION = FLAG;

    static {
        Map<String, FunctionType> c = new HashMap<>();
        c.put(BLOCK, FunctionType.SELECT_FUNCTION_TO_BLOCK);
        c.put(ATTACK, FunctionType.SELECT_ATTACK_TARGET);
        c.put(REPLACE, FunctionType.SELECT_FUNCTION_TO_REPLACE);
        c.put(READ, FunctionType.READ_DATA);
        c.put(FLAG, FunctionType.GET_FLAG);
        c.put(SELECT, FunctionType.SELECT_MESSAGE_RECIPIENTS);
        c.put(SEND, FunctionType.SEND_MESSAGE);
        commands = Collections.unmodifiableMap(c);
    }

    @Override
    public String getFlag() {
        return NAME;
    }

    @Override
    public void readData(ReadonlyBot bot) {
        for (String command : commands.keySet()){
            getVariables().remove(command);
        }
        for (String command : REPLACEMENT_ORDER){
            if (!functionsMatch(bot, commands.get(command))) {
                getVariables().add(command, "");
                return;
            }
        }
    }

    @Override
    public FunctionType selectFunctionToBlock() {
        return commands.get(BLOCK_FUNCTION);
    }

    @Override
    public IPAddress selectAttackTarget() {
        getAddressBook().clear();
        return getAddressBook().getAddress(0);
    }

    @Override
    public FunctionType selectFunctionToReplace() {
        for (String command : REPLACEMENT_ORDER){
            if (getVariables().has(command)) {
                getVariables().remove(command);
                return commands.get(command);
            }
        }
        return commands.get(DEFAULT);
    }
}

MailBot
Mailbot only handles messages.  It is not successful at getting its own flag out into the world (average score ~50, slightly higher than nullbot at ~45), but send it a message and it'll forward your address off to someone else.
package codebots.bots;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import codebots.bot.ReadonlyBot;
import codebots.gameobjects.AddressBook;
import codebots.gameobjects.FunctionType;
import codebots.gameobjects.IPAddress;
import codebots.gameobjects.Message;

public class MailBot extends DefaultCodeBot {
    private final String TEAM = "Just your friendly neighborhood mail delivering robot.";
    private final String TEAMALT = "Mailmain";
    private final List<FunctionType> funcList;
    {
        List<FunctionType> list = new ArrayList<FunctionType>();
        list.add(FunctionType.SELECT_MESSAGE_RECIPIENTS);
        list.add(FunctionType.SEND_MESSAGE);
        list.add(FunctionType.PROCESS_MESSAGE);
        funcList = Collections.unmodifiableList(list);
    }

    @Override
    public IPAddress selectMessageRecipient() {
        AddressBook book = getAddressBook();
        IPAddress ip;
        List<IPAddress> l = book.getAddressesOfType(AddressBook.AddressType.TO_ATTACK);
        if(l.size() > 0) {
            ip = l.get(0);
            book.add(ip,AddressBook.AddressType.UNTRUSTED);
            return ip;
        }
        ip = book.getAddress(getRandom().nextInt(book.size()));
        book.add(ip,AddressBook.AddressType.UNTRUSTED);
        return ip;
    }

    @Override
    public Message sendMessage() {
        AddressBook book = getAddressBook();
        IPAddress ip;

        List<IPAddress> l = book.getAddressesOfType(AddressBook.AddressType.UNTRUSTED);
        if(l.size() > 0) {
            ip = l.get(0);
            book.add(ip,AddressBook.AddressType.TO_DEFEND);
            return new Message(Message.MessageType.INFORM,ip);
        }

        ip = book.getAddress(getRandom().nextInt(book.size()));
        book.add(ip,AddressBook.AddressType.UNTRUSTED);
        return new Message(Message.MessageType.INFORM,ip);
    }

    @Override
    public void processMessage(IPAddress source, Message message) {
        AddressBook book = getAddressBook();
        book.add(source,AddressBook.AddressType.TO_ATTACK);
        if(message.getAddress() != null)
            book.add(message.getAddress(),AddressBook.AddressType.TO_ATTACK);
    }

    @Override
    public FunctionType selectFunctionToBlock() {
        return FunctionType.SEND_MESSAGE;
    }

    @Override
    public IPAddress selectAttackTarget() {
        //Mailbot doesn't attack
        return null;
    }

    @Override
    public void readData(ReadonlyBot bot) { }

    @Override
    public FunctionType selectFunctionToReplace() {
        //if our attack selection gets overwritten,
        //then attack a message-based function
        return funcList.get(getTurnNumber()%3);
    }

    @Override
    public String getFlag() {
        return TEAM;
        //if flag is too long, use:
        //return TEAMALT;
    }
}

I considered saving details so it would forward the whole messsage on to a new bot (content and flag) rather than just the sender's IP, but that would have involved heavy use of Variables without any functional gain, especially considering AmnesiaBot being in play.

Hermit Bot
He lives alone and talks only to himself. If fewer people know who he is, then he will be bothered less. If someone does bother him, he will attack them until someone else bothers him.
package codebots.bots;

import codebots.bot.CodeBot;
import codebots.bot.ReadonlyBot;
import codebots.gameobjects.AddressBook;
import codebots.gameobjects.FunctionType;
import codebots.gameobjects.IPAddress;
import codebots.gameobjects.Message;

public class HermitBot extends CodeBot {

    @Override
    public IPAddress selectMessageRecipient() {
        return personalAddress();//Talks to himself.
    }

    @Override
    public Message sendMessage() {
        Message.MessageType[] values = Message.MessageType.values();
        return new Message(values[getRandom().nextInt(values.length)], personalAddress());
    }

    @Override
    public void processMessage(IPAddress source, Message message) {
        AddressBook book = getAddressBook();
        if(source != personalAddress()){
            //if someone talks to you, put them in your addres book and remove everyone else
            book.clear();
            book.add(source);
            book.remove(0);
        }
    }

    @Override
    public FunctionType selectFunctionToBlock() {
        return getTurnNumber() % 3 == 0 ?
                FunctionType.SELECT_FUNCTION_TO_BLOCK: FunctionType.GET_FLAG;
    }

    @Override
    public IPAddress selectAttackTarget() {
        AddressBook book = getAddressBook();
        return book.getAddress(getRandom().nextInt(book.size()));
    }

    @Override
    public void readData(ReadonlyBot bot) {
        Variables v = getVariables();
        if(functionsMatch(bot, FunctionType.SELECT_FUNCTION_TO_BLOCK))
            v.add("Block Dif","A");
        if(functionsMatch(bot, FunctionType.GET_FLAG))
            v.add("Flag Dif","B");
        if(functionsMatch(bot, FunctionType.SELECT_MESSAGE_RECIPIENTS))
            v.add("Targ Dif","C");

    }

    @Override
    public FunctionType selectFunctionToReplace() {
        Variables v = getVariables();
        FunctionType r = getRandom().nextBoolean()?FunctionType.SELECT_FUNCTION_TO_REPLACE: FunctionType.READ_DATA;

        if(v.has("Targ Dif"))
            r = FunctionType.SELECT_MESSAGE_RECIPIENTS;
        if(v.has("Flag Dif") && getTurnNumber() % 3 == 0)
            r = FunctionType.GET_FLAG;
        if(v.has("Block Dif"))
            r = FunctionType.SELECT_FUNCTION_TO_BLOCK;
        v.clear();
        return r;
    }

    @Override
    public String getFlag() {
        return "Hermit Bot";
    }
}

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/