text:
Let's play Meta tic-tac-toe!
 Lets play a game of Meta tic-tac-toe!
This is a king-of-the-hill tournament of Meta tic-tac-toe. The rules of Meta tic-tac-toe are as follows:

All of the regular rules of tic-tac-toe apply.
There are nine boards arranged to make one master board. Like so:
0|1|2 || 0|1|2 || 0|1|2
----- || ----- || -----
3|4|5 || 3|4|5 || 3|4|5
----- || ----- || -----
6|7|8 || 6|7|8 || 6|7|8
========================
0|1|2 || 0|1|2 || 0|1|2
----- || ----- || -----
3|4|5 || 3|4|5 || 3|4|5
----- || ----- || -----
6|7|8 || 6|7|8 || 6|7|8
========================
0|1|2 || 0|1|2 || 0|1|2
----- || ----- || -----
3|4|5 || 3|4|5 || 3|4|5
----- || ----- || -----
6|7|8 || 6|7|8 || 6|7|8

board 0 refers to the top left board, board 1 refers to the top middle board... like this
0|1|2
-----
3|4|5
-----
6|7|8

If I say board 3, tile 4, that means the center tile of the board on the middle left.
You are only allowed to move in one of the smaller boards.
If you win one of the smaller boards, that entire board counts as your tile.
If one of the boards becomes filled before either bot has won it, it counts as nobodies tile.
Whoever wins the master board wins!

However, there is an important twist. Let's say I go in board 7, tile 2. That means on your turn, you can only go in board 2. Then let's say you go in board 2, tile 5. Now on my turn, I can only go in board 5. Let's say that board 1 is full. (There are no more spots left, or one of us has already won board 1) Now if I go in board 5, tile 1, you can go in any of the boards you want.
These rules can be regarded as:

You must play in the board corresponding to the position played by the previous player.

If X plays in board 2, tile 5; O must play in board 5

If the target board is full (a tie) or already has a victor, the next move is unconstrained.
A board with a winner may not be played into, even on an unconstrained move.

If this is a little bit confusing, you can try it online here. (make sure to switch from "first tile wins" to "3 tiles in a row")
Now here are the rules of the challenge.

You must write a bot that plays this game.
Bot 1 is Xs, and it gets to go first. It will be called with these command line arguments (without the stuff in parentheses):
X         (whose turn)
--------- (board 0)
--------- (board 1)
--------- (board 2)
--------- (board 3)
--------- (board 4)
--------- (board 5)
--------- (board 6)
--------- (board 7)
--------- (board 8)
--------- (master board)
xx        (last move)

The first character represents who the bot is. In this case, bot 1 plays as X. The next 9 lines refers to the 9 boards. The 11th line refers to the master board. The "xx" is the last move. Now, bot1 must print two numbers between 0 and 8. Number 1 is the board your bot is moving in, and number 2 is the tile in said board. The controller will keep track of this move. Let's say bot 1 prints 38. Now the board will look like this:
 | |  ||  | |  ||  | |
----- || ----- || -----
 | |  ||  | |  ||  | |
----- || ----- || -----
 | |  ||  | |  ||  | |
==========================
 | |  ||  | |  ||  | |
----- || ----- || -----
 | |  ||  | |  ||  | |
----- || ----- || -----
 | |X ||  | |  ||  | |
==========================
 | |  ||  | |  ||  | |
----- || ----- || -----
 | |  ||  | |  ||  | |
----- || ----- || -----
 | |  ||  | |  ||  | |

and bot2 will be called with these arguments:
O
---------
---------
---------
--------X
---------
---------
---------
---------
---------
---------
38

Now bot 2 must move in board 8 (because bot1 placed an x in tile 3). Let's say bot2 prints 84. Now the board looks like this.
 | |  ||  | |  ||  | |
----- || ----- || -----
 | |  ||  | |  ||  | |
----- || ----- || -----
 | |  ||  | |  ||  | |
==========================
 | |  ||  | |  ||  | |
----- || ----- || -----
 | |  ||  | |  ||  | |
----- || ----- || -----
 | |X ||  | |  ||  | |
==========================
 | |  ||  | |  ||  | |
----- || ----- || -----
 | |  ||  | |  ||  |O|
----- || ----- || -----
 | |  ||  | |  ||  | |

now bot1 is going to be called with these arguments:
X
---------
---------
---------
--------X
---------
---------
---------
---------
----0----
---------
84

Now bot1 must move in board 4. However, bot1 is a naughty little bot, and decides to move in board 3. It prints '30'. The board does not change at all. The master bot keeps track of this. Now bot2 will be called with these arguments:
O
---------
---------
---------
--------X
---------
---------
---------
---------
----0----
---------
xx

Now bot 2 can go anywhere it wants (except for 38 and 84, of course). This continues until somebody wins 3 of the master boards in a row. Then, there is a second matchup where bot2 is X and gets to go first.
This repeats until every single bot has played every other bot.

Scoring
The scoring works like this:
The winner of a each match gets 100 + number of open spots points. That way, it is more valuable if your bot wins quickly. Every time your bot makes an invalid move, it loses 1 point. If after 250 rounds, neither bot has won, each bot loses 10 points, and we go on to the next round.

Everything will be put into a directory that contains

The controller bot. This is a C++ program that I have written. You can look at the controller bot source code here. Please let me know if you see something that isn't right with the controller.
A text file named instructions.txt This file will look something like this:
[Total number of bots that are competing]

[bot1Name] [bot1 command to run]
[bot2Name] [bot2 command to run]
...

