<commit_before>
import sys, os
import subprocess as sub
import random as r
import time as t

verbose = False

def pos_to_str(pos):
    if pos is None:
        return "N"
    else:
        return "%d,%d"%pos

class Bot:
    "A bot."

    def __init__(self, name, command, initial=None):
        self.name = name
        self.command = command
        self.initial = initial
        self.score = 0
        self.delta_score = 0
        self.handle = None
        self.enemies = None
        self.last_choice = None
        self.report = None

class Vertex:
    "A vertex."

    INACTIVE, ACTIVE, BROKEN = 0, 1, 2

    def __init__(self, children):
        self.children = children
        self.is_sink = not children
        self.status = self.INACTIVE
        self.owners = set()

def open_bots(bot_path):
    global verbose
    alp = list("abcdefghijklmnopqrstuvwxyz")
    bots = []
    bot_file = open(bot_path)
    while True:
        line = bot_file.readline()
        if not line:
            break
        if line[0] == '#':
            continue
        bot_name = line[:-1]
        command = bot_file.readline()[:-1]
        if verbose:
            bots.append(Bot(bot_name, command, initial=alp.pop(0)))
        else:
            bots.append(Bot(bot_name, command))
    bot_file.close()
    for i in range(len(bots)):
        order = list(range(len(bots)))
        order.remove(i)
        r.shuffle(order)
        bots[i].enemies = [bots[j] for j in order]
    return bots
        
def run_round(bots):
    slows = set()
    # Initial message: number of bots, number of turns, sidelength
    turns = len(bots)**2
    side = 2*turns
    for bot in bots:
        bot.handle = sub.Popen(bot.command, bufsize=1, universal_newlines=True, shell=True, stdin=sub.PIPE, stdout=sub.PIPE)
        bot.report = "BEGIN %d %d %d\n"%(len(bots), turns, side)
    grid = [[0]*side for y in range(side)]
    for y in reversed(range(side)):
        for x in range(side):
            grid[y][x] = Vertex([] if y == side-1 else [grid[y+1][(x-1)%side], grid[y+1][x], grid[y+1][(x+1)%side]])
    for turn in range(turns):
        # Destruction phase
        for bot in bots:
            bot.last_choice = None<commit_msg>Removed shell invocation from the controller.<commit_after>
import sys, os
import subprocess as sub
import random as r
import time as t

verbose = False

def pos_to_str(pos):
    if pos is None:
        return "N"
    else:
        return "%d,%d"%pos

class Bot:
    "A bot."

    def __init__(self, name, command, initial=None):
        self.name = name
        self.command = command
        self.initial = initial
        self.score = 0
        self.delta_score = 0
        self.handle = None
        self.enemies = None
        self.last_choice = None
        self.report = None

class Vertex:
    "A vertex."

    INACTIVE, ACTIVE, BROKEN = 0, 1, 2

    def __init__(self, children):
        self.children = children
        self.is_sink = not children
        self.status = self.INACTIVE
        self.owners = set()

def open_bots(bot_path):
    global verbose
    alp = list("abcdefghijklmnopqrstuvwxyz")
    bots = []
    bot_file = open(bot_path)
    while True:
        line = bot_file.readline()
        if not line:
            break
        if line[0] == '#':
            continue
        bot_name = line[:-1]
        command = bot_file.readline()[:-1]
        if verbose:
            bots.append(Bot(bot_name, command, initial=alp.pop(0)))
        else:
            bots.append(Bot(bot_name, command))
    bot_file.close()
    for i in range(len(bots)):
        order = list(range(len(bots)))
        order.remove(i)
        r.shuffle(order)
        bots[i].enemies = [bots[j] for j in order]
    return bots
        
def run_round(bots):
    slows = set()
    # Initial message: number of bots, number of turns, sidelength
    turns = len(bots)**2
    side = 2*turns
    for bot in bots:
        bot.handle = sub.Popen(bot.command, bufsize=1, universal_newlines=True, stdin=sub.PIPE, stdout=sub.PIPE)
        bot.report = "BEGIN %d %d %d\n"%(len(bots), turns, side)
    grid = [[0]*side for y in range(side)]
    for y in reversed(range(side)):
        for x in range(side):
            grid[y][x] = Vertex([] if y == side-1 else [grid[y+1][(x-1)%side], grid[y+1][x], grid[y+1][(x+1)%side]])
    for turn in range(turns):
        # Destruction phase
        for bot in bots:
            bot.last_choice = None
{'fraction_non_alphanumeric': 0.12308039747064137, 'fraction_numerical': 0.008581752484191508, 'mean_word_length': 2.1545584045584047, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3545082', 'n_tokens_mistral': 1526, 'n_tokens_neox': 1498, 'n_words': 397}