text:
Grid-Routing Battle
NOTE: This challenge is currently dead, as I'm unable to install the languages needed to run a match. If someone else has the time and interest to do it, I'm not opposed.
See the bottom of the post for a leaderboard.
This is a semi-cooperative king-of-the-hill challenge, where the bots construct paths through a two-dimensional grid graph. The bot who controls the nodes with the most traffic is the winner. However, it takes more than one bot's resources to actually build a connecting path, so the bots will have to work together -- to some extent.
Gameplay
In the following, let N > 0 be the number of bots in play.
The Grid
The game is played on a two-dimensional integer grid of size ⌊4/3N2⌋ × ⌊4/3N2⌋, whose bottom left coordinate is at (0,0). Each coordinate (x,y) with 0 ≤ y < ⌊4/3N2⌋-1 has outgoing edges to the three coordinates (x-1,y+1), (x,y+1), and (x+1,y+1) above it, where the x-coordinates are taken modulo  ⌊4/3N2⌋. This means that the grid wraps around at the east and west edges. Every bottom coordinate (x,0) is a source, and every top coordinate (x,⌊4/3N2⌋-1) is a sink.
The following picture shows an 8 × 8 grid.

Each vertex of the graph is either inactive, active, or broken. All vertices start inactive, and can be activated by bots, which will then be their owners. Also, bots can break vertices, and they cannot be repaired.
Turn Order
A turn consists of a destruction phase and an activation phase. In the destruction phase, each bot may break one inactive vertex. That vertex is broken from then on, and may not be activated by anyone. In the activation phase, each bot may activate one inactive vertex. From then on, they own that vertex, and it cannot be reactivated by anyone else. Several bots may own a single vertex, if they all activate it on the same turn. In each phase, the vertex selections are done simultaneously.
Scoring
One round lasts for exactly N2 turns. After this, the round is scored as follows. From each active source vertex, we perform N times a randomized depth-first search along the active vertices (meaning that the children of each vertex are visited in a random order). If a path is found from the source to some sink, then for all vertices along that path, every owner of the vertex gets one point.
The entire game lasts for 100 rounds, and the bot with the most points overall is the winner. I may increase this number, if the variance of the scores is too high.
Additional Rules

No messing with the controller or other submissions.
At most one submission per contestant.
No external resources, except one private text file, wiped clean at the beginning of the game.
Do not design your bot to beat or support specific opponents.
Provide commands to compile and run your bot. Any compiler/interpreter that's freely available for Debian Linux is acceptable.

The Controller
The controller is written in Python 3, and can be found in GitHub. See the README file for detailed instructions. Here's an API to get you started:

Bots are started at the beginning of each round, and persist until the end of the round. The communicate with the controller via STDIN and STDOUT, using newline-terminated messages.
BEGIN [num-of-bots] [num-of-turns] [side-length] is input at the beginning.
DESTROY [turn] is input at the beginning of each destruction phase. Your bot shall respond with either VERTEX x,y to choose a vertex, or NONE.
BROKEN [turn] [your-choice] [other-choices] is input at the end of each destruction phase. The order of the other bots is randomized at the beginning of each game, but stays fixed during it. The choices are presented as x,y or N.
ACTIVATE [turn] and OWNED [turn] [your-choice] [other-choices] are the equivalents of the above for the activation phase, and have the same semantics.
SCORE [your-score] [other-scores] is input at the end of the game.
Your bot has 1 second to analyze the results of a phase and choose the next vertex, and 1 second to quit after given the score. I will test the submissions on my relatively old laptop, so it's better to leave some margin here.

Please remember to flush your output buffer. Not doing so may hang the controller in some environments.
Leaderboard
Updated 3/13/2015
Peacemaker is up and running, and Funnelweb received an update too. The scores jumped up by an order of magnitude. Connector exceeded the time limit in two games.
Funnelweb: 30911
Connector: 18431
Watermelon: 3488
Annoyance: 1552
Explorer: 735
Checkpoint: 720
Random Builder: 535
FaucetBot: 236
Peacemaker: 80

The full log with ASCII art graphics can be found in the controller's repository, in graphical_log.txt.
Some observations:

Connector can very easily be stopped by breaking a single vertex in front of it. I suspect Annoyance frequently does this. However, it currently makes little sense because only Connector can conceivably construct a path.
Watermelon can get a decent score by simply happening to be on a connecting path (since the DFS is very likely to use its vertices).
Explorer likes to grow vines from the watermelons.
The updated Funnelweb gets really good scores, since Connector usually latches onto it in the lower half of the grid.
The games are getting quite long, the average round taking about 25 seconds on my machine.

I will be a very sad wolf if I see any Emo Wolf submissions...

Does the rightmost column lack forward arrows intentionally?

@Alex I tried to design the challenge so that suicidal bots won't mess everything up. Three well designed bots should always be able to construct a valid path, if they work together.

@Zgarb Suicide shouldn't mess it up, but a couple troll-bots working together could probably also block all paths, ruining the game.

@CarpetPython Active nodes cannot be destroyed.

@feersum The picture is now fixed.

I'm having a problem running the code

@Pureferret I patched the controller. Even if it still doesn't work, the error messages should be a little more meaningful.

Ok give it a go later!

@Zgarb What happens if a bot activates a vertex already owned by itself?

@Thrax In that case, its choice is interpreted as NONE.

It seems we are unlikely to see any interesting games with the current players and rules. I suggest you change the rules slightly to create opportunities for interesting games. Changing the grid size to 1.5N^2 instead of 2N^2 should be good and not confuse existing robots too much.

I looked at the complete log. So actually the scores are just from one round with positive score? The rest don't have connecting path. I support CarpetPython suggestion to reduce the grid size.

@justhalf That's true. The games in the log were actually played with the further reduced grid size of 4/3*N^2, and even there, the bots had problems forming valid paths. However, Connector was temporarily disqualified due to an error, and now that it has been fixed, I expect the games to be more interesting. I'll run another batch tonight.

Thanks for running another 100 games. Connector is doing very well. I was a little puzzled about game 85 though. Funnelweb (d) scored zero yet there were several d nodes in the paths from sources to sinks. Is there a bug there or have I misunderstood the scoring?

@CarpetPython: Note that the score is counted by taking random path from source to sinks. Looking at the configuration of the d nodes, I think it's unlikely for any of the d nodes to be selected in a path (note that there is only two ways to get to d nodes from bottom-to-top: line 5798 and 5801 in the log, out of many paths since the g nodes make the path width wide)

@justhalf: thanks. I think I see now. There was only one source with a path, so only 7 "score packets" made the trip. Because the d nodes were away from the centre of the paths, probability was against being selected. The funnelweb may need some tinkering.

@Zgarb, thanks for running more games. Will you run other games if we modify our bots, or would you rather move on to different activities? I would be keen to see how bots evolve to cooperate and compete, but I am aware this takes some of your time.

@CarpetPython I'll continue running the games as long as there are new/modified bots, though there may sometimes be delays of a few days.

Funnelweb, Python 2
version 1.2 - Better joining code, added new animation
Named after one of Australia's less friendly spiders. This bot first builds a funnel-shaped nest in the top rows, then lures other bots into building paths for traffic to the nest.
Here is a new animation of a 6 bot game on a 4/3N^2 board showing the funnelweb and some simpler bots:

The funnelweb's Python code:
from random import *
import sys
ME = 0
def pt(x,y): return '%u,%u' % (x % side_len, y)

while True:
    msg = raw_input().split()

    if msg[0] == 'BEGIN':
        turn = 0
        numbots, turns, side_len = map(int, msg[1:])
        R = range(side_len)
        top = side_len - 1
        grid = dict((pt(x, y), []) for x in R for y in R)
        mynodes = set()
        deadnodes = set()
        freenodes = set(grid.keys())
        mycol = choice(R)
        extra = sample([pt(x,top) for x in R], side_len)
        path = [(mycol, y) for y in range(top, top - side_len/6, -1)]
        moves = []
        fence = []
        for x,y in path:
            moves.append( [pt(x,y), pt(x+1,y), pt(x-1,y)] )
            fence.extend( [pt(x+1,y), pt(x-1,y)] )
        for dx in range(2, side_len):
            fence.extend( [pt(x+dx,y), pt(x-dx,y)] )
        for x,y in [(mycol, y) for y in
                range(top - side_len/6, top - 3*side_len/4, -1)]:
            moves.append( [pt(x,y), pt(x+1,y), pt(x-1,y)] )

    elif msg[0] == 'DESTROY':
        target = 'NONE'
        while fence:
            loc = fence.pop(0)
            if loc in freenodes:
                target = 'VERTEX ' + loc
                break
        print target
        sys.stdout.flush()

    elif msg[0] == 'BROKEN':
        for rid, loc in enumerate(msg[2:]):
            if loc != 'N':
                grid[loc] = None
                deadnodes.add(loc)
                freenodes.discard(loc)
                if loc in extra: extra.remove(loc)

    elif msg[0] == 'ACTIVATE':
        target = 'NONE'
        while moves:
            loclist = moves.pop(0)
            goodlocs = [loc for loc in loclist if loc in freenodes]
            if goodlocs:
                target = 'VERTEX ' + goodlocs[0]
                break
        if target == 'NONE':
            if extra:
                target = 'VERTEX ' + extra.pop(0)
            else:
                target = 'VERTEX ' + pt(choice(R), choice(R))
        print target
        sys.stdout.flush()

    elif msg[0] == 'OWNED':
        for rid, loc in enumerate(msg[2:]):
            if loc != 'N':
                grid[loc].append(rid)
                if rid == ME:
                    mynodes.add(loc)
                freenodes.discard(loc)
                if loc in extra: extra.remove(loc)
        turn += 1

    elif msg[0] == 'SCORE':
        break

The spider is run with python funnelweb.py.

Changed algorithm and tested it. It should run now.

Works great now!