A folder for each bot. This folder will hold your program (Whether it's a script or a binary) and ONE text file named data.txt that your bot can read and write whatever it wants to.

Technical specifications and rule clarifications

Any bot that attempts to read/write something from anywhere not inside of it's folder will be kicked from the game.
Your program must be able to run on a macbook running Yosemite. Currently supported languages are python (2.7.9 and 3.4.2), C/C++, objective-C, perl, ruby, bash, PHP, Java, C#, javascript and Haskell. There are a lot more, but these are just the ones I can think of right now. I will add more as time goes on. If you want to compete in a specific language, message me or comment, and I'll add it to the list if possible.
If a board is won, but there is still space, you still cannot move into one of the open spots.
Note that the working directory of your submission will be the directory that contains the controller and all the other bots, NOT the directory that contains your bot.
Please post along with your controller bot code the correct command to compile (if applicable) and to run your bot. Most of this will be done from the OS X terminal, which is fairly similar to a linux terminal.
Bots must complete in under a second. Unfortunately, I am not quite competent enough to add a timer to the controller bot. However, I will manually time the bots.

Results!
Well, I was right. I forgot to make the controller bot check to see if the masterBoard is full. If the masterBoard is full, then EVERY move is invalid, but it continues to call the bots, which is probably why there were so many invalid moves. I have it fixed now. Here are the official results with the most current version of all of the bots.
Bot 1, goodRandBot, has 1 wins and made 0 illegal moves, for a total of 133 points.
Bot 2, naiveBot, has 3 wins and made 48 illegal moves, for a total of 361 points.
Bot 3, depthBot, has 5 wins and made 0 illegal moves, for a total of 664 points.
Bot 4, middleBot, has 1 wins and made 20 illegal moves, for a total of 114 points.

With 4 bots, This program took 477.471 seconds to finish.

Depth Bot is the reigning champion! At least, for right now.

As an aside, have you ever looked at Fire and Ice (a pbem version at  gamerz.net) - there are some tic-tac-toe elements to it... though this also reminded me of scribe.

9 likes and 40 views. I'm impressed!

You might want to put a limit on the response time of bots, or bots may take 3 minutes per move while searching all possible future moves.

I've added some rule clarifications to the bit about next move. I have a concern about the data format and one of the rules.  Rule 5 from the first section: "If one of the boards becomes filled, it counts as nobodies tile." Is this filled without a winner? i.e. if someone wins the tile previously, and it becomes filled is it nobodies tile? Furthermore, if the bots are stateless (they appear to be) with the state passed in, how does the winner of a board that is XXX000--- get transmitted? or is that a 'nobody gets it despite O having won it first'?

@MichaelT the winner of the board is passed in on the 11th line. I'll edit this part to make it a little bit more clear, however your edit is incorrect. "If a board is won, but there is still space, you still cannot move into one of the open spots."

@DJMcMayhem ok, so the board is frozen as soon as one player wins? A ha! That's in "or one of us has already won board 1"  Will correct.

@Ypnypn yes, this is intentional. The boards are 0-indexed, and the 9th (or tenth?) board is the master board. Does my edit make it more clear?

5. If one of the boards becomes filled, it counts as nobodies tile. This is only if someone didn't win it on the last move on that board, right?

@mbomb007 yes, I'll edit that in.

@DJMcMayhem: Is Haskell allowed as well?

@CommuSoft Probably. I have never run haskell on my laptop before, so I can't guarantee it, but I don't see any reason why not. Let me test it real quick and then I'll add it to the list of "officially" supported languages.

Is there a deadline for this? Meaning, a date for the final tournament? Not sure yet if I should give it a shot, but I certainly wouldn't want to invest the time and then miss the tournament.

@RetoKoradi not really. I guess it just depends on how many submissions I get.

@DJMcMayhem Did you use the current version of my submission? I (and perhaps others) made edits to fix some bugs which might explain the illegal moves.

Python 2.7, Depth
An alpha-beta pruning implementation without anything too fancy. It does try to order moves in a less naive way to maximize the alpha-beta eliminations. I will probably try to speed it up, but honestly I don't know how competitive Python can be if it comes down to a question of speed.
class DepthPlayer:
    def __init__(self,depth):
        self.depth = depth

    def score(self,master,subs,last_move):
        total = 0
        for x in range(3):
            for y in range(3):
                c = master[3*y+x]
                if c == 0:
                    total += sum(subs[3*y+x])
                else:
                    total += c*10
                    for (dx,dy) in [(1,-1),(1,0),(0,1),(1,1)]:
                        if x+dx<=2 and 0<=y+dy<=2 and master[3*(y+dy)+(x+dx)] == c:
                            total += c*10
        if last_move is None or master[last_move[1]] != 0 or 0 not in subs[last_move[1]]:
            total += 5
        return total

    def winner(self,board):
        for y in range(3):
            row = board[3*y:3*y+3]
            if 0!=row[0]==row[1]==row[2]:
                return row[0]
        for x in range(3):
            col = board[x:9:3]
            if 0!=col[0]==col[1]==col[2]:
                return col[0]
        if 0!=board[0]==board[4]==board[8]:
            return board[0]
        if 0!=board[2]==board[4]==board[6]:
            return board[2]

        return 0

    def parse(self,input):
        lines = input.split('\n')
        team = lines[0]
        subs_str = lines[1:10]
        master_str = lines[10]
        last_move_str = lines[11]

        master = [1 if c==team else 0 if c=='-' else -1 for c in master_str]
        subs = [[1 if c==team else 0 if c=='-' else -1 for c in sub_str] for sub_str in subs_str]
        if last_move_str == 'xx':
            last_move = None

        else:
            last_move = [int(c) for c in last_move_str]
        return master,subs,last_move

    def alphabeta(self, master,subs,last_move, depth, alpha, beta, player):
        if depth == 0:
            return self.score(master,subs,last_move),None
        w = self.winner(master)
        if w != 0:
            return w*1000,None

        if player:
            v = -10000
            best = None
            for n_master,n_subs,n_last_move in self.all_moves(master,subs,last_move,1):
                nv,_ = self.alphabeta(n_master,n_subs,n_last_move, depth-1, alpha, beta, False)
                if nv>v:
                    v = nv
                    best = n_last_move
                alpha = max(alpha, v)
                if beta <= alpha:
                    break
            return v,best
        else:
            v = 10000
            best = None
            for n_master,n_subs,n_last_move in self.all_moves(master,subs,last_move,-1):
                nv,nb = self.alphabeta(n_master,n_subs,n_last_move, depth-1, alpha, beta, True)
                if nv<v:
                    v = nv
                    best = n_last_move
                beta = min(beta, v)
                if beta <= alpha:
                    break
            return v,best

    def make_move(self,master,subs,move,player):
        n_subs = [sub[:] for sub in subs]
        n_master = master[:]
        n_subs[move[0]][move[1]] = player
        if n_master[move[0]] == 0:
            n_master[move[0]] = self.winner(n_subs[move[0]])
        return n_master,n_subs,move

    def sub_moves(self,board):
        first = []
        second = []
        third = []
        for i in range(9):
            if board[i] != 0:
                continue
            y,x = divmod(i,3)
            c=-2
            if   x==0 and 0!=board[i+1]==board[i+2]>c: c=board[i+1]
            elif x==1 and 0!=board[i-1]==board[i+1]>c: c=board[i-1]
            elif x==2 and 0!=board[i-2]==board[i-1]>c: c=board[i-2]
            if   y==0 and 0!=board[i+3]==board[i+6]>c: c=board[i+3]
            elif y==1 and 0!=board[i-3]==board[i+3]>c: c=board[i-3]
            elif y==2 and 0!=board[i-6]==board[i-3]>c: c=board[i-6]
            if i in [0,4,8] and 0!=board[(i+4)%12]==board[(i+4)%12]>c: c=board[i-6]
            if i in [2,4,6] and 0!=board[6 if i==2 else i-2]==board[2 if i==6 else i+2]>c: c=board[i-6]

            if c==-2:   third.append(i)
            elif c==-1: second.append(i)
            else:       third.append(i)
        return first+second+third

    def all_moves(self,master,subs,last_move,player):
        if last_move is not None and master[last_move[1]]==0 and 0 in subs[last_move[1]]:
            for i in self.sub_moves(subs[last_move[1]]):
                yield self.make_move(master,subs,[last_move[1],i],player)

        else:
            for j in range(9):
                if master[j]==0 and 0 in subs[j]:
                    for i in self.sub_moves(subs[j]):
                        yield self.make_move(master,subs,[j,i],player)

    def move(self,master,subs,last_move):
        return self.alphabeta(master,subs,last_move, self.depth, -10000, 10000, True)[1]

    def run(self,input):
        result = self.move(*self.parse(input))
        if result:
            return str(result[0])+str(result[1])

def print_board(subs,player):
    string = ""
    for row in range(9):
        for sub in subs[row/3*3:row/3*3+3]:
            for c in sub[row%3*3:row%3*3+3]:
                string += "-XO"[c*(1 if player=='X' else -1)]
            string += ' '
        if row%3 == 2:
            string += '\n'
        string += '\n'
    print string

def to_string(master,subs,last_move,player):
    string = player+'\n'
    for sub in subs:
        for c in sub:
            string += "-XO"[c*(1 if player=='O' else -1)]
        string += '\n'
    for c in master:
        string += "-XO"[c*(1 if player=='O' else -1)]
    string += '\n'+str(last_move[0])+str(last_move[1])
    return string

import sys
command = '\n'.join(sys.argv[1:])
print DepthPlayer(8).run(command)

To run it, you can simply do python Depth.py <input>, though I would suggest using pypy as it speeds it up noticeably.
Also I don't know how fast your system is but you can modify the first argument to DepthPlayer at the very end to be higher if it can still run in the specified time (on my system it completed almost all things very quickly with a depth of 7 or 8, but there were a few cases that were near or above a second so I set it to 6 to be safe).

python's sys.argv doesn't return a newline separated string. It gives a list of strings in this format: ['Depth.py', 'X', '---------', '---------', ...] I fixed it by editing the last two lines to this command = '\n'.join(sys.argv[1:]) print DepthPlayer(6).run(command) I hope you don't mind.

@DJMcMayhem Oh thanks I didn't test that last line.

Java, Naive
If possible, it wins. Otherwise, it prevents an opponent from winning.
import java.util.Arrays;

public class Naive {

    public static void main(String[] args) {

        char[][] board = new char[9][9];
        for (int i = 0; i < 9; i++) {
            board[i] = args[i + 1].toCharArray();
        }
        char[] metaBox = args[10].toCharArray();

        char a = args[0].charAt(0),
                b = (char) ('X' + 'O' - a);

        int legalBox = args[11].charAt(1) - '0';
        boolean legalAnywhere = legalBox == 'x' - '0';
        if (!legalAnywhere) {
            if (wins(board[legalBox], 'X') || wins(board[legalBox], 'O')) {
                legalAnywhere = true;
            }
        }
        a:
        if (!legalAnywhere) {
            for (int i = 0; i < 9; i++) {
                if (board[legalBox][i] == '-') {
                    break a;
                }
            }
            legalAnywhere = true;
        }

        if (legalAnywhere) {
            chooseMove(board, metaBox, a, b);
        } else {
            chooseMove(board, metaBox, a, b, legalBox);
        }
    }

    static boolean canWinWith(char[] box, char c) {
        for (int i = 0; i < 9; i++) {
            if (wins(box, i, c)) {
                return true;
            }
        }
        return false;
    }

    static boolean wins(char[] box, int move, char c) {
        char[] copy = Arrays.copyOf(box, 9);
        copy[move] = c;
        return wins(copy, c);
    }

    static boolean wins(char[] box, char c) {
        return (box[0] == c && box[1] == c && box[2] == c)
               || (box[3] == c && box[4] == c && box[5] == c)
               || (box[6] == c && box[7] == c && box[8] == c)
               || (box[0] == c && box[3] == c && box[6] == c)
               || (box[1] == c && box[4] == c && box[7] == c)
               || (box[2] == c && box[5] == c && box[8] == c)
               || (box[0] == c && box[4] == c && box[8] == c)
               || (box[2] == c && box[4] == c && box[6] == c);
    }

    static void endWith(int box, int i) {
        System.out.println("" + box + i);
        System.exit(0);
    }

    private static void chooseMove(char[][] board, char[] metaBox, char a, char b, int legalBox) {
        for (int i = 0; i < 9; i++) {
            if (wins(board[legalBox], i, a) && board[legalBox][i] == '-') {
                endWith(legalBox, i);
            }
        }
        for (int i = 0; i < 9; i++) {
            if (wins(board[legalBox], i, b) && board[legalBox][i] == '-') {
                endWith(legalBox, i);
            }
        }
        for (int i = 0; i < 9; i++) {
            if (board[legalBox][i] == '-') {
                if (!canWinWith(board[i], b)) {
                    endWith(legalBox, i);
                }
            }
        }
        for (int i = 0; i < 9; i++) {
            if (board[legalBox][i] == '-') {
                endWith(legalBox, i);
            }
        }
        throw new RuntimeException("No move chosen!");
    }

    private static void chooseMove(char[][] board, char[] metaBox, char a, char b) {
        for (int box = 0; box < 9; box++) {
            for (int i = 0; i < 9; i++) {
                if (wins(board[box], i, a) && board[box][i] == '-') {
                    endWith(box, i);
                }
            }
        }
        for (int box = 0; box < 9; box++) {
            for (int i = 0; i < 9; i++) {
                if (wins(board[box], i, b) && board[box][i] == '-') {
                    endWith(box, i);
                }
            }
        }
        for (int box = 0; box < 9; box++) {
            for (int i = 0; i < 9; i++) {
                if (board[box][i] == '-') {
                    if (!canWinWith(board[i], b)) {
                        endWith(box, i);
                    }
                }
            }
        }
        for (int box = 0; box < 9; box++) {
            for (int i = 0; i < 9; i++) {
                if (board[box][i] == '-') {
                    endWith(box, i);
                }
            }
        }
        throw new RuntimeException("No move chosen!");
    }
}

You'll have to forgive me for being a java noob, but how do I run this from the parent directory? I have Naive.class in a directory named naiveBot inside the main directory.

@DJMcMayhem I don't have access to a Mac, but on Windows, you can just run the java Naive <args> command, assuming the environment variables include the pointer to C:\Program Files\Java\jdk1.8.0\bin. I hope this helps.

Alright, I'll figure it out.

@DJMcMayhem If you didn't figure it out already, it's java -classpath naiveBot Naive ;)

@Ypnypn If legalAnywhere is true, your submission fails because you try  to use boards that are already won by a player.

