<commit_before>import time

from GTPengine import GTPengine
from Game import Game
from Move import Move
from bots.HumanConsole import HumanConsole
from bots.RandomBot import RandomBot
from bots.RandomGroupingBot import RandomGroupingBot


class GTPcontroller:

    def __init__(self, player1type, player2type):
        self.game = Game()
        self.player1 = Player('b')
        self.player1.engine.controller = self
        self.player2 = Player('w')
        self.player2.engine.controller = self
        self.map = {
            self.player1.engine: self.player1,
            self.player2.engine: self.player2,
        }
        self.send_to_player(self.player1, 'set_player_type ' + player1type)
        self.send_to_player(self.player2, 'set_player_type ' + player2type)
        self.player1.name = self.wait_for_response(self.player1, 'name')[2:]
        self.player2.name = self.wait_for_response(self.player2, 'name')[2:]
        self.current_player = self.player1
        self.other_player = self.player2

    @staticmethod
    def send_to_player(player, command):
        print('      send to ' + player.name + ' (' + player.color + '): ' + command)
        player.engine.handle_input_from_controller(command)

    def wait_for_response(self, player, message):
        self.send_to_player(player, message)
        while player.latest_response is None:
            pass
        return player.get_latest_response()

    def run(self):
        while True:
            print('\nnext turn\n')
            response = self.wait_for_response(self.current_player, 'genmove ' + self.current_player.color)
            move = response[2:]  # strip away the "= "
            self.send_to_player(self.other_player, 'play ' + self.current_player.color + ' ' + move)

            self.game.play(Move().from_gtp(move, self.game.size), self.current_player.color)
            time.sleep(0.5)

            # swap players for next turn
            if self.current_player == self.player1:<commit_msg>print the board after each turn to see whats going on<commit_after>import time

from GTPengine import GTPengine
from Game import Game
from Move import Move
from bots.HumanConsole import HumanConsole
from bots.RandomBot import RandomBot
from bots.RandomGroupingBot import RandomGroupingBot


class GTPcontroller:

    def __init__(self, player1type, player2type):
        self.game = Game()
        self.player1 = Player('b')
        self.player1.engine.controller = self
        self.player2 = Player('w')
        self.player2.engine.controller = self
        self.map = {
            self.player1.engine: self.player1,
            self.player2.engine: self.player2,
        }
        self.send_to_player(self.player1, 'set_player_type ' + player1type)
        self.send_to_player(self.player2, 'set_player_type ' + player2type)
        self.player1.name = self.wait_for_response(self.player1, 'name')[2:]
        self.player2.name = self.wait_for_response(self.player2, 'name')[2:]
        self.current_player = self.player1
        self.other_player = self.player2

    @staticmethod
    def send_to_player(player, command):
        print('      send to ' + player.name + ' (' + player.color + '): ' + command)
        player.engine.handle_input_from_controller(command)

    def wait_for_response(self, player, message):
        self.send_to_player(player, message)
        while player.latest_response is None:
            pass
        return player.get_latest_response()

    def run(self):
        while True:
            print('\nnext turn\n')
            response = self.wait_for_response(self.current_player, 'genmove ' + self.current_player.color)
            move = response[2:]  # strip away the "= "
            self.send_to_player(self.other_player, 'play ' + self.current_player.color + ' ' + move)

            self.game.play(Move().from_gtp(move, self.game.size), self.current_player.color)
            print('\n' + self.game.__str__())

            time.sleep(0.5)

            # swap players for next turn
            if self.current_player == self.player1:
{'fraction_non_alphanumeric': 0.10430504305043051, 'fraction_numerical': 0.012792127921279213, 'mean_word_length': 2.663063063063063, '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': '1597964', 'n_tokens_mistral': 1233, 'n_tokens_neox': 1205, 'n_words': 247}