Connector (Java)
Tries to create a path at a random position. Because it can't create a path on its own, it searches for active cells and uses them. Credit goes to Geobits, from whom I stole some code. Also, this submission isn't finished yet, as it simply stops doing anything as soon as the path is built.
Edit: If a path is built, Connector tries to create multiple paths along the existing one.
import java.awt.Point;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Connector {
    private static final int INACTIVE = 0;
    private static final int ACTIVE   = 1;
    private static final int BROKEN   = 2;
    private static final int MINE     = 3;

    private int size = 0;
    private int[][] grid = new int[size][size];
    private Point previousCell = null;
    private final List<Point> path = new ArrayList<>();

    public static void main(String[] args) {
        new Connector().start();
    }

    private void start() {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        while(true) {
            try {
                String input = reader.readLine();
                act(input);
            } catch (Exception e) {
                e.printStackTrace();
                System.exit(0);
            }
        }
    }

    private void act(String input) throws Exception {
        String[] msg = input.split(" ");
        String output = "";
        int turn;
        switch(msg[0]){
        case "BEGIN":
            size = Integer.parseInt(msg[3]);
            grid = new int[size][size];
            break;
        case "DESTROY":
            output = "NONE";
            break;
        case "BROKEN":
            update(msg, true);
            break;
        case "ACTIVATE":
            turn = Integer.parseInt(msg[1]);
            output = activate(turn);
            break;
        case "OWNED":
            update(msg, false);
            break;
        case "SCORE":
            System.exit(0);
            break;
        }
        if (output.length() > 0) {
            System.out.println(output);
        }
    }

    private String activate(int turn) {
        if (turn == 0) {
            Random r = new Random();
            previousCell = new Point(r.nextInt(size), 0);
            return "VERTEX " + previousCell.x + "," + 0;
        }
        Point lastCell = findLastPathCell(previousCell.x, previousCell.y);
        if (lastCell.y == size-1) {
            //path is done
            Point extendingPathPoint = findExtendingPathPoint();
            if (extendingPathPoint == null) {
                return "NONE";
            }
            return "VERTEX " + extendingPathPoint.x + "," + extendingPathPoint.y;
        } else {
            int x = findBestX(lastCell.x, lastCell.y);
            return "VERTEX " + x + "," + (lastCell.y + 1);
        }
    }

    private int findBestX(int x, int y) {
        int bestScore = Integer.MIN_VALUE;
        int bestX = 0;
        for (int i = -1; i <= 1; i++) {
            int newY = y + 1;
            int newX = (x + i + size) % size;
            int score = calcCellScore(newX, newY, 10);
            if (score > bestScore) {
                bestScore = score;
                bestX = newX;
            } else if (score == bestScore && Math.random() < 0.3) {
                bestX = newX;
            }
        }
        return bestX;
    }

    private int calcCellScore(int x, int y, int depth) {
        int newY = y + 1;
        if (depth < 0) {
            return 1;
        }
        if (newY >= size)
            return 100;
        int cellScore = 0;
        for (int i = -1; i <= 1; i++) {
            int newX = (x + i + size) % size;
            if (grid[newX][newY] == ACTIVE || grid[newX][newY] == MINE) {
                cellScore += 5;
            } else if (grid[newX][newY] == INACTIVE) {
                cellScore += 1;
            } else {
                cellScore -= 2;
            }
            cellScore += calcCellScore(newX, newY, depth -1);
        }
        return cellScore;
    }

    private Point findLastPathCell(int x, int y) {
        Point thisCell = new Point(x,y);
        int newY = y + 1;
        if (newY >= size) {
            return thisCell;
        }
        List<Point> endCells = new ArrayList<>();
        endCells.add(thisCell);
        path.add(thisCell);
        for (int i = -1; i <= 1; i++) {
            int newX = (x + i + size) % size;
            if (grid[newX][newY] == ACTIVE || grid[newX][newY] == MINE) {
                endCells.add(findLastPathCell(newX, newY));
            }
        }
        int bestY = -1;
        Point bestPoint = null;
        for (Point p : endCells) {
            if (p.y > bestY) {
                bestY = p.y;
                bestPoint = p;
            }
        }
        return bestPoint;
    }

    private Point findExtendingPathPoint() {
        if (path.size() == 0)
            return null;
        Random rand = new Random();
        for (int i = 0; i < size; i++) {
            Point cell = path.get(rand.nextInt(path.size()));
            for (int j = -1; j <= 1; j += 2) {
                Point newCellX = new Point((cell.x + j + size) % size, cell.y);
                if (grid[newCellX.x][newCellX.y] == INACTIVE)
                    return newCellX;

                Point newCellY = new Point(cell.x, cell.y + j);
                if (cell.y < 0 || cell.y >= size)
                    continue;
                if (grid[newCellY.x][newCellY.y] == INACTIVE)
                    return newCellY;
            }
        }
        return null;
    }

    private void update(String[] args, boolean destroyPhase) {
        for(int i = 2; i < args.length; i++) {
            String[] tokens = args[i].split(",");
            if(tokens.length > 1){
                int x = Integer.parseInt(tokens[0]);
                int y = Integer.parseInt(tokens[1]);
                if (grid[x][y] == INACTIVE) {
                    if (destroyPhase) {
                        grid[x][y] = BROKEN;
                    } else if (i == 2) {
                        grid[x][y] = MINE;
                        path.add(new Point(x,y));
                        previousCell = new Point(x,y);
                    } else {
                        grid[x][y] = ACTIVE;
                    }
                }
            }
        }
    }
}

@Zgarb Sorry, I created a bug while fixing the other one. It works now

@Manu, it is good you are back in the game. There are too many exploiters and not enough builders. With Connector running, the games may become more interesting (more that 1 game in 100 with a score).

Connector took 28 seconds to respond in one of the latest games (see the log). Seems like it ran into Watermelon and had a hard time deciding where to go next.

I ran some games again with the improved Peacemaker, and Connector threw an error: java.lang.ArrayIndexOutOfBoundsException: -1 at Connector.findExtendingPathPoint(Connector.java:166).

Checkpoint, Java
This bot tries to create checkpoints so that any valid path passes through one of my vertices. Since there are N2 turns and the board is 2N2 across, I can activate/break every node on a single horizontal line (assuming I'm there first). Do this in an alternating pattern (x is broken, o is mine):
xoxoxoxoxoxox...

If you want to make a path, you need to go through my checkpoints :)
Now, there are several issues this might face. First, it's not going to do very well at all unless there are many paths. Since he doesn't make any productive paths himself, he really is totally reliant on there being some competitors. Even a couple competitors combining to make a single path won't help much, since he only scores one spot for each path found. What he needs to shine is probably quite a few bots making quite a few different paths. Even then, it might not score very highly, but it was an idea I had in chat, so...
If one of the spaces on the line is blocked/claimed already, I just search for a nearby spot I can use (preferably on the same x line, just shifted vertically).

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Checkpoint {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        while(true)
            try {
                String input = reader.readLine();
                act(input);
            } catch (Exception e) {
                e.printStackTrace();
                System.exit(0);
            }
    }

    static void act(String input) throws Exception{
        String[] msg = input.split(" ");
        String output = "";
        int turn;
        boolean found = false;
        switch(msg[0]){
        case "BEGIN":
            size = Integer.parseInt(msg[3]);
            grid = new int[size][size];
            target = size/2;
            break;
        case "DESTROY":
            turn = Integer.parseInt(msg[1]);
            for(int x=0;x<size;x+=2)
                for(int y=0;y<size&&!found;y++)
                    if(grid[(x+turn*2)%size][(y+target)%size]==INACTIVE){
                        output = "VERTEX " + ((x+turn*2)%size) + "," + ((y+target)%size);
                        found = true;
                    }
            if(output.length() < 1)
                output = "NONE";
            break;
        case "BROKEN":
            for(int i=2;i<msg.length;i++){
                String[] tokens = msg[i].split(",");
                if(tokens.length>1){
                    int x = Integer.parseInt(tokens[0]);
                    int y = Integer.parseInt(tokens[1]);
                    if(grid[x][y]==INACTIVE)
                        grid[x][y] = BROKEN;
                }
            }
            break;
        case "ACTIVATE":
            turn = Integer.parseInt(msg[1]);
            for(int x=1;x<size;x+=2)
                for(int y=0;y<size&&!found;y++)
                    if(grid[(x+turn*2)%size][(y+target)%size]==INACTIVE){
                        output = "VERTEX " + ((x+turn*2)%size) + "," + ((y+target)%size);
                        found = true;
                    }
            if(output.length() < 1)
                output = "NONE";
            break;
        case "OWNED":
            for(int i=2;i<msg.length;i++){
                String[] tokens = msg[i].split(",");
                if(tokens.length>1){
                    int x = Integer.parseInt(tokens[0]);
                    int y = Integer.parseInt(tokens[1]);
                    if(i==2){
                        if(grid[x][y]==INACTIVE)
                            grid[x][y] = MINE;
                    }else{
                        if(grid[x][y]==INACTIVE)
                            grid[x][y]=ACTIVE;
                    }
                }
            }
            break;
        case "SCORE":
            System.exit(0);
            break;
        }
        if(output.length()>0)
            System.out.println(output);
    }

    static int size = 2;
    static int target = size/2;
    static int[][] grid = new int[size][size];

    static final int INACTIVE = 0;
    static final int ACTIVE   = 1;
    static final int BROKEN   = 2;
    static final int MINE     = 3;
}

To compile, it's javac Checkpoint.java. To run, java Checkpoint. You'll want to add/change the path to reflect wherever it is.

FaucetBot (in R)
Creates a bottleneck on the second line, and activate nodes on the path behind it.
infile <- file("stdin")
open(infile)
repeat{
    input <- readLines(infile,1)
    args <- strsplit(input," ")[[1]]
    if(args[1]=="BEGIN"){
        L <- as.integer(args[4])
        M <- N <- matrix(0,nrow=L,ncol=L)
        x0 <- sample(2:(L-1),1)
        }
    if(args[1]=="DESTROY"){
        if(args[2]==0){
            X <- x0
            Y <- 2
            }else{
                free <- which(M[,2] == 0)
                mine <- which(N[,2] == 1)
                X <- free[which.min(abs(free-mine))]
                Y <- 2
                }
        if(length(X)){cat(sprintf("VERTEX %s,%s\n",X-1,Y-1))}else{cat("NONE\n")}
        flush(stdout())
        }
    if(args[1]=="BROKEN"){
        b <- strsplit(args[args!="N"][-(1:2)],",")
        o <- strsplit(args[3],",")[[1]]
        b <- lapply(b,as.integer)
        if(o[1]!="N") N[as.integer(o[1])+1,as.integer(o[2])+1] <- -1
        for(i in seq_along(b)){M[b[[i]][1]+1,b[[i]][2]+1] <- -1}
        }
    if(args[1]=="ACTIVATE"){
        if(args[2]==0){
            broken <- which(M[,2] == -1)
            free <- which(M[,2] == 0)
            X <- free[which.min(abs(broken-free))]
            Y <- 2
            }else{
                y <- 3
                X <- NULL
                while(length(X)<1){
                    lastrow <- which(N[,y-1]==1)
                    newrow <- unlist(sapply(lastrow,function(x)which(M[,y]==0 & abs((1:L)-x)<2)))
                    if(length(newrow)){
                        X <- sample(newrow,1)
                        Y <- y
                        }
                    y <- y+1
                    if(y>L){X <- x0; Y <- 1}
                    }
                }
        cat(sprintf("VERTEX %s,%s\n",X-1,Y-1))
        flush(stdout())
        }
    if(args[1]=="OWNED"){
        b <- strsplit(args[args!="N"][-(1:2)],",")
        o <- strsplit(args[3],",")[[1]]
        b <- lapply(b,as.integer)
        if(o[1]!="N") N[as.integer(o[1])+1,as.integer(o[2])+1] <- 1
        for(i in seq_along(b)){M[b[[i]][1]+1,b[[i]][2]+1] <- 1}
        }
    if(args[1]=="SCORE") q(save="no")
    }

If I didn't screw up, the final configuration should be something like:
........    .a..aa..
..aaa...    ..aaa...
.xxaxx..    xxxaxxx.    etc.
........    ........

Command is Rscript FaucetBot.R.

Watermelon, Java
Attempts to draw watermelons on the grid.
import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

public class Watermelon {

    private static int numberOfBots;
    private static int numberOfTurns;
    private static int sideLength;

    private static int turn = 0;

    private static int[][] theGrid;