Python 2, MiddleBot
MiddleBot likes the middle. Before the central game (4) is won, it will try to grab the centre square of as many games as possible, forcing the opponent back to the middle game again and again.
Once this is done, it tries to win any games it can, or just fills the first available space if not (need to work on its late game, I think)
from random import randint
import sys
command_in = '\n'.join(sys.argv[1:])
class MiddleBot:

    def scan_in(self,the_game):

        lines = the_game.split('\n')
        self.us = lines[0]
        if self.us == 'X':
            self.them = 'O'
        else:
            self.them = 'X'
        self.games = lines[1:10]
        self.metagame = lines[10]
        self.last_move = lines[11]

        try:
            self.sub_board = int(self.last_move[1])
        except ValueError:
            self.sub_board = self.last_move[1]

    def empty(self,game,target):
        if self.games[int(game)][int(target)] == '-':
            self.emptycell = 1
        else: self.emptycell = 0

    def empty_fill(self,game):
        #checks for next empty space, fills it
        for k in xrange(0,8):
            self.empty(game,k)
            if self.emptycell == 1:
                self.first_empty_space = k
                break
            if self.emptycell == 0:
                game = randint(0,8)
                self.first_empty_space = 4

    def aim_for_target(self,game,target):
        if self.games[int(game)][int(target)] == '-':
            self.move = `game` + `target`
        else:
            self.empty_fill(game)
            self.move = `game` + `self.first_empty_space`

    #define all win conditions
    win = [0]*8
    win[0] = [0,1,2]
    win[1] = [3,4,5]
    win[2] = [6,7,8]
    win[3] = [0,3,6]
    win[4] = [1,4,7]
    win[5] = [2,5,8]
    win[6] = [0,4,8]
    win[7] = [2,4,6]

    #check if current board state is one move away from 'us' winning
    def aim_for_win(self,game):
            for k in xrange(0,len(self.win)):
                if self.games[self.sub_board][self.win[k][0]] == self.games[self.sub_board][self.win[k][1]] == self.us:
                    self.empty(self.sub_board,self.win[k][2])
                    if self.emptycell == 1:
                        self.move = `self.sub_board`+`self.win[k][2]`
                    else:
                        self.empty_fill(self.sub_board)
                        self.move = `self.sub_board`,`self.first_empty_space`
                elif self.games[self.sub_board][self.win[k][0]] == self.games[self.sub_board][self.win[k][2]] == self.us:
                    self.empty(self.sub_board,self.win[k][1])
                    if self.emptycell == 1:
                        self.move = `self.sub_board`+`self.win[k][1]`
                    else:
                        self.empty_fill(self.sub_board)
                        self.move = `self.sub_board`+`self.first_empty_space`
                elif self.games[self.sub_board][self.win[k][1]] == self.games[self.sub_board][self.win[k][2]] == self.us:
                    self.empty(self.sub_board,self.win[k][0])
                    if self.emptycell == 1:
                        self.move = `self.sub_board`+`self.win[k][0]`
                    else:
                        self.empty_fill(self.sub_board)
                        self.move = `self.sub_board`+`self.first_empty_space`
                else:
                    self.empty_fill(self.sub_board)
                    self.move = `self.sub_board`+`self.first_empty_space`

    def play(self):
        #If the middle board is not won, aim for the middle square of each board
        if self.metagame[4] == '-':
            if self.sub_board == 4 or self.sub_board == 'x':
                self.aim_for_target(4,4)
            else:
                self.aim_for_target(self.sub_board,4)
        else:
            #once the middle board is won, pretty much plays randomly, aiming to win if it can, otherwise just filling the first empty space in each subgame
            played = 0
            if self.sub_board == 'x':
                self.sub_board = randint(0,8)
            while played == 0:
                if self.metagame[int(self.sub_board)] == '-':
                    self.aim_for_win(self.sub_board)
                    played = 1
                else:
                    self.sub_board = randint(0,8)
        return self.move

    def run(self,game_board):
        self.scan_in(game_board)
        self.play()
        return self.move

print MiddleBot().run(command_in)

To run it, python MiddleBot.py <input> It seems to happily run under a second for me, so hopefully it will for you as well

Everything runs fine, but FYI, it crashes when the last move is 'xx' which happens at the beginning and every time a bot makes an invalid move.

Oops! Should be fixed now. Forgot to test the 'xx' case in that iteration, sorry!

Also made an edit - it would crash if a board had been filled without a winner and it was asked to play there

Might as well throw my own bot into the mix.
python 2, goodRandomBot
import sys
from random import choice

args = sys.argv
if len(args) < 13:
    print ("I can't work with this!\n")
    sys.exit()

whoAmI = args[1];
masterBoard = list(args[11])
board = []
for i in range(2, 11):
    board.append(list(args[i]))

oppMove = args[12]

def findAllValidMoves(board, masterBoard):
    validMoves = []
    for row in range(9):
        if masterBoard[row] != '-':
            continue
        for col in range(len(board[row])):
            if board[row][col] == '-':
                validMoves.append(str(row) + str(col))
    return validMoves

validMoves = []
if oppMove == "xx" or masterBoard[int(oppMove[1])] != "-":
    validMoves = findAllValidMoves(board, masterBoard)

else:
    row = int(oppMove[1])
    for col in range(len(board[row])):
        if board[row][col] == '-' and masterBoard[row] == "-":
            validMoves.append(str(row) + str(col))

if (validMoves == []):
    validMoves = findAllValidMoves(board, masterBoard)

print choice(validMoves)

This bot doesn't care where it moves, as long as it is a valid move. Picks at random from all valid moves, and makes an average of 0 invalid moves.


text:
Generate Keyboard Friendly Numbers
Most common computer keyboard layouts have the decimal digit keys
1234567890
running along at their top, above the keys for letters.
Let a decimal digit's neighborhood be the set of digits from its own digit key and from the digit keys immediately to the left and right, if they exist.
For example, the neighborhood of 0 is {0, 9}, and the neighborhood of 5 is {4, 5, 6}.
Now, define a keyboard friendly number as a positive integer (in decimal form with no leading zeros) that can be typed on the layout above such that every consecutive digit in the number after the first digit is in the neighborhood of the preceding digit.

All single digit numbers (1-9) are trivially keyboard friendly.
A number such as 22321 is keyboard friendly because every digit (not counting the first) is in the neighborhood of the digit just before.
A number such as 1245 is not keyboard friendly because 4 is not in the neighborhood of 2 (nor vice versa).
A number such as 109 is not keyboard friendly because 0 is not in the neighborhood of 1. The ends do not loop around.

By putting the keyboard friendly numbers in order from smallest to largest, we can create an integer sequence.
Here are the first 200 terms of the keyboard friendly numbers sequence:
N KFN(N)
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 11
11 12
12 21
13 22
14 23
15 32
16 33
17 34
18 43
19 44
20 45
21 54
22 55
23 56
24 65
25 66
26 67
27 76
28 77
29 78
30 87
31 88
32 89
33 90
34 98
35 99
36 111
37 112
38 121
39 122
40 123
41 211
42 212
43 221
44 222
45 223
46 232
47 233
48 234
49 321
50 322
51 323
52 332
53 333
54 334
55 343
56 344
57 345
58 432
59 433
60 434
61 443
62 444
63 445
64 454
65 455
66 456
67 543
68 544
69 545
70 554
71 555
72 556
73 565
74 566
75 567
76 654
77 655
78 656
79 665
80 666
81 667
82 676
83 677
84 678
85 765
86 766
87 767
88 776
89 777
90 778
91 787
92 788
93 789
94 876
95 877
96 878
97 887
98 888
99 889
100 890
101 898
102 899
103 900
104 909
105 987
106 988
107 989
108 990
109 998
110 999
111 1111
112 1112
113 1121
114 1122
115 1123
116 1211
117 1212
118 1221
119 1222
120 1223
121 1232
122 1233
123 1234
124 2111
125 2112
126 2121
127 2122
128 2123
129 2211
130 2212
131 2221
132 2222
133 2223
134 2232
135 2233
136 2234
137 2321
138 2322
139 2323
140 2332
141 2333
142 2334
143 2343
144 2344
145 2345
146 3211
147 3212
148 3221
149 3222
150 3223
151 3232
152 3233
153 3234
154 3321
155 3322
156 3323
157 3332
158 3333
159 3334
160 3343
161 3344
162 3345
163 3432
164 3433
165 3434
166 3443
167 3444
168 3445
169 3454
170 3455
171 3456
172 4321
173 4322
174 4323
175 4332
176 4333
177 4334
178 4343
179 4344
180 4345
181 4432
182 4433
183 4434
184 4443
185 4444
186 4445
187 4454
188 4455
189 4456
190 4543
191 4544
192 4545
193 4554
194 4555
195 4556
196 4565
197 4566
198 4567
199 5432
200 5433

Challenge
Write a program or function that takes a positive integer N (via stdin/command line/function arg) and prints (to stdout) or returns the Nth term in the keyboard friendly numbers sequence.
For example, if the input is 191, the output should be 4544.
The output may optionally have a single trailing newline.
The shortest submission in bytes wins.

Random fact: OEIS has a related sequence for numpads

Thanks, @Sp3000. I scrolled down to here wondering that very thing.

Pyth, 27 24 bytes
uf!f/h-FY3.:metsd`T2hGQ0

Demonstration.
Improvements to the original:

Using metd, instead of .r ... _UJ: 2 less bytes. 1 direct, 1 for not having to use J.
Using s and `T instead of JT10: 1 less byte.