    private static final int INACTIVE = -2;
    private static final int BROKEN   = -1;
    private static final int MINE     =  0;
    private static final int ACTIVE   =  1;

    private static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    private static PrintStream out = System.out;

    public static void main(String[] args) throws IOException {
        while (true){
            String[] input = in.readLine().trim().split(" ");
            String instruction = input[0];
            switch (instruction){
                case "BEGIN":
                    begin(input);
                    break;
                case "DESTROY":
                    destroy(input);
                    break;
                case "BROKEN":
                    broken(input);
                    break;
                case "ACTIVATE":
                    activate(input);
                    break;
                case "OWNED":
                    owned(input);
                    break;
                default:
                    return;
            }
            out.flush();
        }
    }

    private static void begin(String[] input) {
        numberOfBots = Integer.parseInt(input[1]);
        numberOfTurns = Integer.parseInt(input[2]);
        sideLength = Integer.parseInt(input[3]);
        theGrid = new int[sideLength][sideLength];
        for (int x = 0; x < sideLength; x++){
            for (int y = 0; y < sideLength; y++){
                theGrid[x][y] = INACTIVE;
            }
        }
    }

    private static void owned(String[] input) {
        turn = Integer.parseInt(input[1]);
        for (int i = input.length - 1; i >= 2; i--){
            if (input[i].equals("N")){
                continue;
            }
            String[] coordinates = input[i].split(",");
            int x = Integer.parseInt(coordinates[0]);
            int y = Integer.parseInt(coordinates[1]);
            int player = i - 2;
            if (player == 0){
                theGrid[x][y] = MINE;
            } else {
                theGrid[x][y] = ACTIVE;
            }
        }
    }

    private static void activate(String[] input) {
        turn = Integer.parseInt(input[1]);
        double[][] values = new double[sideLength][sideLength];
        List<Point> pointList = new ArrayList<>();
        for (int x = 0; x < sideLength; x++){
            for (int y = 0; y < sideLength; y++){
                if (theGrid[x][y] == MINE || theGrid[x][y] == ACTIVE){
                    for (int x1 = 0; x1 < sideLength; x1++){
                        for (int y1 = 0; y1 < sideLength; y1++){
                            double distance = Math.pow(x - x1, 2) + Math.pow(y - y1, 2);
                            values[x1][y1] += 1 / (distance + 1);
                        }
                    }
                }
                pointList.add(new Point(x, y));
            }
        }
        pointList.sort(Comparator.comparingDouble((Point a) -> values[a.x][a.y]).reversed());
        for (Point point : pointList){
            if (theGrid[point.x][point.y] == INACTIVE){
                out.println("VERTEX " + point.x + "," + point.y);
                return;
            }
        }
        out.println("NONE");
    }

    private static void broken(String[] input) {
        turn = Integer.parseInt(input[1]);
        for (int i = 2; i < input.length; i++){
            if (input[i].equals("N")){
                continue;
            }
            String[] coordinates = input[i].split(",");
            int x = Integer.parseInt(coordinates[0]);
            int y = Integer.parseInt(coordinates[1]);
            theGrid[x][y] = BROKEN;
        }
    }

    private static void destroy(String[] input) {
        turn = Integer.parseInt(input[1]);
        double[][] values = new double[sideLength][sideLength];
        List<Point> pointList = new ArrayList<>();
        for (int x = 0; x < sideLength; x++){
            for (int y = 0; y < sideLength; y++){
                if (theGrid[x][y] == MINE){
                    for (int x1 = 0; x1 < sideLength; x1++){
                        for (int y1 = 0; y1 < sideLength; y1++){
                            double distance = Math.pow(x - x1, 2) + Math.pow(y - y1, 2);
                            values[x1][y1] -= 1 / (distance + 1);
                        }
                    }
                }
                if (theGrid[x][y] == ACTIVE){
                    for (int x1 = 0; x1 < sideLength; x1++){
                        for (int y1 = 0; y1 < sideLength; y1++){
                            double distance = Math.pow(x - x1, 2) + Math.pow(y - y1, 2);
                            values[x1][y1] += 1 / (distance + 1) / (numberOfBots - 1);
                        }
                    }
                }
                pointList.add(new Point(x, y));
            }
        }
        pointList.sort(Comparator.comparingDouble((Point a) -> values[a.x][a.y]).reversed());
        for (Point point : pointList){
            if (theGrid[point.x][point.y] == INACTIVE){
                out.println("VERTEX " + point.x + "," + point.y);
                return;
            }
        }
        out.println("NONE");
    }
}

Peacemaker, Java
Based on Manu's code.
Peacemaker search conflict zones (i.e. most BROKEN or ACTIVE vertex concentration) and activates a random vertex nearby.
import java.awt.Point;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.stream.IntStream;

public class Peacemaker {
    private static final int INACTIVE = 0;
    private static final int ACTIVE   = 1;
    private static final int BROKEN   = 2;
    private static final int MINE     = 3;

    private int size = 0;
    private int[][] grid = new int[size][size];
    private int startingPoint = 0;

    public static void main(String[] args) {
        new Peacemaker().start();
    }

    private void start() {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        while(true) {
            try {
                String input = reader.readLine();
                act(input);
            } catch (Exception e) {
                e.printStackTrace();
                System.exit(0);
            }
        }
    }

    private void act(String input) throws Exception {
        String[] msg = input.split(" ");
        String output = "";
        int turn;
        switch(msg[0]){
        case "BEGIN":
            size = Integer.parseInt(msg[3]);
            grid = new int[size][size];
            break;
        case "DESTROY":
            output = "NONE";
            break;
        case "BROKEN":
            update(msg, true);
            break;
        case "ACTIVATE":
            turn = Integer.parseInt(msg[1]);
            output = activate(turn);
            break;
        case "OWNED":
            update(msg, false);
            break;
        case "SCORE":
            System.exit(0);
            break;
        }
        if (output.length() > 0) {
            System.out.println(output);
        }
    }

    private String activate(int turn) {
        Random r = new Random();
        if (turn == 0) {
            startingPoint = r.nextInt(size);
            return "VERTEX " + startingPoint + "," + 0;
        } else {

            Point point = searchConflicts();

            int posX = point.x;
            int posY = point.y;

            while (grid[posX][posY] != INACTIVE) {
                 int previousX = (posX - 1 < 0 ? size - 1 : posX - 1);
                 int nextX = (posX + 1 > size - 1 ? 0 : posX + 1);
                 int previousY = (posY - 1 < 0 ? size - 1 : posY - 1);
                 int nextY = (posY + 1 > size - 1 ? 0 : posY + 1);

                 int choice = r.nextInt(4);
                 switch (choice) {
                     case 0: posX = previousX; break;
                     case 1: posX = nextX; break;
                     case 2: posY = previousY; break;
                     case 3: posY = nextY; break;
                 }
            }

            return "VERTEX " + posX + "," + posY;
        }
    }

    private Point searchConflicts() {

        int previousCellScore = 0;
        int cellX = 0;
        int cellY = 0;
        for (int i = 0; i < size; i++) {
            for (int j = 0; j < size; j ++) {
                if (previousCellScore < adjacentCellsScore(i, j)) {
                    cellX = i; cellY = j;
                    previousCellScore = adjacentCellsScore(i, j);
                }
            }
        }
        return new Point(cellX, cellY);
    }

    /*  Format of adjacent cells :
     *
     *   0 1 2
     *   3 . 4
     *   5 6 7
     */
    private int adjacentCellsScore(int x, int y) {

        int[] scores = new int[8];

        int previousX = (x - 1 < 0 ? size - 1 : x - 1);
        int nextX = (x + 1 > size - 1 ? 0 : x + 1);
        int previousY = (y - 1 < 0 ? size - 1 : y - 1);
        int nextY = (y + 1 > size - 1 ? 0 : y + 1);

        scores[0] = calcScore(previousX, nextY);
        scores[1] = calcScore(x, nextY);
        scores[2] = calcScore(nextX, nextY);
        scores[3] = calcScore(previousX, y);
        scores[4] = calcScore(nextX, y);
        scores[5] = calcScore(previousX, previousY);
        scores[6] = calcScore(x, previousY);
        scores[7] = calcScore(nextX, previousY);

        return IntStream.of(scores).reduce(0, (a, b) -> a + b);
    }

    private int calcScore(int x, int y) {
        int activeScore = 2;
        int mineScore = 1;
        int inactiveScore = 0;
        int brokenScore = 3;

        if (grid[x][y] == ACTIVE)
            return activeScore;
        else if (grid[x][y] == MINE)
            return mineScore;
        else if (grid[x][y] == INACTIVE)
            return inactiveScore;
        else if (grid[x][y] == BROKEN)
            return brokenScore;
        else
            return 0;
    }

    private void update(String[] args, boolean destroyPhase) {
        for(int i = 2; i < args.length; i++) {
            String[] tokens = args[i].split(",");
            if(tokens.length > 1){
                int x = Integer.parseInt(tokens[0]);
                int y = Integer.parseInt(tokens[1]);
                if (grid[x][y] == INACTIVE) {
                    if (destroyPhase) {
                        grid[x][y] = BROKEN;
                    } else if (i == 2) {
                        grid[x][y] = MINE;
                    } else {
                        grid[x][y] = ACTIVE;
                    }
                }
            }
        }
    }
}

@Zgarb Thanks, I should have resolved this issue now.

Peacemaker works now, and is included in the leaderboard. However, it doesn't seem to do much, so there are probably still some bugs left.

Actually, looking at your code, I think the problem is in the while loop of the activate method. You stop the search once you find a vertex that is not yours and not broken -- but it could be owned by someone else, so you cannot activate it.

@Zgarb I misread the specs and thought multiple players could activate the same vertex anytime. I guess I just have to change my search and look for inactive vertex only.

Random Builder, Python 3
This is a stupid example bot that never destroys anything, and tries to activate a random vertex every turn. Note that it doesn't need to check whether the vertex is inactive; the controller takes care of that.
import random as r

while True:
    msg = input().split()
    if msg[0] == "BEGIN":
        side_len = int(msg[3])
    elif msg[0] == "DESTROY":
        print("NONE")
    elif msg[0] == "ACTIVATE":
        print("VERTEX %d,%d"%(r.randrange(side_len), r.randrange(side_len)), flush=True)
    elif msg[0] == "SCORE":
        break

Run with the command
python3 random_builder.py

You may need to replace python3 by python depending on your Python installation. To do this, just edit the bots.txt file. I updated the controller, and there's no need to mess with file paths anymore.

Since your using python 3, instead of sys.stdout.flush() you can just do flush=True as an argument to print.

@matsjoyce Thanks, I didn't know that. I'll edit the repository version later.

Explorer, Python 3
Activation strategy:
Creates a heatmap based on the state of every node (active/inactive/broken) and chooses the node which would have the biggest expected heatmap-value per person if it would choose that one.
Destruction strategy:
Never destroys anything as that doesn't help the bot much.
import sys

class bd:

    def __init__(s, l):

        s.l=l
        s.b=[]
        s.v=[]
        s.m=[]
        s.bm=[]
        s.utd=False #up_to_date
        s.bmc=1

        for i in range(s.l):
            s.b+=[[]]
            s.v+=[[]]
            s.m+=[[]]
            s.bm+=[[]]
            for k in range(s.l):
                s.b[i]+=[0]
                s.v[i]+=[0]
                s.m[i]+=[0]
                s.bm[i]+=[s.bmc]

    def update(s):
        s.utd=True

        vu=[]
        vd=[]
        for i in range(s.l):
            vu+=[[]]
            vd+=[[]]
            for k in range(s.l):
                vu[i]+=[1]
                vd[i]+=[1]

        #spread up
        for i in range(s.l):
            vu[i][0]*=s.bm[i][0]

        for k in range(1,s.l):
            for i in range(s.l):
                sumv=vu[(i-1)%s.l][k-1]+vu[(i)%s.l][k-1]+vu[(i+1)%s.l][k-1]
                vu[i][k]*=sumv*s.bm[i][k]/3

        #spread down
        t=s.l-1
        for i in range(s.l):
            vd[i][t]*=s.bm[i][t]

        for k in range(s.l-2,-1,-1):
            for i in range(s.l):
                sumv=vd[(i-1)%s.l][k+1]+vd[(i)%s.l][k+1]+vd[(i+1)%s.l][k+1]
                vd[i][k]*=sumv*s.bm[i][k]/3

        #mult
        for i in range(s.l):
            for k in range(s.l):
                if s.b[i][k]==-1 or s.m[i][k]==1:
                    s.v[i][k]=float(-1)
                else:
                    s.v[i][k]=vu[i][k]*vd[i][k]/(s.b[i][k]+1)

    def add_act(s,al):
        s.utd=False

        for ind, ap in enumerate(al):
            i,k=ap
            s.b[i][k]+=1
            s.bm[i][k]=2*s.bmc
            #doesn't work alone WHY???
            if ind==0: s.m[i][k]=1

    def add_ina(s,il):
        s.utd=False

        for ind, ip in enumerate(il):
            i,k=ip
            s.b[i][k]=-1
            s.bm[i][k]=0

    def get_newact(s):
        s.update()
        vm=-28
        pm=None
        for i in range(s.l):
            for k in range(s.l):
                if s.v[i][k]>vm:
                    vm=s.v[i][k]
                    pm=(i,k)
        #doesn't work alone WHY???
        s.m[pm[0]][pm[1]]=1
        return pm

b=None

while True:
    inp=input()
    msg = inp.split()
    if msg[0] == "BEGIN":
        b = bd(int(msg[3]))
    elif msg[0] == "DESTROY":
        print("NONE")
    elif msg[0] == "BROKEN":
        pl=[]
        for m in msg[2:]:
            if m!='N':
                pl+=[tuple(map(int,m.split(',')))]
        b.add_ina(pl)
    elif msg[0] == "ACTIVATE":
        at=b.get_newact()
        print("VERTEX %d,%d"%(at[0], at[1]))
    elif msg[0] == "OWNED":
        pl=[]
        for m in msg[2:]:
            if m!='N':
                pl+=[tuple(map(int,m.split(',')))]
        b.add_act(pl)
    elif msg[0] == "SCORE":
        break

    sys.stdout.flush()

Annoyance, Bash
#!/bin/bash

declare -A avail
broken=
owned=