We start with the string representation of a number: `T.
Then, we convert the string to a list of digits, and rotate the digits digits backwards by one, (9876543210) with metsd. Then, we take the 2 element subsequences with .: ... 2. These subsequences are filtered on /h-FY3. This expression corresponds to ((a-b)+1)/3, which is zero if and only if the difference between a and b is at most 1. Thus, the filtered list will be empty if and only if the number is keyboard friendly. With !, the result is true only if the number is keyboard friendly.
f ... hG filters upwards from G+1 until the result is true, giving the first keyboard friendly number at G+1 or above. u ... Q0 applies this function to its own output Q times, starting from 0, where Q is the input. This gives the Qth Keyboard Friendly Number, as desired.

Python 3, 112 102 bytes
f=lambda n,k=0:n+1and f(n-all(-2<~-int(a)%10-~-int(b)%10<2for a,b in zip(str(k),str(k)[1:])),k+1)or~-k

We keep track of the count of friendly numbers still needed to find in n and the last checked number in k.
5 and 5 bytes saved thanks to @isaacg and @Sp3000.

Use a lamba expression instead of a def return. Lambas allow defaults.

@isaacg Thanks, I didn't know how to recurse with lambda.

Ah right. Unary ops come first. My mistake.

You can drop the [:-1] in the zip

CJam, 29 28 bytes
ri_4#{AbAfe|_1>.-W<3,:(-!},=

Try it online in the CJam interpreter.

Is there an easy proof that the upper limit of N-th friendly number is N**2

Haven't found one yet. The proof for N ** 4 is pretty easy, since there are at least 2 ** k KFN below 10 ** k < 16 ** k. Replacing _* with 4# wouldn't alter the byte count, but it would make the code horribly inefficient.

Then isn't your code incorrect for some large input number ?

Hopefully not. But I'll change it until I know. grumbles

CJam, 34 31 bytes
3 bytes saved by Dennis.
I'm sure the gap to Pyth can be closed somehow, but I don't have time right now to golf this further...
0q~{{)_s:_2ew{A,s(+f#~m2/},}g}*

Test it here.

You can replace )_++ with :_ to save 2 chars and -z1> with m2/ to save another.

@Dennis Oh, those are nice, thank you!

JavaScript (ES6), 95
F=k=>{for(i=0;k;k-=(f=1,p=NaN,[for(d of''+i)(d=(8-~d)%10,d-p>1|p-d>1?f=0:p=d)],f))++i;return i}

Ungolfed
F=k=>{
  for(i=0; k>0; )
  {
    ++i;
    f = 1; // presume i it's friendly
    p = NaN; // initial value so that first comparison gives false
    for(d of ''+i) // loop for each digit of i
    {
      // rotate digits 1->0, 2->1 ... 9->8, 0->9
      // note d is string, ~~ convert to number (golfed: 8-~d)
      d = (~~d+9) % 10
      if (p-d>1 || p-d<-1)
        f = 0 // not friendly
      else
        // this can go in the 'else', if not friendly I don't care anymore
        p = d // move current digit to prev digit
    }
    k -= f // count if it's friendly, else skip
  }
  return i
}

Test : execute snippet in Firefox

F=k=>{
  for(i=0;k;k-=(f=1,p=NaN,[for(d of''+i)(d=(8-~d)%10,d-p>1|p-d>1?f=0:p=d)],f))++i
  return i
}
<input id=N><button onclick="R.value=F(N.value)">-></button><input readonly id=R>

I don't know much JS, but couldn't you do something like abs(p-d)>1 rather than p-d>1|p-d<-1?

@AlexA. The expressions in expanded and golfed are equivalent. Math.abs(p-d)>1 is longer than p-d>1|p-d<-1

Ah, okay. I knew they were equivalent, I just didn't know that you needed the Math. prefix.

Haskell, 90 80 bytes
([x|x<-[0..],all((<2).abs)$zipWith(-)=<<tail$[mod(1+fromEnum c)10|c<-show x]]!!)

This is a function without a name. To use it, call it with a parameter, e.g.:([x|x<-[0..],all((<2).abs)$zipWith(-)=<<tail$[mod(1+fromEnum c)10|c<-show x]]!!) 199 which returns 5432.
How it works:
[x|x<-[0..]           ]  make a list of all integers x starting with 0
           ,             where
             c<-show x   each character in the string representation of x
  mod(1+fromEnum c)10    turned into the number '(ascii+1) mod 10'
 zipWith(-)=<<tail       then turned into a list of differences between neighbor elements
all((<2).abs)            only contains elements with an absolute value less than 2

                   !!    ... take the element given by the parameter (!! is 0
                         based, that's why I'm starting the initial list with 0)

Edit: @Mauris found some bytes to save. Thanks!

Instead of x<-[1..] ... !!n-1, you can do x<-[0..] ... !!n.

And then of course f n=[...]!!n can be f=([...]!!).

I got it down to a single function, eliminating a: f=([x|x<-[0..],all((<2).abs)$zipWith(-)=<<tail$[mod(1+fromEnum c)10|c<-show x]]!!)

@Mauris: wow, thank you! Without a we can eliminate f, too.

Dart, 92 bytes
f(n,[x=0]){t(x)=>x>9?((x+9)%10-((x~/=10)+9)%10).abs()>1||t(x):--n>0;while(t(++x));return x;}

With linebreaks:
f(n,[x=0]){
  t(x)=>x>9?((x+9)%10-((x~/=10)+9)%10).abs()>1||t(x):--n>0;
  while(t(++x));
  return x;
}

See/run it on DartPad

Vyxal, 83 bitsv2, 10.375 bytes
Þ∞'f0₀V¯ȧ2<A;i

Try it Online!
Explanation
Þ∞'f0₀V¯ȧ2<A;i
Þ∞              # Natural numbers
  '         ;   # Filtered by:
   f0₀V         # The list of digits where 0 is replaced with 10, ie [9,0] becomes [9,10]
       ¯        # Consecutive differences between digits
        ȧ2<A    # Are the absolute values of those difference all less than 2
             i  # index (from input)

Created with the help of Luminespire.

Vyxal, 70 bits2, 8.75 bytes: f0₀V¯ȧ2<A)ȯ (vyncoded)

oh thats clever!

Bash + coreutils, 120 bytes
seq $1$1|tr 1-90 0-9|sed 's#.#-&)%B)/3)||(((C+&#g;s/^/(0*((/;s/$/))*0)/'|bc|nl -nln|sed '/1$/d;s/   0//'|sed -n "$1{p;q}"

Some testcases:
$ for i in 1 10 11 99 100 200; do ./kfn.sh $i; done
1
11
12
889
890
5433
$

Batch - 520 Bytes
Shudder.
@echo off&setLocal enableDelayedExpansion&set a=0&set b=0
:a
set/ab+=1&set l=0&set c=%b%
:b
if defined c set/Al+=1&set "c=%c:~1%"&goto b
set/am=l-2&set f=0&for /l %%a in (0,1,%m%)do (
set x=!b:~%%a,1!&set/an=%%a+1&for %%b in (!n!)do set y=!b:~%%b,1!
set z=0&set/ad=x-1&set/ae=x+1&if !e!==10 set e=0
if !d!==-1 set d=9
if !y!==!d! set z=1
if !y!==!e! set z=1
if !y!==!x! set z=1
if !y!==0 if !x!==1 set z=0
if !y!==1 if !x!==0 set z=0
if !z!==0 set f=1)
if !f!==0 set/aa+=1
if %a% NEQ %1 goto :a
echo %b%

Pyth, 19 bytes
e.f.AgL1.aM.+|RTjZT

Try it here.
Note: Uses commit newer than this challenge, so shouldn't be considered as an outgolf of isaacg's answer. This is still competing, though.

JavaScript ES6, 126 bytes
f=n=>{b=s=>[...++s+''].every((e,i,a,p=(+a[i-1]+9)%10)=>i?p==(e=+e?e-1:9)|p-e==1|e-p==1:1)?s:b(s)
for(p=0;n--;)p=b(p)
return p}

Ungolfed code and tests below. This could certainly be improved more.

f=function(n){
  b=function(s){
    return (s+'').split('').every(function(e,i,a){
      e=+e?e-1:9
      p=i?(+a[i-1]+9)%10:e
      return p==e|p-e==1|e-p==1
    })?s:b(s+1)
  }
  for(p=i=0;i<n;i++){
    p=b(p+1)
  }
  return p
}

var input = document.getElementById('n'), results = [];
input.onchange = function(){
  document.getElementById('s').innerHTML = f(input.value)
}
for(var i=0;i<200;i++){
  results.push(i + ': ' + f(i))
}
document.getElementById('r').innerHTML=results.join('
')
N = <input type="number" id="n" min="1" value="191" />

KBD(N) = <samp id="s">4544</samp>

Cobra - 135
Haven't done this in a while, but here goes:
def f(n,i=0)
    while n,if all for x in (s='[i+=1]').length-1get s[x+1]in' 1234567890'[(int.parse(s[x:x+1])+9)%10:][:3],n-=1
    print i

Ungolfed:
def fn(n as int)
    i = 0
    while n <> 0
        i += 1
        s = i.toString
        l = s.length - 1
        v = true
        for x in l
            k = (int.parse(s[x].toString) + 9) % 10
            if s[x + 1] not in ' 1234567890'[k : k + 3], v = false
        if v, n -= 1
    print i

Jelly, 11 bytes
Do⁵IỊẠ
1Ç#Ṫ

Try it online!

JavaScript (Node.js), 64 bytes
f=(n,i)=>n?f(n-![...~i+f].some(e=v=>(e-(e=+v||1+v))**2>1),-~i):i
               ^                            ^
   If exist, don't decrease        1=>1, 0=>10, s=>1s

Try it online!

source: Stack Exchange

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

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

sort: votes


text:
Order 40 sticks
We have 40 sticks of same widths but different heights. How many arrangements are there possible to put them next to each other so that when we look from right we see 10 sticks and when we look from left we again see exactly 10 sticks?
For example such an ordering is:
Black sticks are hidden, red sticks are the ones you can see when you look from left, the blue sticks are the ones you can see when you look from right and purple one(i.e. the longest one) is the one that can be see seen from both sides.
As test cases:

If we had 3 sticks number of orderings to see 2 from left and 2 from right is 2
If we had 5 sticks number of orderings to see 3 from left and 3 from right is 6
If we had 10 sticks number of orderings to see 4 from left and 4 from right is 90720

You might want to avoid questions with a fixed output because the optimal code-golf answer will probably just print the result without calculating it. I'd recommend making the question have a few variable inputs, eg N sticks such that you see K of them from left/right, where N and K are input integers

If you do change the spec so that programs take in input (I don't see why not - you already have the test cases), you might want to think about whether or not you want to put a time limit on programs.

"Must use your posted program to calculate the 40/10 case" should be a good enough time limit.

I can't get over the fact that 10!/40 = 90720... is that coincidence?

@Tim Whats the significance of 90720?  Zip code for Los Alamitos, CA?

@DigitalTrauma no, that is the orderings for 10 with 4 from each side.

PARI/GP, 80
f(n,v)=abs(sum(k=1,n-1,binomial(n-1,k)*stirling(k,v-1,1)*stirling(n-k-1,v-1,1)))

The number of visible sticks is also called Skyscraper Numbers, after the pencil/grid game. This code is based on (only slightly altered) the formula from OEIS A218531. I don't know much PARI, but I really don't think there's much to golf out here.
Test cases are all shown at ideone.com. The result for f(40,10) is:
192999500979320621703647808413866514749680

There's a nice reason for the formula. The number of permutations with v left-visible sticks is the Stirling number s(n,v). If the tallest stick is at position k, then the left-visible sticks are that stick and the left-visible sticks in the sub-permutation to the left of k-1 values left of position k. So, to have v left-visible sticks and v right-visible sticks, one has s(k,v-1) choices to permute the left half, s(n-k-1,v-1) to permute the right half, and binomial(n-1,k) choices to split sticks into the two halves.

@xnor They give basically that explanation in the linked PDF, but yours is worded much better IMO.

You can save 11 bytes: f(n,v,s=stirling)=abs(sum(k=1,n--,binomial(n,k)*s(k,v-1)*s(n-k,v-1))). This saves sterling to a variable for reuse, leaves off its last argument, since 1 is the default, and subtracts 1 from n once rather than three times.

Python 3, 259 bytes
Not very happy with this.
import itertools as i
x=input().split()
y,k=x
y=int(y)
c=0
x=list(i.permutations(list(range(1,y+1))))
for s in x:
 t=d=0;l=s[::-1]
 for i in range(y):
  if max(s[:i+1])==s[i]:t+=1
 for i in range(y):
  if max(l[:i+1])==l[i]:d+=1
 if t==d==int(k):c+=1
print(c)

Example input and output:
10 4
90720

It generates all the possible combinations of the provided range, and then loops through them, checking each number in them to see if it equal to the maximum of the previous numbers. It then does the same backwards, and if the count forwards (t) = the count backwards (d) = the given view number (k) it's a valid one. It adds this to a counter (c) and prints that at the end.

R, 104
function(N,K)sum(sapply(combinat::permn(N),function(x)(z=function(i)sum(cummax(i)==i)==K)(x)&z(rev(x))))

De-golfed a little:
    function(N,K) {
      all_perm <- combinat::permn(N)
      can_see_K_from_left <- function(i)sum(cummax(i) == i) == K
      can_see_K_from_both <- function(x)can_see_K_from_left(x) &
                                        can_see_K_from_left(rev(x))
      return(sum(sapply(all_perm, can_see_K_from_both)))
    }

Pyth - 38 36 bytes
Basically a port of the R answer. Pretty slow, can't even complete 10, 4 online.
AGHQLlfqhS<bhT@bTUGlf!-,yTy_TH.pr1hG

The only things Pyth doesn't have are cummax and the == over vectors, but those only took a few bytes to implement.
Explanation and further golfing coming soon.
Try it here online.

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


text:
aBOTcalypse Now
aBOTcalypse
Design a bot to compete in a King-of-the-Hill challenge! Here's a replay of a default bot game.
The board is 2D, like a side-scrolling video game (but without any scrolling).
A valid bot must accept a multiline string representation of the region of the board it can see, and output a move for the bot.
Mechanics
This is a survival game. The apocalypse has come, and only bots (and an endless supply of rocks stored in hammerspace) remain. Each bot is given a random starting location, at elevation 0. In a given move, a bot can rest, move, throw a rock, or drop a rock. Bots can share space with stationary rocks, but a bot that collides with another bot or a meteor is killed, as is a bot hit by a thrown rock.

Gravity: bots and rocks must rest on top of the floor of the board or on top of another rock; resting on something else (air, a meteor, a bot, etc.) leaves one "unsupported". Unsupported bots or rocks will fall until they are supported; a fall of greater than one space will kill a bot, and a bot underneath a falling rock or bot is also killed. This means that trying to move or drop up will only work if the bot is currently sharing a space with a rock (otherwise the bot/rock will fall back down 1 space). A space can become "unsupported" if the rock beneath it falls or is destroyed by a meteor or projectile.
Meteors: Each turn a meteor enters the board from the top. A meteor has a velocity of magnitude 2, with a random angle chosen uniformly in the range [-180,0], and a random starting x position. Meteors fall in a straight line along the given trajectory until they hit something, at which point they disappear. Note that rounding in a meteor's movement is towards 0 (as per python's int()).
Projectiles: A bot can choose to throw a rock any distance up to its elevation. A thrown rock moves in a straight line until it hits something (all in one turn, unlike a meteor; thrown rocks don't appear on the board), at a slope of - elevation / max distance. Note that thrown rocks begin their trajectory at x +- 1 square. For example, if a bot is at an elevation of 5, and throws left a distance of 1, the rock will begin at (x-1,5) and end at (x-2,0). Collision is only checked in steps of dx=1, and dy is rounded towards 0 (as per python's int()).

Input
Each bot can see a square 20 pixels in each direction (Chebyshev distance = 20), up to the boundaries of the board. There are 8 different characters in each input string:

'#' (board boundary)
'.' (air)
'@' (meteor)
'&' (rock)
'e'/'s' (an enemy bot, or itself)
'E'/'S' (an enemy bot, or itself, sharing a space with a rock)

Here's an example input (line breaks will be \n):
..............................#
..............................#
..............................#
..............................#
..............................#
..............................#
..............................#
..............................#
..............................#
..............................#
..............................#
..............................#
..............................#
..............@...............#
.....................E........#
.....................&........#
.....................&........#
.....................&........#
.....................&........#
...........@.........&........#
....................s&........#
###############################

Output
There are four actions that a bot can take each turn.

rest (literally sit and do nothing)
move <direction> moves the bot one space in any of the four directions, up, down, left, or right. Movement causes the bot to fall if the new space is not supported by the floor or a rock (fall > 1 = bot.kill()).
drop <direction> places ("drops") a rock in the indicated direction. Dropping a rock up (i.e., placing a rock in the square [bot_x, bot_y+1]) or to the side causes it to fall until supported (possibly falling onto the bot during drop up). drop down places a rock in the same position as the bot, if there is not a rock there already.
throw <direction> <distance> throws a rock as per the "projectiles" mechanics above, with the indicated max distance. Max distance is irrelevant for throwing upward or downward - the projectile collides with the square below (for down), or attempts to collide with the square above (for up) and then with the bot's square if it doesn't hit anything (killing the bot).

A bot in the contest must output a scalar string with its action upon receiving the input string.
Interface
A bot must consist of a single program which can be called via a python 2 subprocess. Any commands should be indicated, and will be saved in a file called command.txt; before a game begins, the controller will execute each command in command.txt, in order, and then the final command will be used to pass input to the bot from then on.
A bot may have a single storage file called storage.txt in its folder; the "Default Thrower" bot shows an example implementation, using json to save its state during various turns. In addition, feel free to include debugging output in a write-only errlog.txt, which I'll pass along in case your bot fails during a run. I'll make sure to run several tests with each bot, to try and find any errors beforehand.
Scoring
A bot's total score is equal to the number of turns it survives, accumulated over X games of maximum length Y. At the moment, X,Y = 10, 500; if bots are lasting a long time, I'll increase Y, and if they are lasting a short time, I'll increase X.
Controller code is found in controller.py; many thanks to @Nathan Merrill for his DDOS koth from which I adapted the Communicator code.

What prevents bots from making structures such as &&&\n&S&\n###? They would be invulnerable to falling meteors.

nothing at all. however, they'd have to rebuild part of the structure if it was struck by anything (which involves being exposed on one of the outer layers during the maintenance process), and they'd still have to deal with other bots.

As far as I can see, there is no way to dig rocks.

what do you mean by "dig"? each bot has as many rocks as it wants, stored in hammerspace (i'll edit that link into the question). or do you mean to destroy rocks? if that's the case, then a rock is destroyed when it's hit by any projectile, not just a meteor. also realize that other bots can waltz right into your stronghold.

You should add the fact that meteors/projectiles destroy rocks.

...how did i miss that? lol, i'll edit it in. it should be obvious from the replay, but it's still important to mention. thank you!

How does the builder bot go downwards without a possible output of throw?

it doesn't go down on its own, the throwers and meteors destroy its tower. since build-and-climb takes 2 turns, the thrower can destroy the tower faster than it's built.

Let us continue this discussion in chat.

If a bot 'drops up' with no other rocks around, does it squash itself, or end up hiding under a rock?

it squashes itself.

Perhaps you could edit the controller to render each bot in a different color.

sure, i can give it a shot

Python 2, Edgebot
Edgebot wants to hide in a corner and build a tower. They'll run to one end, build up a bit, then start dropping rocks to build a wall. Edgebot does not like visitors, and will throw rocks at anyone who gets too close to their tower. If it all goes horribly wrong and edgebot crashes, it'll drop a rock on its own head
import sys
from random import randint
class edgebot():

    def playtime(self,board):
        try:
            self.max_height = 5
            board = board.splitlines()

            #find edgebot
            for y in xrange(0,len(board)):
                row = board[y]
                symbol = 's' if row.count('s') else 'S'
                x = row.find(symbol)
                if x >= 0:
                    self.height = 20 - y
                    break

            ground = board[len(board)-2]
            floor = board[len(board)-1]
            nasty_person = 'e' if ground.count('e') else 'E'
            bad_x = ground.find(nasty_person)
            side = ground.find('#')
            if abs(side - x) ==1:
                self.end_found = 1
            else:
                self.end_found = 0

            if side - x == -1:
                self.direction = 'right'
            else:
                self.direction = 'left'

            #Bad edgebot! No climbing out of the game!
            if floor[x] != '#':
                if board[self.height-1][x] == '&':
                    dist = randint(3,self.height)
                    return 'throw ' + self.direction + ' ' + `dist`
                elif symbol =='S':
                    return 'drop up'
                else:
                    return 'move down'

            #Edgebot will go through you to find a corner. You have been warned.
            elif abs(x - bad_x) <=2:
                if x - bad_x >0:
                    return 'throw left 1'
                else:
                    return 'throw right 1'

            #edgebot wants to hide in a corner
            elif self.end_found ==0:
                if side == -1:
                    return 'move right'#edgebot is right-handed
                elif side - x < -1:
                    return 'move left'
                elif side - x > 1:
                    return 'move right'

            #Too close! Throw rocks at it!
            elif self.height+1>= abs(x-bad_x) and abs(x-bad_x) >=3:
                distance = abs(x - bad_x) - 2
                if distance < 1:
                    return 'throw ' + self.direction + ' 1'
                else:
                    return 'throw ' + self.direction + ' ' +`distance - 1`
                self.max_height += 2 #people came close, edgebot needs to be higher up!

            #edgebot wants a home in the corner
            elif self.height <self.max_height :
                if symbol =='S':
                    return 'move up'
                else:
                    return 'drop down'

            #edgebot wants a wall. edgebot has, at best, a limited understanding of architecture
            elif bad_x < 3 or self.height+1<abs(x-bad_x):
                if self.direction == 'right' and row[x+1] == '&':
                    self.max_height += 2
                    return 'drop down'
                elif self.direction == 'left' and row[x-1] == '&':
                    self.max_height += 2
                    return 'move down'
                else:
                    return 'drop ' + self.direction

            else:
                return 'drop down' #Not sure? Hide under a rock!
        except:
            return 'drop up' #All gone horribly wrong? Squish.

print edgebot().playtime(sys.argv[1])

Sorry for all the edits, didn't run enough test cases before submitting. There's a small problem in that the little guy will try to climb off the top of the board given enough time, but hopefully that won't be an issue in most matches. Edgebot should now just throw rocks random distances once it's climbed high enough
Last edit for now. Edgebot will now throw rocks at anyone close enough between it and the wall. No sense it taking itself out by running through someone


text:
Convert Brainfuck to a Non-Golfing Language
Input:
Any Brainfuck program. This includes brainfuck programs with comments such as +++COMMENT[>+++<-]..
Output:
A program in one of the below languages that produces the same output as the Brainfuck program on all inputs. It should produce the same output exactly as the interepreter on this website There are no code-golf or performance restrictions on the output program; the outputted program doesn't need to be optimized in any way. In other words, the quality of the outputted program does not affect score, only the translation program. To clarify: you may write your answer in any language that is normally valid for answers on PCG. The restriction on output languages is only for the outputted program.
The outputted program only receives the same input that would be received by the Brainfuck program. The outputted program does not receive the Brainfuck program as input.
Valid Output Languages

C#
C++
C
Java 8
Javascript ES6 (it is both okay to receive all of stdin in a single prompt, or multiple prompts per character)
Perl
Python 2.7
Python 3.4.2
Ruby

Fine Print
You may write a program or function which takes the Brainfuck program as a String argument or on STDIN or closest alternative, and which returns the output as a String or printing it to STDOUT (or closest alternative). You may optionally include a single trailing newline in the output.
Additionally, standard loopholes which are no longer funny are banned. You may not use external libraries or external data files, the code must be self contained.
This is code-golf, shortest program wins.

possible duplicate of Interpret Brainfuck

It's not a dup, as a compiler is not an interpreter

It might not be a dup, but the question is whether there is a shorter solution than copy&pasting a golfed interpreter in one of the allowed languages; and copying the brainfuck to the output program.

Can you clarify the behavior of the linked interpreter? What is the max number of memory cells? How is overflow of cell values handled?

@nderscore The linked interpreter uses signed integers that wrap around from -128 to +127.  However, the values are effectively cast to 2-byte unsigned ints before being output as characters; so -1 => chr(65535) ().  Personally, I would prefer output in the form of 1-byte (ASCII) characters (in part because that's what my solution uses).  The tape is circular, with 32768 cells.  durron597, are these specs what you intended?

Any reason not to open this up to all output languages?

I agree with Adám - there are tons of non-golfing languages out there that you're keeping from participating here. Also, why those very specific versions of Python and Java?

@Adám ,[.,] To convert Brainfuck to the output language Brainfuck in Brainfuck.

AFAIK: None of the mentioned languages can support this, reason: Memory. Brainfuck has an infinite amount of memory, but the listed languages have a finite amount (at least their implementation does). For example C, while you can create a implementation that supports an arbitary amount of memory, it still isn't infinite since CHAR_BIT * 2 ** ( CHAR_BIT*sizeof(size_t))   is an absolute maximum amount of bits it can use and a implementation has to define this values. Maybe it would help when you define a minimum maximum number of cells and a minimum maximum value for a single cell?

K, 143 129 113 bytes
1!"}int a[99];int*p=a;main(){",,/{("p++;";"p--;";"*p++;";"*p--;";"*p=getchar();if(*p<0)*p=0;";"putchar(*p);";"while(*p){";"}";"")"><+-,.[]"?x}'

This is an extremely straightforward approach which generates C source code by emitting a preamble, a C snippet for each BF command and then a postscript. Non-BF characters are translated into empty strings in the concatenated output.
The translation into C is as follows:

preamble: int a[99];int*p=a;main(){
>: p++;
<: p--;
+: *p++;
-: *p--;
,: *p=getchar();if(*p<0)*p=0;
.: putchar(*p);
[: while(*p){
]: }
postscript: }

I suspect that there is room for improvement here by using more mangled abuses of C or compressing the C fragments.
The K part of the program by itself would look like the following, where c is the C translations of each BF instruction and p is the preamble/postscript:
1!p,,/{c"><+-,.[]"?x}'

Using the venerable BF string reverser program >,[>,]<[.<] as my test case I generate code which looks like the following after a bit of whitespace for readability:
int a[99];
int*p=a;

main(){
    p++;
    *p=getchar();if(*p<0)*p=0;
    while(*p){
        p++;
        *p=getchar();if(*p<0)*p=0;
    }
    p--;
    while(*p){
        putchar(*p);
        p--;
    }
}

edit:
A few tweaks. Firstly, more compliant tape declaration as suggested by alexander-brett. The int part can be left off:
int a[99]; -> a[1<<15]; (-1 byte)
Also, it seems that EOF behavior in BF can return 0, -1 or cause no change as a result of ,. EOF=-1 seems to be what other solutions are going with, so for the sake of uniformity I will do the same:
*p=getchar();if(*p<0)*p=0; -> *p=getchar(); (-13 bytes)
Note that this means my string reverser program will choke if you simply cat it a file ending in EOF(!), but as above it seems to be fair.
The new complete 129 byte solution:
1!"}a[1<<15];int*p=a;main(){",,/{("p++;";"p--;";"*p++;";"*p--;";"*p=getchar();";"putchar(*p);";"while(*p){";"}";"")"><+-,.[]"?x}'

edit 2, much, much later:
I randomly stumbled upon this old answer and, being older and wiser, realized there are several ways to make this shorter:

exploit the fact that it's completely syntactically valid C to include semicolons after every fragment instead of just those who need them, and thus remove them from the lookup table entries.
use the k5/k6 or oK dialects, which have overloads for \ and / which split a string apart on a character or join a list of strings with a character, respectively, to use a more compact representation of the lookup table and accomplish the above.
take advantage of the fact that find (dyadic ?) in the above dialects naturally conforms to a listy right argument, and thus does not need an explicit lambda + each

The one downside is that in these dialects there is no "rotate" primitive, so we have to add the "}" suffix in a less elegant manner. The overall structure of our solution:
1!     p, ,/{c"><+-,.[]"?x}'   / old
,[;"}"]p,";"/c"><+-,.[]"?      / new

The complete (and now totally points-free!) solution:
,[;"}"]"a[1<<15];int*p=a;main(){",";"/("|"\"p++|p--|*p++|*p--|*p=getchar()|putchar(*p)|while(*p){|}|")"><+-,.[]"?

Which shaves us down to 113 bytes.

Shouldn't that be a[30000]?

That would be more compliant. a[1<<15] is closer to the interpreter above, and I can leave off "int" as C variables are implicitly ints. It also looks like my "EOF=0" handling is more than is strictly necessary, even if it's a common assumption.

DARN! You beat me to K. :)

Unary postfix binds first over unary prefix, so *p++ increments p rather than *p. ++*p works as intended.

Suggest *p*=read(0,p,1); instead of *p=getchar();if(*p<0)*p=0;

Javascript (ES7 Draft), 170 bytes
Function which compiles BF source code into Javascript. The resulting code accepts input via prompt() and outputs via alert(), both one character at a time.
f=x=>'x=[i=0];'+[for(y of x)'z=x[i]|=0,x[i]'+'0++0--0,i++0,i--0,alert(String.fromCharCode(z))0=prompt().charCodeAt()0;for(;x[i];){x0}x'.split(0)['+-><.,[]'.indexOf(y)+1]]

The result is composed of:
Preamble: x=[i=0]; - Initializes x as an object to store memory cells and i as 0 for the initial index.
Each command is prefixed with: z=x[i]|=0,x[i] - Forces undefined memory cells to 0, starts all commands with x[i] to reduce repetition in the translation map. Stores value at current index in z.
Each command is also seperated by , commas due to implicit casting of the array to a string.
Command translation map:

(unknown) => empty string
+ => ++ - increment value at x[i]
- => -- - decrement value at x[i]
> => ,i++ - increment index pointer i
< => ,i-- - decrement index pointer i
. => ,alert(String.fromCharCode(z)) - alert character from value at x[i]
, => =prompt().charCodeAt() - store converted character code from prompt at x[i]
[ => ;for(;x[i];){x - Loop while value at x[i] is truthy (non-zero).
] => }x - End loop. Unused x appended to prevent errors from commas.

Python 2, 250 244 bytes
def B(b):
 I=0;print"from ctypes import*;R,p,c=[0]*9999,0,CDLL('libc.so.6')"
 for c in b:
     try:print' '*I+'p+=1|p-=1|R[p]+=1|R[p]-=1|c.putchar(R[p])|R[p]=c.getchar()|while R[p]!=0:|'.split('|')['><+-.,[]'.index(c)];I+=']&['.index(c)-1
     except:0

#first indentation level=space, 2nd indentation level=tab

(thks to @undergroundmonorail for helping me save 4 extra bytes)
The B function takes bf code as parameter and generates... a Python script.
Brainfuck's "tape" is seen a an array called R, which owns 32768 9999 items, and the pointer is stored in a variable called p.
The lack of a native equivalent to C's getchar function in python forced me to load it using ctypes at runtime, which makes the generated script unusable on Windows (untested, I guess that a Windows version should load mscvrt.dll instead of libc.so.6)
Example
The infamous 'hello world':
B('++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.')

Generates the following script:
from ctypes import*;R,p,c=[0]*9999,0,CDLL('libc.so.6')
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
while R[p]!=0:
 p+=1
 R[p]+=1
 R[p]+=1
 R[p]+=1
 R[p]+=1
 R[p]+=1
 R[p]+=1
 R[p]+=1
 p+=1
 R[p]+=1
 R[p]+=1
 R[p]+=1
 R[p]+=1
 R[p]+=1
 R[p]+=1
 R[p]+=1
 R[p]+=1
 R[p]+=1
 R[p]+=1
 p+=1
 R[p]+=1
 R[p]+=1
 R[p]+=1
 p+=1
 R[p]+=1
 p-=1
 p-=1
 p-=1
 p-=1
 R[p]-=1

p+=1
R[p]+=1
R[p]+=1
c.putchar(R[p])
p+=1
R[p]+=1
c.putchar(R[p])
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
c.putchar(R[p])
c.putchar(R[p])
R[p]+=1
R[p]+=1
R[p]+=1
c.putchar(R[p])
p+=1
R[p]+=1
R[p]+=1
c.putchar(R[p])
p-=1
p-=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
c.putchar(R[p])
p+=1
c.putchar(R[p])
R[p]+=1
R[p]+=1
R[p]+=1
c.putchar(R[p])
R[p]-=1
R[p]-=1
R[p]-=1
R[p]-=1
R[p]-=1
R[p]-=1
c.putchar(R[p])
R[p]-=1
R[p]-=1
R[p]-=1
R[p]-=1
R[p]-=1
R[p]-=1
R[p]-=1
R[p]-=1
c.putchar(R[p])
p+=1
R[p]+=1
c.putchar(R[p])
p+=1
c.putchar(R[p])

Unless I'm mistaken, the length of R is 0xfff=4095, not 32768. Also you can save some bytes by changing the last line to except:0. 0 is a no-op and 3 bytes shorter than pass.

@undergroundmonorail http://en.wikipedia.org/wiki/Brainfuck#Array_size

You can save a few bytes by replacing from ctypes import* with from msvcrt import* and using just putchar instead of c.putchar.

Common Lisp &  JavaScript - 425 bytes
N.B. I am using the Parenscript library, so this is just for the fun.
(defun b(i &aux(s(coerce i'list)))(labels((c()(do(r x)((or x(not s))(reverse r))(push(case(pop s)(#\>`(incf p))(#\<`(decf p))(#\+`(setf(aref a p)(1+#1=(or(aref a p)0))))(#\-`(setf(aref a p)(1- #1#)))(#\.`((ps:@ console log)((ps:@ *String from-char-code)#1#)))(#\,`(setf(aref a p)((ps:@(prompt)char-code-at)0)))(#\[`(loop until(= 0 #1#)do ,@(c))))(#\](setf x t)(go /))(t(go /)))r)/)))(ps:ps*`(let((a(make-array))(p 0)),@(c)))))

Ungolfed
(defun bf(i)
  (let ((s (coerce i'list)))
    (labels((lbf ()
              (do(r x)((or x(not s))(reverse r))
                      (push (case (pop s)
                              (#\> `(incf p))
                              (#\< `(decf p))
                              (#\+ `(setf(aref a p)(1+(or (aref a p)0))))
                              (#\- `(setf(aref a p)(1-(or (aref a p)0))))
                              (#\. `((ps:@ console log)((ps:@ *String from-char-code) (or(aref a p)0))))
                              (#\, `(setf(aref a p) ((ps:@ (prompt) char-code-at) 0)))
                              (#\[ `(loop until(= 0(or(aref a p)0))do ,@(lbf)))
                              (#\] (setf x t) (go /))
                              (t (go /)))
                            r)/)))
      `(let ((a (make-array))
             (p 0))
         ,@(lbf)))))

Explanations

Convert input string as list of characters s
The recursive function lbf pop elements from s and build a local list of expressions r
Whenever we encounter a [ character, the function recurse in order to create a nested block of instructions
Whenever we encounter a ] character, the function exits, returning to one higher level of invocation. Note that when returning from the function, the variable s has been modified to hold the rest of the characters to be processed, thanks to pop.
The whole S-expr being built is expressed in a sub-language of Common Lisp that can be converted to Javascript thanks to Parenscript.

Optimized version
I made a slightly optimized version that is too long to post here, with the following changes:

Parsing only produces an AST containing the following symbols: print, read, left, right, inc, dec, bracketed (nested tree) and brainfuck (root tree).
The AST is analyzed to group all increment and decrement operations, as well as move operations, in order to build (add x) and (move y) terms.
Finally, the AST is converted into Parenscript code.
That code is emitted as a Javascript string

The resulting Javascript for Hello World is:
(function () {
   var a = new Array();
   var p = 0;
   a[p] = (a[p] || 0) + 10;
   while (0 !== (a[p] || 0)) {
       ++p;
       a[p] = (a[p] || 0) + 7;
       ++p;
       a[p] = (a[p] || 0) + 10;
       ++p;
       a[p] = (a[p] || 0) + 3;
       ++p;
       a[p] = (a[p] || 0) + 1;
       p += -4;
       a[p] = (a[p] || 0) + -1;
   };
   ++p;
   a[p] = (a[p] || 0) + 2;
   console.log(String.fromCharCode(a[p] || 0));
   ++p;
   a[p] = (a[p] || 0) + 1;
   console.log(String.fromCharCode(a[p] || 0));
   a[p] = (a[p] || 0) + 7;
   console.log(String.fromCharCode(a[p] || 0));
   console.log(String.fromCharCode(a[p] || 0));
   a[p] = (a[p] || 0) + 3;
   console.log(String.fromCharCode(a[p] || 0));
   ++p;
   a[p] = (a[p] || 0) + 2;
   console.log(String.fromCharCode(a[p] || 0));
   p += -2;
   a[p] = (a[p] || 0) + 15;
   console.log(String.fromCharCode(a[p] || 0));
   ++p;
   console.log(String.fromCharCode(a[p] || 0));
   a[p] = (a[p] || 0) + 3;
   console.log(String.fromCharCode(a[p] || 0));
   a[p] = (a[p] || 0) + -6;
   console.log(String.fromCharCode(a[p] || 0));
   a[p] = (a[p] || 0) + -8;
   console.log(String.fromCharCode(a[p] || 0));
   ++p;
   a[p] = (a[p] || 0) + 1;
   console.log(String.fromCharCode(a[p] || 0));
   ++p;
   return console.log(String.fromCharCode(a[p] || 0));
})();

QuadR, 106 100 99 bytes
Edit: finally below 100 bytes! -1 thanks to ceilingcat (⌈,)
Creates C code.
^
>
<
[+-]
\.
,
\[
]|$
a[1<<15];*p=a;main(){
p++;
p--;
&&*p;
putchar(*p);
read(0,p,1);
while(*p){
}

Try it online!
The first nine lines are PCRE regexes. Matches throughout the input are replaced with the corresponding string from the last 9 lines. The only noteworthy "hacks" are transpiling [+-] to &&*p; where & means the matched plus/minus symbol, and combining end-of-loop with end-of-main through mapping ]|$ to }

Unary postfix binds first over unary prefix, so *p++ increments p rather than *p. ++*p works as intended.

Perl, 127 120B + 2
%h=qw#> ++p;
< --p;
+ ++*p;
- --*p;
. putchar(*p);
, *p=getchar();
[ while(*p){
] }#;say"a[1<<15],*p=a;main(){@h{/./g}}"

The magic happens in @h{/./g}: /./g splits the input into characters, @h{} is a hash slice, and the "" interpolation joins hash elements using a space (by default). The target is C using exactly the spec on the Brainfuck website. 2 point penalty for -0n: run with
perl -M5.10.0 -0n scratch.pl > test.c < input.bf && gcc -ansi test.c && ./a.out

7B saving thanks to CL- and the prevailing opinion on variable declarations.

It looks like you can shorten the C preamble from main(){int a[1<<15];int*p=a; to a[1<<15],*p=a;main(){ for a 7 byte saving. This also guarantees that each element of a will be initialised to 0.

@CL- how do I compile that? gcc on OSX errors if I don't put a type in

You'll see a warning, but it should still compile fine.

rs, 214 bytes
Outputs Ruby 1.9 code.
[^+\-[\]<>.,]/
\[/while tape[i
\]/end;
\[i/[i] != 0 do
\./print tape[i].chr;
if !defined?tape then require "io\x2Fconsole";tape=[0]*9999;i=0;end;
\+/tape[i]+=1;
-/tape[i]-=1;
</i+=1;
>/i-=1;
,/tape[i]=STDIN.getch;

Try it here!
Sample runs
Hello, world!
Input:
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.

Output:
if !defined?tape then require "io\x2Fconsole";tape=[0]*9999;i=0;end;tape[i]+=1;tape[i]+=1;tape[i]+=1;tape[i]+=1;tape[i]+=1;tape[i]+=1;tape[i]+=1;tape[i]+=1;while tape[i] != 0 do i-=1;tape[i]+=1;tape[i]+=1;tape[i]+=1;tape[i]+=1;while tape[i] != 0 do i-=1;tape[i]+=1;tape[i]+=1;i-=1;tape[i]+=1;tape[i]+=1;tape[i]+=1;i-=1;tape[i]+=1;tape[i]+=1;tape[i]+=1;i-=1;tape[i]+=1;i+=1;i+=1;i+=1;i+=1;tape[i]-=1;end;i-=1;tape[i]+=1;i-=1;tape[i]+=1;i-=1;tape[i]-=1;i-=1;i-=1;tape[i]+=1;while tape[i] != 0 do i+=1;end;i+=1;tape[i]-=1;end;i-=1;i-=1;print tape[i].chr;i-=1;tape[i]-=1;tape[i]-=1;tape[i]-=1;print tape[i].chr;tape[i]+=1;tape[i]+=1;tape[i]+=1;tape[i]+=1;tape[i]+=1;tape[i]+=1;tape[i]+=1;print tape[i].chr;print tape[i].chr;tape[i]+=1;tape[i]+=1;tape[i]+=1;print tape[i].chr;i-=1;i-=1;print tape[i].chr;i+=1;tape[i]-=1;print tape[i].chr;i+=1;print tape[i].chr;tape[i]+=1;tape[i]+=1;tape[i]+=1;print tape[i].chr;tape[i]-=1;tape[i]-=1;tape[i]-=1;tape[i]-=1;tape[i]-=1;tape[i]-=1;print tape[i].chr;tape[i]-=1;tape[i]-=1;tape[i]-=1;tape[i]-=1;tape[i]-=1;tape[i]-=1;tape[i]-=1;tape[i]-=1;print tape[i].chr;i-=1;i-=1;tape[i]+=1;print tape[i].chr;i-=1;tape[i]+=1;tape[i]+=1;print tape[i].chr;

Mandelbrot
Input:
      A mandelbrot set fractal viewer in brainf*** written by Erik Bosman
+++++++++++++[->++>>>+++++>++>+<<<<<<]>>>>>++++++>--->>>>>>>>>>+++++++++++++++[[
>>>>>>>>>]+[<<<<<<<<<]>>>>>>>>>-]+[>>>>>>>>[-]>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>[-]+
<<<<<<<+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>>+>>>>>>>>>>>>>>>>>>>>>>>>>>
>+<<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+[>>>>>>[>>>>>>>[-]>>]<<<<<<<<<[<<<<<<<<<]>>
>>>>>[-]+<<<<<<++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<+++++++[-[->>>
>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[[-]>>>>>>[>>>>>
>>[-<<<<<<+>>>>>>]<<<<<<[->>>>>>+<<+<<<+<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>
[>>>>>>>>[-<<<<<<<+>>>>>>>]<<<<<<<[->>>>>>>+<<+<<<+<<]>>>>>>>>]<<<<<<<<<[<<<<<<<
<<]>>>>>>>[-<<<<<<<+>>>>>>>]<<<<<<<[->>>>>>>+<<+<<<<<]>>>>>>>>>+++++++++++++++[[
>>>>>>>>>]+>[-]>[-]>[-]>[-]>[-]>[-]>[-]>[-]>[-]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>-]+[
>+>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>[>->>>>[-<<<<+>>>>]<<<<[->>>>+<<<<<[->>[
-<<+>>]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<<<<<<<<<[<<<<<<<<<]>>>>[-]<<<++++
+[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>->>>>>>>>>>>>>>>>>>>>>>>>>>>-<<<<<<[<<<<
<<<<<]]>>>]

Output (I'm glad it isn't scored!) is available on Pastebin because it was too long to put here!

Yes! A ruby transpiler!

Javascript (ES6), 202 196 192 bytes
Outputs C code. Tested with Node.js 14.7.0 and GCC 10.1.0.
Try it online
f=i=>"a[99];main(){int*p=a;"+Array.prototype.map.call(i,x=>({">":"p++","<":"p--","+":"++*p","-":"--*p","[":"while(*p){","]":"}",",":"read(0,p,1)||(*p=0)",".":"putchar(*p)"})[x]).join(";")+"}";

The only clever thing here is using Array.map on a string rather than an array. I expected this to be golfier than it was; the 24 characters for Array.prototype.map.call were brutal.
I copied some of the C code from nderscore's answer. As far as I can tell, the C is as golfed as it can be, other than perhaps the preamble. Potentially I could tease out some undefined behaviour to point p to somewhere lower down on the stack for fewer bytes than defining an array outright.
-6 bytes: replace *p=getchar();if(*p<0)*p=0 with read(0,p,1)||(*p=0). Thanks to ceilingcat
-4 bytes: replace (*p)++ and (*p)-- with ++*p and --*p. Thanks to Bubbler

(*p)++; and (*p)--; can be written as ++*p; and --*p;.

Nice first answer.

Suggest *p*=read(0,p,1) instead of read(0,p,1)||(*p=0)

Also, forgot to welcome you to CGCC!


text:
What date is that again?
On my website, users enter their date of birth in the style xx.xx.xx - three two-digit numbers separated by dots. Unfortunately, I forgot to tell the users exactly which format to use. All I know is that one section is used for the month, one for the date, and one for the year. The year is definitely in the 20th century (1900-1999), so the format 31.05.75 means 31 May 1975. Also, I'm assuming everyone uses either the Gregorian or the Julian calendar.
Now, I want to go through my database to clear up the mess. I'd like to start by dealing with the users with the most ambiguous dates, that is, those where the range of possible dates is the biggest.
For example, the date 08.27.53 means 27 August 1953 in either the Gregorian or Julian calendar. The date in the Julian calendar is 13 days later, so the range is just 13 days.
In contrast, the notation 01.05.12 can refer to many possible dates. The earliest is 12 May 1901 (Gregorian), and the latest is 1 May 1912 (Julian). The range is 4020 days.
Rules

Input is a string in the format xx.xx.xx, where each field is two digits and zero-padded.
Output is the number of days in the range.
You can assume that the input will always be a valid date.
You may not use any built-in date or calendar functions.
Shortest code (in bytes) wins.

Testcases

01.00.31 => 12
29.00.02 => 0 (The only possibility is 29 February 1900 (Julian))
04.30.00 => 13
06.12.15 => 3291

Is the 5, May 1975 supposed to be 31st? Also, do we have to account for leap years?

@Maltysen Yes, fixed. Yes.

Why couldn't it be in the 21st century?

@ElefantPhace The rules state that the 20th century is assumed; otherwise there would be no maximum date.

Pyth, 118 bytes
M++28@j15973358 4G&qG2!%H4FN.pmv>dqhd\0cz\.I&&&hN<hN13eN<eNhgFPNaYK+++*365JhtN/+3J4smghdJthNeNInK60aY-K+12>K60;-eSYhSY

Try it online: Demonstration or Test Suite.
Necessary knowledge of Julian and Gregorian Calendars
Julian and Gregorian Calendar are quite similar. Each calendar divides a year into 12 months, each containing of 28-31 days. The exact days in a month are [31, 28/29 (depends on leap year), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]. The only difference between the calendars are their definition of a leap year. In the Julian Calendar any year divisible by 4 is a leap year. The Gregorian Calendar is a bit more specific. Any year divisible by 4 is a leap year, except the year divisible by 100 and not divisible by 400.
So in the 20th century only one year is different. The year 1900, which is a leap year in the Julian Calendar, but not a leap year in the Gregorian Calendar. So the only date, that exists in the one calendar but not in the other calendar is the day 29.02.1900.
Because of the different leap year definition, there's a difference between a date in the Julian Calendar and the Gregorian Calendar. 12 days difference for a date before the 29.02.1900, and 13 days difference for dates after the 29.02.1900.
Simplified Pseudo-Code
Y = []  # empty list
for each permutation N of the input date:
   if N is valid in the Julian Calendar:
      K = number of days since 0.01.1900
      append K to Y
      if K != 60:  # 60 would be the 29.02.1900
         L = K - (12 if K < 60 else 13)
         append L to Y
print the difference between the largest and smallest value in Y

Detailed Code Explanation
The first part M++28@j15973358 4G&qG2!%H4 defines a function g(G,H), which calculates the number of days in month G of a year H in the Julian Calendar.
M                            def g(G,H): return
      j15973358 4               convert 15973358 into base 4
     @           G              take the Gth element
  +28                           + 28
 +                &qG2!%H4      + (G == 2 and not H % 4)

And the next part is just the for loop, and the ifs. Notice that I interpret N in the format (month, year, day). Just because it saves some bytes.
FN.pmv>dqhd\0cz\.
             cz\.        split input by "."
    mv>dqhd\0            map each d of ^ to: eval(d[d[0]=="0":])
FN.p                     for N in permutations(^):

I&&&hN<hN13eN<eNhgFPN
I                          if
    hN                        month != 0
   &                          and
      <hN13                   month < 13
  &                           and
           eN                 day != 0
 &                            and
             <eNhgFPN         day < 1 + g(month,year):

aYK+++*365JhtN/+3J4smghdJthNeN
          JhtN                    J = year
     +*365J   /+3J4               J*365 + (3 + J)/4
    +              smghdJthN      + sum(g(1+d,year) for d in [0, 1, ... month-2])
   +                        eN    + day
  K                               K = ^
aYK                               append K to Y

InK60aY-K+12>K60
InK60                             if K != 60:
     aY-K+12>K60                    append K - (12 + (K > 60)) to Y

;-eSYhSY
;          end for loop
 -eSYhSY   print end(sorted(Y)) - head(sorted(Y))

Perl 5, 294 bytes
sub f{map/(\d\d)(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])/             #1
      &&$3<29+($2==2?!($1%4):2+($2/.88)%2)                        #2
      &&($j{$_}=++$j+12)                                          #3
      &&$j!#1=60?$g{$_}=++$g:0,'000101'..'991231'if!%g;           #4
      pop=~/(\d\d).(\d\d).(\d\d)/;                                #5
      @n=sort{$a<=>$b}                                            #6
         grep$_,                                                  #7
         map{($j{$_},$g{$_})}                                     #8
         ("$1$2$3","$1$3$2","$2$1$3","$2$3$1","$3$1$2","$3$2$1"); #9
      $n[-1]-$n[0]}                                               #10

Try it online!
298 bytes when spaces, newlines and comments are removed.
Lines 1-4 initializes (if not done) the %g and %j hashes where the  values are the Gregorian and Julian day numbers accordingly counting from Jaunary 1st 1900 up to December 31st 1999.
Line 5 puts input date into $1, $2 and $3.
Line 9 lists all six permutations of those three input numbers.
Line 8 converts those six into two numbers each, the Gregorian and the Julian day numbers, but only those who are valid dates.
Line 7 makes sure of that, it filters out non existant day numbers.
Line 6 sorts the list of valid date numbers from the smallest to the largest.
Line 10 returns then difference between the last and first (max and min), which was the wanted range.