while read c p
    case "$c" in
        ACTIVATE|BROKEN) v=broken;;
        *) v=owned
    esac
    case "$c" in
        BEGIN)
            read b t n <<<"$p"
            list=$(
                eval "echo {0..$((n-1))},{0..$((n-1))}\$'\\n'" |
                shuf
            )
            for i in $list; do
                avail[$i]=1
            done;;
        DESTROY|ACTIVATE)
            for t in $(
                for i in ${!v}; do
                    [ "$i" != N ] &&
                    if [ "$c" = ACTIVATE ]; then
                        echo $(((${i%,*}+2)%n)),${i#*,}
                        echo $(((${i%,*}-2+n)%n)),${i#*,}
                    else
                        echo ${i%,*},$(((${i#*,}+1)%n))
                        echo ${i%,*},$(((${i#*,}-1+n)%n))
                    fi
                done |
                shuf
            ) $list; do
                [ "${avail[$t]}" ] && echo VERTEX $t && break
            done ||
            echo NONE;;
        BROKEN|OWNED)
            read x m $v <<<"$p";
            for i in $m ${!v}; do
                unset avail[$i]
            done;;
        SCORE)! :
    esac
do :;done

Tried to make the result looks more interesting.
Run with bash annoyance.sh.

Your bot prints all its inputs to STDERR. It's not forbidden or anything, just an annoyance (pun intended).

@Zgarb Sorry, I pasted the wrong version. Fixed.

Middle Man
I saw that some bots built from the top, and some from the bottom. This is the first (I think) to start in the middle and work up and down.
(it is not tested with the controller, so if it dose not work, let me know.)
class Node

  def self.set_size s
    @@grid = Array.new(s,Array.new(s,0))
  end

  def initialize x,y
    @x=x
    @y=y
  end

  def offset dx,dy
    return Node.new @x+dx,@y+dy
  end

  def state
    return -1 if @x<0 || @y<0 || @x>=@@grid.length || @y>=@@grid.length
    @@grid[@x][@y]
  end

  def state= n
    return -1 if @x<0 || @y<0 || @x>=@@grid.length || @y>=@@grid.length
     @@grid[@x][@y]=n
  end

  def active?
    state > 0
  end

  def open?
    state == 0
  end
  attr_reader :x,:y

  def to_s
    "VERTEX #{@x},#{@y}"
  end

  def scan_down
    ans = nil
    [0,-1,1].each do|offset|
      n = Node.new @x+offset,@y-1
      ans = (ans||n) if n.open?
      ans = (n.scan_down||ans) if n.active?
    end
    return ans
  end

  def scan_up
    ans = nil
    [0,-1,1].each do|offset|
      n = Node.new @x+offset,@y+1
      ans = (ans||n) if n.open?
      ans = (n.scan_up||ans) if n.active?
    end
    return ans
  end

end

input = gets.split
input.shift

BotCount = input.shift.to_i
Turns = input.shift.to_i
GridSize = input.shift.to_i

Node.set_size GridSize

midRow = GridSize/2

toDestroy = (0...GridSize).map{|i|Node.new i,midRow}
toDestroy.reject!{|n| n.x==midRow}

chain = []
Turns.times do
  gets;
  toDestroy.each{|x|
    if x.active?
      toDestroy.push x.offset 0,1
      toDestroy.push x.offset 1,1
      toDestroy.push x.offset -1,1
    end
  }
  toDestroy.reject!{|x|!x.open?}
  puts toDestroy.sample
  input = gets.split
  input.shift;input.shift
  input.each{|str|
    a,b = str.split ','
    (Node.new a.to_i,b.to_i).state=1
  }
  gets;

  if chain.length == 0
    n = Node.new midRow,midRow
    until n.open?
      n = Node.new n.x+1,midRow
    end
    puts chain[0]=n
  elsif rand>0.5
    n=nil
    loop do
      h=chain[0]
      n = h.scan_down
     break if !n
      chain.shift
    end
    h.unshift n
    puts n
  else
    loop do
      h=chain[-1]
      n = h.scan_up
      h.pop if !n
      brake if n
    end
    chain.push n
    puts n
  end

  input = gets.split
  input.shift;input.shift
  input.each{|str|
    a,b = str.split ','
    (Node.new a,b).state=-1
  }

end
gets
exit

Thank you for the submission! Unfortunately, this challenge has been dormant for almost half a year, and I'm currently unable to run most of the bots, since I don't have access to a computer where I could install the languages.

@Zgarb I understand. maybe someday I will answer a challenge in a reasonable time frame...


text:
Identifying the triangles
Counting the amount of triangles in a picture is a task commonly used in brain tests. You are given a picture that contains shapes consisting of triangles. You then must find all possible triangles in the picture.
Task
You are given a list of lines in a format of your choice. You must then output a list of triangles found in that
Input
You are given a list of lines, each given by four integer coordinates (eg. x1 y1 x2 y2). You may choose the input format, as long as it is clearly documented. Examples:
0 4 8 1
0 4 9 5
8 1 9 5
2 8 0 4
9 5 2 8

[[0, 4, 8, 1], [0, 4, 9, 5], [8, 1, 9, 5], [2, 8, 0, 4], [9, 5, 2, 8]]

Here's the same input as an image:

Another one, with intersections (only in one format to save space):
[[2, 1, 5, 0], [2, 1, 2, 7], [5, 0, 6, 6], [5, 0, 2, 7], [6, 6, 2, 1], [2, 7, 6, 6]]

Output
You must output a list of all triangles, each given by six floating-point coordinates (eg. x1 y1 x2 y2 x3 y3), in the picture specified by the input. These might not be integers, since the lines may cross at any point. You may choose the output format, as long as it is clearly documented. Example outputs for the example inputs above:
0 4 8 1 9 5
0 4 9 5 2 8

[[0, 4, 8, 3, 9, 5], [0, 4, 9, 5, 2, 8]]

[[2, 1, 5, 0, 2, 7], [2, 1, 5, 0, 6, 6], [5, 0, 6, 6, 2, 7], [2, 1, 6, 6, 2, 7], [2, 1, 5, 0, 3.674, 3.093], [5, 0, 6, 6, 3.674, 3.093], [6, 6, 2, 7, 3.674, 3.093], [2, 7, 2, 1, 3.674, 3.093]]

You may assume that

there are no edge cases where a line crosses an intersection but not any lines, like
[[0, 9, 1, 8], [1, 8, 2, 9], [2, 9, 3, 8], [3, 8, 4, 9], [4, 9, 0, 9]]

there are no angles over 179 degrees, like
[[0, 0, 0, 1], [0, 1, 0, 2], [0, 2, 0, 0]]

Rules

You may use any language you want.
No external resources must be used.
Standard loopholes apply.

Scoring
This is code-golf, so the shortest answer in bytes wins.

Is it sufficent to identify 3-cycles or do we have to handle more complex edge cases? For example the "pentagon" defined by [0,9],[1,8],[2,9],[3,8],[4,9] is actually a W with a line drawn across the top. Is that no triangles or 2 triangles?

@steveverrill Let's say that edge cases can be ignored.

Ok. And And [0,0],[1,0],[2,0],[1,2] A "quadrilateral" with one angle of 180 degrees. No triangles or 1 triangle?

That would not be a triangle, but you may assume that doesn't come either.

PostGIS, 162
I think this complies with the rules, It is a query for PostGIS, which is an extension of PostgreSQL.
The input is assumed to be a table of coordinates for each line called L
The output is a set of rows with the polygon definition for the triangles formed.
SELECT ST_AsText(D)FROM(SELECT(ST_Dump(ST_Polygonize(B))).geom D FROM(SELECT ST_Union(ST_MakeLine(ST_Point(A,B),ST_Point(C,D)))B FROM L)A)B WHERE ST_NPoints(D)=4;

In use it looks like the following
-- Create a table for the input
CREATE TABLE L (A INT, B INT, C INT,D INT);
INSERT INTO L VALUES(2, 1, 5, 0), (2, 1, 2, 7), (5, 0, 6, 6), (5, 0, 2, 7), (6, 6, 2, 1), (2, 7, 6, 6);

SELECT ST_AsText(D)FROM(SELECT(ST_Dump(ST_Polygonize(B))).geom D FROM(SELECT ST_Union(ST_MakeLine(ST_Point(A,B),ST_Point(C,D)))B FROM L)A)B WHERE ST_NPoints(D)=4;

-- Cleanup
DROP TABLE L;

The output is as follows
POLYGON((5 0,2 1,3.67441860465116 3.09302325581395,5 0))
POLYGON((6 6,5 0,3.67441860465116 3.09302325581395,6 6))
POLYGON((3.67441860465116 3.09302325581395,2 7,6 6,3.67441860465116 3.09302325581395))
POLYGON((2 7,3.67441860465116 3.09302325581395,2 1,2 7))

Mathematica 915 395 401 405
Update
This programming challenge is much more difficult than it first appears to be.
The present approach works with simple cases, where there is but a single intersection along the length of any line segment.  With multiple crossings along one segment, it is necessary to
keep track of all of the intersection points along each line and create new sub-segments (hence additional graph edges) connecting the new intersection to all the intersection points along the target line.
Despite that limitation, it may be worth sharing the logic underlying the current approach.

The input line segments are treated as regions. If they intersect, the centroid will be the coordinates of the intersection.
We need to eliminate those intersections that occur at the vertices of line segments.
Lines that do not intersect will have an indeterminate centroid.
Four new edges are created for each intersection point. They connect the intersection point to the four vertices of the two intersecting lines.
A graph such as the one below on the right is generated using both the old and new edges.
The vertices are the coordinates of the respective points.
Cycles, i.e., closed loops of three vertices will be triangles provided that the three vertices are not collinear.
Presently we check to see whether any "triangle" has an indeterminate area.  (For some reason it does not return an area of 0 for three collinear points.)

A simple example
Below are (a) the figure plotted in the coordinate plane and (b) the graph showing the given nodes as well as the intersection node, {114/23, 314/69}.  In the latter, the vertices are not located at the respective Cartesian coordinates.
It may appear that their are more edges in the right figure than in the left. But remember that there are overlapping graph edges on the left.  Each diagonal actually corresponds to 3 graph edges!

    f@w_ :=(h@{a_, b_, c_, d_} := (r = RegionCentroid@RegionIntersection[Line@{a, b}, Line@{c, d}];
     {r <-> a, r <-> b, r <-> c, r <-> d});
      Cases[FindCycle[Graph[Union@Join[w /. {{a_, b_Integer}, {c_, d_}} :> {a, b} <-> {c, d},
      Cases[Flatten[h /@ Cases[{Length[Union@#] < 4, #} & /@ (FlattenAt[#, {{1}, {2}}] & /@
      Subsets[w, {2}]),{False, c_} :> c]], Except[{Indeterminate, _} <-> _]]]], {3}, 50],
      x_ /; NumericQ[RegionMeasure@Triangle[x[[All, 1]]]]][[All, All, 1]]//N//Grid)

Each row below is a triangle.
f[{{{2,8},{8,1}},{{0,4},{8,1}},{{0,4},{9,5}},{{8,1},{9,5}},{{2,8},{0,4}},{{9,5},{2,8}}}]

A more complex example
f@{{{9, 5}, {0, -10}}, {{9, 5}, {0, 2}},  {{9, 5}, {2, -1}}, {{0, -10}, {2, -1}}, {{0, -10}, {-2, -1}}, {{-9, 5}, {0, -10}}, {{-9, 5}, {0, 2}}, {{-9, 5}, {-2, -1}}, {{0, 2}, {0, -10}}, {{-9, 5}, {2, -1}}, {{9, 5}, {-2, -1}}, {{-9, 5}, {9, 5}}}

Here's the graph corresponding to the input coordinates. The vertices are at their expected Cartesian coordinates. (If you run the golfed code it will display the vertices elsewhere while respecting the vertex labels and edges. For readability, I assigned the vertex coordinates using a smattering of additional code, not necessary for the solution.)

Here's the derived graph.
It includes the derived point of intersection (0,1/11), where some of the input lines cross.

The code found 19 triangles.  Nine of them have the point, (0,1/11) as one of the vertices.

Ok. It's now in the form of a function.

Java, 1051 1004
(Fully working program)
I thought this is a nice challenge not just to golf some code, but mainly to practice writing mathematical functions.
And to draw a "baseline" I made this one in Java *Waits for everyone to start laughing*.
Code
import java.util.*;class P{double x,y;static P l(double... i){double a=i[0],b=i[1],c=i[2],d=i[3],e=i[4],f=i[5],k,l,x=(k=i[7]-f)*(c-a)-(l=i[6]-e)*(d-b),n=(l*(b-f)-k*(a-e))/x,m=((c-a)*(b-f)-(d-b)*(a-e))/x;P p=new P();p.x=a+n*(c-a);p.y=b+n*(d-b);return(n>=0&n<=1&m>=0&m<=1&x!=0)?p:null;}public static void main(String[]p){Set<String>v=new HashSet();P q,w,e;Integer a,b,c,d,k,f,g,h,i,j,m,l,r,t,y,z;int[][]x=new int[l=p.length/4][4];for(c=0;c<l;c++){for(d=0;d<4;){x[c][d]=l.parseInt(p[c*4+d++]);}}z=x.length;for(r=0;r<z;r++){a=x[r][0];b=x[r][1];c=x[r][2];d=x[r][3];for(t=0;t<z;t++){if(t!=r){k=x[t][0];f=x[t][1];g=x[t][2];h=x[t][3];q=l(a,b,c,d,k,f,g,h);if(q!=null){for(y=0;y<z;y++){if(y!=r&y!=t){i=x[y][0];j=x[y][1];m=x[y][2];l=x[y][3];w=l(a,b,c,d,i,j,m,l);e=l(k,f,g,h,i,j,m,l);if(w!=null&&e!=null&&q.x!=e.x&q.y!=e.y&!v.contains(""+r+y+t)){v.add(""+r+t+y);v.add(""+r+y+t);v.add(""+t+r+y);v.add(""+t+y+r);v.add(""+y+r+t);v.add(""+y+t+r);System.out.printf("%s %s %s %s %s %s\n",q.x,q.y,w.x,w.y,e.x,e.y);}}}}}}}}}

Input
Space separated integers. In pairs of 4 (x1, y1, x2, y2)
2 1 5 0 2 1 2 7 5 0 6 6 5 0 2 7 6 6 2 1 2 7 6 6

Output (real output does not round to 3 decimals)
Each line contains one triangle Each line consist out of space separated floating points in pairs of 2 (x1, y1, x2, y2, x3, y3). (Note: the order of the 3 points that form the triangle is undefined.)
5.0 0.0 2.0 1.0 6.0 6.0
5.0 0.0 2.0 1.0 2.0 7.0
5.0 0.0 2.0 1.0 3.674 3.093
2.0 7.0 2.0 1.0 3.674 3.093
2.0 1.0 2.0 7.0 6.0 6.0
5.0 0.0 6.0 6.0 3.674 3.093
5.0 0.0 6.0 6.0 2.0 7.0
3.674 3.093 2.0 7.0 6.0 6.0

Explanation
I started to write a method to find the intersection between two not-infinite lines. The resulting method is for a Java style one pretty short (246). Instead of letting the method input consists out of 8 double's or two Points (P) I choose to use a arbitrary parameter to safe massive amounts of characters. To minimize the array operator usage each parameter used more than 2 times is placed in it's own variable.
static P l(double... i){double a=i[0],b=i[1],c=i[2],d=i[3],e=i[4],f=i[5],k,l,x=(k=i[7]-f)*(c-a)-(l=i[6]-e)*(d-b),n=(l*(b-f)-k*(a-e))/x,m=((c-a)*(b-f)-(d-b)*(a-e))/x;P p=new P();p.x=a+n*(c-a);p.y=b+n*(d-b);return(n>=0&n<=1&m>=0&m<=1&x!=0)?p:null;}

More explanation to be added... (this answer can probably be golfed even more)

BBC BASIC
Emulator at http://www.bbcbasic.co.uk/bbcwin/bbcwin.html
I'm expecting this to golf down into the 400's.
Input / Output
Every time the user enters a new line, the program checks if any new triangles have been created, and outputs them immediately, see below.
A new triangle is created wherever the new line intersects with two pre-existing lines that are also mutually intersecting (except when all three lines intersect at a point, which is a special case that has to be dealt with.)

Code
The main program is about as simple as can be. At the end is the function, which performs the complex task of detecting intersections, according to the formula in http://en.wikipedia.org/wiki/Line%E2%80%93line_intersection
The function returns zero if there is no intersection and a nonzero floating point number if there is. It also has a side effect: the coordinates of the intersection are appended to the string z$. Additionally, in BBC basic the variables of a function are visible to the main program provided the main program does not have a variable of the same name (even after the function has finished.)
Therefore the main program has access to the variables x and y, and m and n, which store the coordinates of the current and previous intersections. This is used to detect if we have really found a triangle and not just three lines intersecting at a point.
  DIM a(99),b(99),c(99),d(99)                                                    :REM declare 4 arrays to hold the ata
  y=0                                                                            :REM x and y are only initialized
  x=0                                                                            :REM to avoid a no such varialbe error later
  FOR i=0 TO 99                                                                  :REM for each input line
    INPUT a(i),b(i),c(i),d(i)
    FOR j=0 TO i-1                                                               :REM iterate through all combinations of 2 previous lines
      FOR k=0 TO j-1
        z$=""                                                                    :REM clear z$, three function calls on next line will write the triangle (if found) to it
        IF i>j AND j>k AND FNf(i,j)*FNf(i,k)*FNf(j,k)<>0 IF x<>m OR y<>n PRINT z$:REM to avoid printing the same triangle twice, print only if j,k,i in lexicographic order. Also reject if x,y (3rd FNf call) and m,n (2nd FNf call) are the same: this means a point, not a triangle.
      NEXT
    NEXT
  NEXT

  DEF FNf(g,h)                                                                   :REM returns zero if no intersection found, otherwise a floating point value
  m=x                                                                            :REM backup previous x and y
  n=y                                                                            :REM to use in test for point versus triangle
  p=a(g)-c(g)
  q=b(g)-d(g)
  r=a(h)-c(h)
  s=b(h)-d(h)
  t=a(g)*d(g)-b(g)*c(g)
  u=a(h)*d(h)-b(h)*c(h)
  e=p*s-q*r                                                                      :REM following method in wikipedia, calculate denominator of expression
  IF e<>0 x=(t*r-u*p)/e : y=(t*s-u*q)/e: z$=z$+" "+STR$(x)+" "+STR$(y)           :REM if denominator not zero, calculate x and y and append a string copy to z$
  IF (a(g)-x)*(c(g)-x)>0 OR (b(g)-y)*(d(g)-x)>0 OR(a(h)-x)*(c(h)-x)>0 OR(b(h)-y)*(d(h)-y)>0 e=0
  =e          :REM return e                                                      :REM previous line sets e to zero if the intersection falls outside the line segment. This is detected when both are on the same side of the intersection, which yields a positive multiplication result.

source: Stack Exchange

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

sort: votes


text:
Finding prime numbers without using "prime characters"
Your task, if you choose to accept it, is to write a program/function that accepts an integer \$N\$ as input. The program/function should output/return a list of the first \$N\$ prime numbers. But here's the catch: you are not allowed to use prime characters in your code. A prime character is a character whose Unicode code point is a prime number. In the printable ASCII range, these are:
%)+/5;=CGIOSYaegkmq

But the rule also applies to non-ASCII characters if your code uses those.

A valid input is an integer \$N\$ where \$0 < N \le T\$, where you can choose \$T\$, but it has to be greater than or equal to \$10000\$. \$T\$ does not have to be finite.
For invalid inputs (non-integers, integers out of range), throw an exception or output/return nothing/null.
An integer with leading/trailing whitespace as input is considered invalid.
An integer with a + as sign character as input is considered invalid.
An integer with leading zeros as input is considered valid.
If your language allows you to pass an already-parsed integer as input, the above parsing rules (except the range one) don't apply, because the int is already parsed.
The input is always base-10.
Use of built-in prime generators and primality testers (this includes prime factorization functions) is not allowed.
The source restriction is imposed on Unicode characters, but the byte counting for the score can be in another encoding if you wish.
The output can contain a single trailing newline, but this is not required.
If you output/return the prime number list as a string, then every prime number must be delimited by one or multiple non-digit char(s). You can choose which delimiter you use.
This is a code-golf challenge, the shortest code in bytes wins.

Stack Snippet to verify your code
You can use the below Stack Snippet to verify that your code does not contain prime chars:

var primes=[],max=10000;for(var i=2;i<=max;i++){primes.push(i);}for(var N=2;N<Math.sqrt(max);N++){if(primes.indexOf(N)===-1){continue;}primes=primes.filter(function (x){return x===N||x%N!==0;});}function setText(elem,text){var z=('innerText' in elem)? 'innerText' : 'textContent';elem[z]=text;}function verify(inputCode,resultSpan){var invalidChars=[];var success=true;for(var i=0;i<inputCode.length;i++){var cc = inputCode.charCodeAt(i);if (cc>max){setText(resultSpan,"Uh oh! The char code was bigger than the max. prime number calculated by the snippet.");success = false;break;}if (primes.indexOf(cc)!==-1){invalidChars.push(inputCode[i]);}}if (invalidChars.length===0&&success){setText(resultSpan, "Valid code!");}else if(success) {  var uniqueInvalidChars = invalidChars.filter(function (x, i, self){return self.indexOf(x)===i;});setText(resultSpan, "Invalid code! Invalid chars: " + uniqueInvalidChars.join(""));    }}document.getElementById("verifyBtn").onclick=function(e){e=e||window.event;e.preventDefault();var code=document.getElementById("codeTxt").value;verify(code,document.getElementById("result"));};
Enter your code snippet here:
<textarea id="codeTxt" rows="5" cols="70"></textarea>
<button id="verifyBtn">Verify</button>

It's pretty cruel that ; happens to be banned...

If primality testers aren't allowed, what about prime factorization functions.

@Maltysen From prime factorization functions, you can very quickly see whether a number is a prime or not, so I'm afraid that's disallowed. I'll clarify that.

Are we mandated to throw out some of these invalid inputs? For instance, if our language's string->int function allows a leading +, it seems disappointing to be required to manually throw these out.

@Runer112 You don't have to throw. As the rules state, you can also simply exit/return with no/empty output.

@ProgramFOX My point is, I'm going to have to add code to disallow what my language thinks (and I think) is a valid integer, but that your spec doesn't. And that seems a bit silly. I would suggest that the spec presented a more minimal set of valid/invalid input rules, and left the rest up to user's choice.

I got all excited about this and started on a solution, then realized closed parens are disallowed. Well, I'm out.

@Runer112 I changed the rules and now the input range is 0 < N <= T, where you can choose T, but it has to be greater than or equal to 10000. This rule change does not invalidate existing answers.

@ProgramFOX But we're still required to treat inputs that start with a + as invalid, even if our language's string->int function parses them fine?

@Runer112 Yes, you are. I will not drop that requirement, because it makes a nice addition and makes the challenge a bit more difficult.

Do we have to treat multiple lines of input as invalid as well?

@Runer112 How do you mean, multiple lines? Just trailing/leading newlines, or the integer split up?

@ProgramFOX I assumed trailing/leading, since if the integer was split up, then it seems that the input couldn't be treated as a valid integer anyways.

@Runer112 In that case, it's invalid. I'll change "spaces" into "whitespace".

I bet it's possible in Brainfuck. But you'd have to use subtraction instead of addition. Nvm, it'd be easier to just use Blub.

In groovy, got this far it.findAll{x->y=2..x**0.5;y.every{x%it}} then realized % was one of the characters excluded and facepalmed...

In JavaScript, you can't possibly assign an object, as = is banned, so you'd have to make it a single expression. In addition, you can't call a function with () (or make a function in any way), so you'd have to use tagged templates. I'd be surprised if it's actually possible. (Note: You can start by getting input with pro\u006dpt`` .)

@ETHproductions You can make a function using Function`...` . It's not very useful since it can't take any arguments, but it is possible. You could probably use some sort of escape sequence inside that template literal to assign to variables as well.

CJam, 19 18 30 34 33 19 17 21 20 bytes
Try it online.
{_3\#,2>__ff*:~-<N*}

This is probably one of the most horribly inefficient algorithms I've ever implemented. But I did it for the size!
My answer consists of a code block, which acts like an anonymous function in CJam. Run it with an integer immediately preceding it on the stack, and the resulting list is dumped onto the stack. I treat the upper bound on the input as infinite so I don't have to check that bound.
My algorithm starts by raising 3 to the inputth power, which is guaranteed to give a number larger than the input-th prime if the input is valid. Then a list of the integers from 2 to this number minus one is generated, which is a large enough swath to contain all the prime numbers we want. To get rid of the composite numbers... sigh... we create a list of every pairwise product, which should generate all composite numbers from 4 to some stupidly large value, large enough for our purposes. Then it's just a matter of removing every element from the original list that is in this composite list, trimming it down to the first input elements, and joining the elements with the newline character.
The algorithm should work for any input. However, whether or not the interpreter/computer has enough memory or time is a whole other question, because the time and space requirements are exponential with respect to the input. So if the input is larger than about 5 for the online interpreter or about 8 for the offline one, then the answer to that question is probably no.

heh, at 17 you have a prime number of bytes in your answer.

Why do you need a S*?

@user23013 Invalid inputs less than 1 still feed through the algorithm, they just produce an empty list. But that's not a legal output for them, so I join the list elements with spaces to produce an empty output for these invalid inputs.

I've noticed this, isn't S a prime character?

It is a prime character. I know I'm over 2 years late on saying this, but this answer should be invalid

@ZacharyT You're right, I don't know how I and everybody else missed that. I have amended the solution to use N instead. This results in the output being newline-delimited instead of space-delimited.

Thanks, I replaced my downvote with an upvote now, nice work! (I came back here to see if anything's changed, then I realized that I left a trailing space at the end of one of my lines)!

Python 3.7+, 183 bytes
for E,E.__clªss_ᵍᵉtitᵉᵐ__ in[__builtins__.__loªdᵉr__,ᵉxᵉc],:E[f'd{101:c}f F(n\x29:\n p,f\x3d1,1\n whil{101:c} n>0:p,f\x3d-~p,f*p*p\73n-\x3df{37:c}p>0!\x3dprint(p\x29']

Try it online!
Assumes an infinite upper bound, takes integer input via function argument, and prints the primes on separate lines.
Without substitutions for characters (except \n):
for E,E.__class_getitem__ in[__builtins__.__loader__,exec],:E[f'def F(n):\n p,f=1,1\n while n>0:p,f=-~p,f*p*p;n-=f%p>0!=print(p)']

The string in the above code:
def F(n):
 p,f=1,1
 while n>0:p,f=-~p,f*p*p;n-=f%p>0!=print(p)

Python 3.7 added the __class_getitem__ magic method: if A is a class, then A[x] calls A.__class_getitem__(x). Assigning exec to this attribute of a class allows us to call it without ). Unfortunately, we cannot create our own class without either using the class keyword (a) or calling the type function ()), so we must use a built-in class. The only one that allows the assignment to be made without error is __builtins__.__loader__.
Python normalizes all identifiers to NFKC, and this allows us to spell __class_getitem__, __loader__, and  exec without using any of the letters aegm. The exact substitutions are U+00AA for a, U+1D49 for e, U+1D4D for g, and U+1D50 for m. We use a for loop to make assignments without using =, and these let us call exec via E[f'...'] in the body.
Inside the string passed to exec, we use octal (\73 instead of ;), hex (\x3d instead of =), and decimal ({37:c} instead of %) escapes for banned characters. The code simply tests the primality of each positive integer using Wilson's theorem. A function was used instead of a lambda as the recursion limit causes the latter to stop working well below 10000.

Welcome to Code Golf, and nice first answer!

Java. 474 bytes
i\u006dport j\u0061v\u0061.util.*\u003bvoid b(int b\u0029{Lon\u0067 c\u003d2L,d,f[]\u003d{}\u003bfor(f\u003dArr\u0061ys.copy\u004ff(f,b\u0029,Arr\u0061ys.fill(f,0L\u0029\u003bb-->0\u003b\u0029for(d\u003d0L\u003bf[b]<1\u003bf[b]\u003dd<1?c:f[b],d\u003d0L,c\u002b\u002b\u0029for(lon\u0067 h:f\u0029d\u003dh>0&&c\u002fh*h\u003d\u003dc?1:d\u003bj\u0061v\u0061x.x\u006dl.bind.JAXB.un\u006d\u0061rsh\u0061l(""\u002bArr\u0061ys.\u0061sList(f\u0029,Lon\u0067.cl\u0061ss\u0029\u003b}

Takes input via function argument, outputs via thrown exception.
Indented:
i\u006dport j\u0061v\u0061.util.*\u003b
void b(int b\u0029{
    Lon\u0067 c\u003d2L,d,f[]\u003d{}\u003b
    for(f\u003dArr\u0061ys.copy\u004ff(f,b\u0029,Arr\u0061ys.fill(f,0L\u0029\u003bb-->0\u003b\u0029
        for(d\u003d0L\u003bf[b]<1\u003bf[b]\u003dd<1?c:f[b],d\u003d0L,c\u002b\u002b\u0029
            for(lon\u0067 h:f\u0029
                d\u003dh>0&&c\u002fh*h\u003d\u003dc?1:d\u003b
    j\u0061v\u0061x.x\u006dl.bind.JAXB.un\u006d\u0061rsh\u0061l(""\u002bArr\u0061ys.\u0061sList(f\u0029,Lon\u0067.cl\u0061ss\u0029\u003b
}

Escaped characters removed:
import java.util.*;
void b(int b){
    Long c=2L,d,f[]={};
    for(f=Arrays.copyOf(f,b),Arrays.fill(f,0L);b-->0;)
        for(d=0L;f[b]<1;f[b]=d<1?c:0,d=0L,c++)
            for(long h:f)
                d=h>0&&c/h*h==c?1:d;
    javax.xml.bind.JAXB.unmarshal(""+Arrays.asList(f),Long.class);
}

Explanation:
Long c,d,f[]={};                                                //Initialize variables.

for(f=java.util.Arrays.copyOf(f,b),Arrays.fill(f,0L);b-->0;)
    f=java.util.Arrays.copyOf(f,b),Arrays.fill(f,0L)            //Initialize f to an array of 0's.
                                                     b-->0      //Iterate over the first b primes.

for(d=0L;f[b]<1;f[b]=d<1?c:0,d=0L,c++)
    d=0L                        d=0L                            //Initialize d to 0.
         f[b]<1                      c++                        //Increment c while the b'th prime is 0.
                f[b]=d<1?c:0                                    //If d = 0, the b'th prime = c, else continue.

for(long h:f)                                                   //Iterate over all found primes.

d=h>0&&c/h*h==c?1:d;
  h>0                                                           //Ignore non-found primes.
       c/h*h==c                                                 //Equivalent to c%h==0
               ?1:d                                             //If h is prime and c is divisible by h, d = 1. Otherwise d stays unchanged.

javax.xml.bind.JAXB.unmarshal(""+Arrays.asList(f),Long.class)   //Print solution to stderr
javax.xml.bind.JAXB.unmarshal(                   ,Long.class)   //Prints what's contained to stderr.
                                 Arrays.asList(f)               //Convert f to list.
                              ""+                               //Convert to string.

My original solution used a return statement. After asking this question on StackOverflow, regettman was kind enough to provide a way to output/return without using prime letters.
As usual, suggestions are welcome :)

+1. That had to be really hard for you and rgettman to figure out. Very impressive. :)

Ruby, 74
->n,*o{o<<[2..n*n][0].find{|x|!o.find{|y|1.>x.^y.*x.div y}}until o[n-1]
o}

Explanation:
*o initializes an empty output array. until it has n items, we find the smallest number >=2  that doesn't divide any item currently in o, then add it to o. To test for division, yikes. All the good operators are disallowed, and I can't even use divmod. Best I could see was to use x.div y, which takes x divided by y and rounds down, then multiply that by y again. If it equals x, there was no rounding, so y divides x. 1.>x.^ is an equality test, checking whether the result of xor is 0. The . before every operator is because you can't mix .-free operator calls and parenthesis-free method calls.
Edit: The range-checking specifications were added after I posted this, I think. To comply requires 79 characters:
->n,*o{o<<[*2..-~n*n].find{|x|!o.find{|y|1.>x.^y.*x.div y}}until o[n-1]||n<1
o}

CJam, 38 37 30 bytes
{_~2#,2>\{(\{1$37c~},\p}*'<(~}

Try it here
I think this should comply with all the rules and works for any non-negative N (i.e. T is infinite). It's horribly inefficient though, so don't try it for large numbers.
This is a block - the closest thing to an (unnamed) function - which expects an integer on the stack, prints all the prime numbers and leaves the stack without its input. For all invalid inputs it will either throw an error or print nothing.
Most of the code is input validation, followed by the sieve of Eratosthenes. I only needed to work around the input restriction in 3 places:

) is increment in CJam. I needed that once, but could replace it with ~ (bitwise complement) because I was squaring the numbers afterwards anyway.
% is modulo. I'm using 37c~ instead, which first creates the character % and then eval's that. This makes the code a lot slower.
; pops and discards an element from the stack. I need to do this at the end. Instead I'm using '<(~ which pushes the character <, decrements it and eval's that.

I thought that, given all the input parsing rules, we're not allowed to just take in an already-parsed integer.

@Runer112 We're allowed to write "a function which accepts an integer". Not "a function which accepts the string representation of an integer".

Bash + coreutils, 227 bytes
printf -vb br`dc<<<Di14B8209P`
printf -vc -- $[$1-0]
[ "${1#$c}" -o $c -lt 1 ]||{
for i in {2..104729}
{
for f in `jot $[i-1] $[i-1] 1`
{
[ 0 -lt `dc<<<"$i $f~p"` ]||$b
}
[ $f -lt 2 ]&&printf $i\ &&: $[c--]
[ $c -lt 1 ]&&$b
}
}

This was quite tricky.  Some things I ran into:

Most loops (while and until) are unusable because they most close with done which is a shell keyword and cannot be the result of a variable expansion (unless eval is used, but that is out too).  The only usable loop is for/in which allows {/} instead of do/done.  for (( ; ; )) is also not usable.
= is out, so we need another way to assign variables.  printf -v is good for this.
We know that p(10000) is 104729 so for the outer loop for potential primes we can simply loop from 2 to 104729 and break once we have enough primes
jot generates the list of potential factors in the inner loop.  If a potential factor divides a potential prime, then it is not prime and we break out early
Fortunately break is a shell builtin and not a keyword, so may be generated as a result of an expansion.  dc converts a base 13 number to the bytestream eak.
To check if a potential factor divides a potential prime, we cannot use the usual / or % shell arithmetic operators.  So this is outsourced to dcs ~ operator, which pushes quotient and remainder to the stack.
-lt - less-than - is the only usable shell comparison operator.
echo is no use for output.  printf works though as long as we avoid %

Getting the input validation right is a bit of a pain.  This returns nothing in the case of invalid input.
Output:
$ ./primenoprime.sh 10
2 3 5 7 11 13 17 19 23 29 $

Rust, 2720 1695 bytes
|n|for i in 0..n{if i<3&&i>1||i&1>0&&0<[0x2196820D864A4c32816D129A64B4cB6Eu128,0x4A2882D129861144A48961204A0434c9|1<<28,0x148A48844224064B0834992132424030|1<<80,0x64048928124108A00B40B4086c304204|1<<0|1<<84|1<<120,0xc02104c94112422180124496804c3098,0x220824B0826896810804490000982D32|1<<104,0x69009244304340069004264940A28948|1<<36,0x86122D22400c06012410DA408088210,0x14916022c044A0020110D301821B0484,0x4cA2100800422094092094D204A6400c|1<<84,0x34c108144309A24A48B081041018200|1<<28|1<<64,0x241140A2180032402084490880422402|1<<8|1<<20|1<<68,0x29260008360044120A41A00101840128|1<<72,0xc20c26484822006D10100480c0618283|1<<100,0x10c02402190024884420482024894810|1<<44|1<<7*8|1<<104,0x60901300264B0400802832cA01140868,0x430800112186430c32100100D0248082|1<<16,0x24880906002D20430092900c10480424,0x4000814196800880430082090932c040|1<<60,0x926094022080c3292048489608481048|1<<4*13,0xA04204901904004A0104422812000|1<<7*8,0x800084424002982c02c801348348924|1<<96,0x1864328244908A0004D0048442043698|1<<28|1<<112,0x861104309204A44028024001020A0090,0x4424990912486084c90804422c004208|1<<36,0x4040208804321A011000211403002400|1<<88,0xA2020c90116802186030014084c30906,0x8801904800841028224148929860004,0x120100100c061061020004A442681210,0x140128040A0c94186412422194032010|1<<7*8,0x4882402D20410490014000D040A40A29,0x822902002484490424080130100020c1|1<<76,0xA0cA0006112100104816814802486100|1<<20,0x2414480906810c044200B09104000240|1<<120,0x84420004802c10c860A00A011242092|1<<16|1<<112,0x12824414814804820022130406980032,0x2c00D86424812004D028804340101824,0x180110c04120cA41020000A241081209,0x48044320240A08320941220A41804A4,0x820104128864008A6086400c001800|1<<96][i>>8]&1<<{[i&{1<<8}-1][0]>>1}{print!{"{}
",i}}}

Try it online!
Lookup table generator
Yikes, I'm fairly confident rust doesn't even count as primitive recursive with the restrictions, because mutability and function calls are disallowed, meaning there is no way to maintain state across loop iterations. Works up to 10111.
My strategy was to form a lookup table by packing the primality of every odd number into array of 128 bit integers, and then just using a good old fashioned mask and shift to recover the value. The 5s in the hexadecimal representation are dealt with by removing the 1 bit and orring it in at runtime. To deal with operator precedence issues, I abused the fact that blocks are also expressions, so I can use curly braces instead of parentheses.

Haskell, 90 bytes
\n->[fst c|c<-zip[p|p<-[2..],not$or[b>p-1&&b-1<p|b<-[u*v|u<-[2..p-1],v<-[2..p-1]]]][1..n]]

This is an anonymous function which takes an integer n as input.
How it works: [p|p<-[2..],not$or[b>p-1&&b-1<p|b<-[u*v|u<-[2..p-1],v<-[2..p-1]]]] (first example of prime number one-liners at the Haskell wiki but with the elem function replaced) creates an infinite list of primes. zip it with the numbers from 1to n to make a list of (prime, seq. number) pairs. Remove seq. number, again. Result is a list of primes of length n.

Rust, 64897 bytes
|n|println!{"{:?}",&[2,3,6-1,7,11,13,17,19,23,29,31,37,41,43,47,60-7,0x3b,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,0x97,0x9d,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,0xfb,0x101 ...}

(code snipped due to character limit, full solution here)
The following rust features become unavailable due to the prime restriction:

function calls, as they require ')'
regular bindings, since they require let (e)
macro definitions, they require macro-rules! (a,e,m)
match statements, they require match (a,m) and => (=)
mutability, since it's always introduced with the mut keyword (m).
return (e), break (a,e), continue (e)
else (e)

What you can technically use:

if. But without else, they're useless in expression contexts, so only good for side effects.
macros. Standard macros like print! are usually followed by (), but it's actually legal to use {} or [] instead. Without this, the task would be impossible.
closures, in the most narrow sense. You can't call them (requires ()) or bind them(requires let), but you can define a single non-recursive one. Without this, the task would obviously become impossible.
structs.
for loops. These are promising, since they actually allow variable binding, and they take an iterator, which can still be defined with the range syntax. The iterator can even be an expression.
Builtin operators, except +, % and /. The short-circuiting logical operators seem promising.

I simply couldn't make anything Turing-complete with these tools. I'm sorry. All that was left was to include the full first 10000 primes, cleaned of 5's. At least you can slice it and have a valid solution, in the most narrow sense possible.
I very much would like experts on Turing tarpit diving (or on Rust!) to tell me if I could have done anything better!

GNU APL, 75 68 67 65 59 56 55 characters
⎕IO must be 1.
∇z←p n
z←2,j←3
j←j--2
→2×⍳∨⌿1>z|j
z←z,j
→2×⍳n>⍴z
z←n↑z∇

I came back on this months later realizing that I had an extra space!

Is this in APL encoding or UTF-8? If you convert it to APL encoding (and it's valid) it would be much shorter in bytes.

UTF-8. Yeah, but at those low character points, there's going to be more primes.

To be exact, it's now byte counted in APL, but it's restriction on source is Unicode. (I realized the challenge allowed non-Unicode byte counts)

Jelly, 9 bytes
2ḍƇ`L<3Ʋ#

Try it online!
The character codes are [50, 7693, 391, 96, 76, 60, 51, 434, 35]
How it works
2ḍƇ`L<3Ʋ# - Main link. Takes N on the left
       Ʋ  - Define a monad f(k):
  Ƈ       -   Filter the range [1, 2, ..., k] on the following:
 ḍ `      -     Divides k cleanly?
    L     -   Length
     <3   -   Less than 3?
2       # - Count up k = 2, 3, 4, ... until n integers return true.
            Return those integers

JavaScript (V8), 131 bytes
[].fill.constructor`M${`for(N\x3D1\x3bM\x3bn-N||--M-print(n\x29\x29for(n\x3Di\x3DN-\x3D-1\x3bi-->2\x3b\x29n\x2fi-~~[n\x2fi]||n--`}`

Try it online!

Pyth - 12 bytes
Uses pyth's prime factorization function to see if # is prime. Uses !tPT trick suggested to me at my answer for primes under million problem.
<f!tPTr2^T6Q

Since the filter only works for primes under n and not first n, I just looked up the inverse of pi(x) for 10,000 and got 104,000 so I use primes under 10⁶ and get first n. This doesn't actually run, so you should test by replacing ^T6 with ^T3 and restrict n to under 1000. Input from stdin and output to stdout.
<          Q     Slice first n
f     r2^T6      filter on range 2->10⁶
 !               Logical not (gives true if tail is empty)
  t              Tail (all but first, so gives empty if prime fact is len 1)
   PT            Prime factorization of filter var (len 1 if num is prime)

From the rules: "Use of built-in prime generators and primality testers is not allowed."

@Runer112 Yeah but this is not a primality tester, is prime factorization, is on the border of the rules. I should probably ask if this is allowed.

@Maltysen "Use of built-in prime generators and primality testers (this includes prime factorization functions) is not allowed" - seems pretty clear to me.

@DigitalTrauma the clarification "(this includes prime factorization functions)" was added after this answer was posted.

MartinBüttner True.  I guess its up to @ProgramFOX'es discretion.

05AB1E, 11 bytes
∞¦ʒDÑPQ}sôн

Input as integers.
Try it online or verify it's valid, and some test cases.
Or 14 bytes if we include string inputs, and comply to the other rules:

Non-integer strings; leading whitespaces; or leading + are invalid
Leading 0 are valid

∞ʒDÑPQ}s0ì>ôн¦

Try it online or verify it's valid, and some test cases.
Explanation:
∞        # Push an infinite positive list: [1,2,3,...]
 ¦       # Remove the leading 1: [2,3,4,...]
  ʒ      # Filter it by:
   D     #  Duplicate the current integer
    Ñ    #  Pop and push a list of its divisors
     P   #  Take the product of this list of divisors
      Q  #  Check if it's still the same as the duplicated integer
         #  (only if the divisors are {1,value}, the value will be a prime)
  }s     # After the filter: swap so the (implicit) input-integer is a the top
    ô    # Split the infinite list into parts of that size
     н   # Pop and leave just the first part

For the program with additional string input validation:

The 0ì will prepend a leading "0" to the input (to fix the test cases with leading +, which would otherwise be interpret as integers);
The > will then increase the string-integer by 1 (implicitly converting it to an integer if it's valid first), because we haven't removed the leading 1 with ¦ yet;
The ¦ will then:

Remove the leading 1 from the list for valid inputs;
Or remove the 1 from itself, leaving an empty string for invalid inputs. Because the s0ì>ô will have been no-ops, after which н will leave not the first part, but the first integer in the list, which is the 1.

Minor notes:

Uses 05AB1E encoding, with the following codepoint-integers.
ôн could have been £, but unfortunately £ with code-point 163 is a prime.
Even if prime-builtins were allowed, Å in the builtin Åp with code-point 197 is a prime as well. Although <ÝØ would in that case be a short 'valid' alternative: Try it online or verify it's 'valid', and some test cases. <Ý pushes a list in the range [0,input), whereas Ø converts each value in this list to their 0-based value'th prime.

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/


text:
Help me procrastinate on my computer repairs!
This challenge is brought to you by real (and tragic) inspiration. Recently, the number row on my keyboard has been a bit sporadic. The keys 1-9 work sometimes--but other times they have no result. As an avid programmer, this is horrible! (See that exclamation point? That's how you know they're working right now.) Not only do I often need the numbers themselves, but the symbols !@#$%^&*( are completely ineffective half the time as well! As a C programmer, rather than take time off my busy schedule of doodling around with code to fix my laptop, I've been more interested in working around the problem. Over the course of the past few weeks, slowly, all of the number literals in my code have been replaced with hexadecimal so that I don't have to go hunting around for numbers to copy and paste. However, some numbers aren't easy to type without the keys 1-9. For example, the number 1 cannot be written so simply in hexadecimal, and I've resorted to replacing 1s in my code with 0xF - 0xE. The only keys that are affected are 1-9, so I maintain full use of symbols like +, -, and /. However, I cannot use multiplication or parentheses, as * and ( are often broken. This leads to your challenge.
Input
An integer, n to stdin or your language's equivalent. If you wish, the integer may be preceded or followed by a new line or other whitespace character. Alternatively, you may receive input via a command line argument.
Your program should respond to negative input correctly, and be able to handle at least 32-bit signed integers.
Output
Your program should output, in some observable form, the shortest (in non-whitespace characters) possible way to write the number n as a sum, difference, or division of one or more hexadecimal values. There is more than one way to solve this problem, and there is no requirement that you favor any equal-length output over any other.
The output should be in the form A % A % A... where A is a hexadecimal value following 0x containing only digits A-F a-f, and % is one of of the symbols -+/. Let / describe integer division, not floating-point.
(Note that your output should result in n when evaluating divisions first, left to right, and then additions and subtractions, left to right, as is convention.)
Test Cases
Input Output

1
0xF - 0xE (or 0xF-0xE or 0xB-0xA or 0xd - 0xc or 0xF/0xF)
15
0xF
255
0xFF
30
0xF + 0xF

Scoring and Rules
This is code-golf. Your preliminary score is the number of bytes in your source file.
You may NOT use any of the digits 1-9 in your source.
You MAY use symbols !@#$%^&*( in your source, but each comes at a penalty of +20 to your score.
Your program may be replaced by a function that takes n as an argument as long as that function produces some form of human-readable output. Your function's return value does NOT count as output.
Standard loopholes are not allowed.
Lowest score wins! Good luck!
Did I goof something up formatting/questioning/clarity-wise? Let me know! This is my first submission to this site!

Is there an upper limit to the size of the integer? Also, will negative numbers be represented to some arbitrary precision (i.e. 32 bit)?

@FryAmTheEggman Edited the original post to clarify. Input may be negative, and your program should respond correctly to at least 32 bit input. Thanks!

Related: http://codegolf.stackexchange.com/a/32114/21348

This looks like a pretty solid spec to me, but if you'd like some feedback, I'd recommend posting it in the sandbox (for future challenges) so you can get feedback before you post it on main and people start working on it.

Integer or floating point division?

@edc65 Since the syntax of the output is largely based on C, I'll edit the post to specify integer division.

@Martin Büttner Yes, functions will be allowed, but output cannot be in the form of a "return" or similar. Output must be to stdout, or another readable format.

JavaScript 287 (187+20*5) 295 (195 +20*5) 338 (198 + 20*7)
A function that check every possible combinations of the 6 allowed hex digits (0xA to 0xF) and the 3 allowed operators.
Output via popup and not returning a value, as requested.
I used [] to group comma separated expression but could not avoid 5 7 open brackets for loops and function calling.
To avoid digits there are variables A,B,C for 1,2,3 (this makes the code even more obscure)
Edit code revised focusing on avoiding '('. Removed ifs and explicit RegExp creation
Beware: this function is incredibly slow, it will exceed the time limit for a script in FireFox, even for small input like 90.
To enumerate all the possible expression, I use number starting at 3 and going up forever.  Digits encoding:
  0,1,2 are the operators +,-,/
  4 to 9 are the hex digits A..F
  3 is not allowed
Each number is checked with a regexp /3|[0-2]{2}/ to avoid the digit 3 and having 2 consecutive operators (the check also avoid traling and leading operators - see code)
The resulting string is something like 0xA + 0xA - 0xD that is valid javascript, so I use eval to evaluate it. Unfortunatley the '/' operator is floating point and not integer in JavaScript, so I'm not 100% sure that the result are correct event casting to integer the final result (but I am quite confident, given that a small rounding error can not be amplified by a '*')
F=x=>{
  for(A=-~0,B=A+A,i=C=A+B,j=0;j?x-~~eval(L):A;)
  {
    j=++i+'0',k=0+j;
    for(c of~k.search(C+'|[0-'+B+']{'+B+'}',L='',w='0x')?j='':j)
      c>C?w+=' ABCDEF'[c-C]:[L+=w,w=' '+'+-/'[c]+' 0x']
  }
  alert(L)
}

Something else
Now, something funnier. I used an oversimplified expressione parser to avoid the eval call and, amusingly, that turned out to be a lot faster.
The parser is really simplified, in a real parser V and O should be arrays containing the pending values stack and the pending operators stack. Here V is the single pending value (and also the return value) and O is a string with at most 2 characters. P contains the operators precedence table, for '-+/' => '112'
This scores 275 + 4*20 => 355
F=x=>{
  for(A=-~0,B=A+A,i=C=A+B,D=A+C,j=0,P=''+A+A+B;j?x-V:A;)
  {
    j=++i+'0',k=0+j;
    for(c of~k.search(C+'|[0-'+B+']{'+B+'}',v=V=O=L='',w='0x')?j='':j)
      c>C?
        w+='ABCDEF'[v<<=D,v+=D+A-~c,c-D]
      :[
          P[O[0]]>=P[c]?[v=O>A?V/v|0:O>0?V+v:V-v,O=c]:O=c+O,
          L+=w,w=' '+'-+/'[c]+' 0x',V=v,v=0
      ]
  }
  alert(L)
}

Test In Firefox/FireBug console, change alert with return (a lot more usable)
;[0, 1, 15, 255, 30].forEach(x=>console.log(x,F(x)))

0 0xA - 0xA
  1 0xA / 0xA
  15 0xF
  255 0xFF
  30 0xF + 0xF

Just a little less obvious (but be patient)
;[16,40, 51, 62, 73, 84, 95].forEach(x=>console.log(x,F(x)))

16 0xBA / 0xB
  40 0xA + 0xF + 0xF
  51 0xDD - 0xAA
  62 0xEA - 0xAC
  73 0xA + 0xEA - 0xAB
  84 0xFE - 0xAA
  95 0xA + 0xFF - 0xAA

Python 2: 185 byte + 2 * 20 = 225
Way too long for a serious answer. But since there are no answers yet, I'll post it anyways.
from itertools import product as p
n=input()
l=t=0
while~l:
 l=-~l
 for i in p("0xABCDEF+-/",repeat=l):
  j=""
  for k in i:j+=k
  try:exec"t="+j
  except:0
  if t==n:print j;l=~0;break

product creates all different arrangements of the allowed chars. exec tries to decode it. This sadly returns an exception, thence the long try - catch block. It the result is fine, it prints and exists.
2 times penalty, because of those braces during function calls.

This answer could have a couple of issues: (1) 0 isn't a hexadecimal literal; (2) Division involving a negative number in Python gives a different result than in C.