<commit_before>#!/usr/bin/env python

import unittest

import pdb

import alpha_beta

import game
import rules
import player
from board import *

from ab_bridge import *

class AlphaBetaBridgeTest(unittest.TestCase):

    def setUp(self):
        player1 = player.HumanPlayer("Blomp")
        player2 = player.HumanPlayer("Kubba")
        r = rules.Rules(13, "standard")
        my_game = game.Game(r, player1, player2)
        self.s = ABState()
        self.s.set_state(my_game.current_state)

    def test_update_substrips_middle_of_board(self):
        self.s.board().set_occ(Pos(7,7), BLACK)

        self.assertEquals(self.s.black_lines, [20, 0, 0, 0, 0])
        self.assertEquals(self.s.white_lines, [0, 0, 0, 0, 0])

    def test_empty_board(self):
        self.assertEquals(self.s.black_lines, [0, 0, 0, 0, 0])
        self.assertEquals(self.s.white_lines, [0, 0, 0, 0, 0])

    def test_update_substrips_SW_corner(self):
        self.s.board().set_occ(Pos(0,0), BLACK)

        self.assertEquals(self.s.black_lines, [3, 0, 0, 0, 0])
        self.assertEquals(self.s.white_lines, [0, 0, 0, 0, 0])

    def test_update_substrips_remove_single_stone(self):
        self.s.board().set_occ(Pos(0,0), BLACK)
        #pdb.set_trace()
        self.s.board().set_occ(Pos(0,0), EMPTY)

        self.assertEquals(self.s.black_lines, [0, 0, 0, 0, 0])
        self.assertEquals(self.s.white_lines, [0, 0, 0, 0, 0])

    def test_update_substrips_TEMP(self):
        self.s.board().set_occ(Pos(0,0), BLACK)
        self.s.board().set_occ(Pos(1,1), BLACK)

        self.assertEquals(self.s.black_lines, [7, 1, 0, 0, 0])
        self.assertEquals(self.s.white_lines, [0, 0, 0, 0, 0])

    def test_update_substrips_near_SW_corner(self):
        self.s.board().set_occ(Pos(1,0), BLACK)

        self.assertEquals(self.s.black_lines, [4, 0, 0, 0, 0])
        self.assertEquals(self.s.white_lines, [0, 0, 0, 0, 0])

    def test_update_substrips_2_opp_colour_pieces(self):
        self.s.board().set_occ(Pos(0,0), BLACK)
        self.s.board().set_occ(Pos(0,1), WHITE)

        self.assertEquals(self.s.black_lines, [2, 0, 0, 0, 0]) # FAILING
        self.assertEquals(self.s.white_lines, [3, 0, 0, 0, 0])

    def test_update_substrips_2_pieces(self):
        self.s.board().set_occ(Pos(0,0), BLACK)
        self.s.board().set_occ(Pos(0,1), BLACK)

        self.assertEquals(self.s.black_lines, [5, 1, 0, 0, 0]) # FAILING
        self.assertEquals(self.s.white_lines, [0, 0, 0, 0, 0])

    def test_update_substrips_NE_corner(self):
        self.s.board().set_occ(Pos(12,12), BLACK)

        self.assertEquals(self.s.black_lines, [3, 0, 0, 0, 0])
        self.assertEquals(self.s.white_lines, [0, 0, 0, 0, 0])

    '''<commit_msg>Clean up<commit_after>#!/usr/bin/env python

import unittest

import pdb

import alpha_beta

import game
import rules
import player
from board import *

from ab_bridge import *

class AlphaBetaBridgeTest(unittest.TestCase):

    def setUp(self):
        player1 = player.HumanPlayer("Blomp")
        player2 = player.HumanPlayer("Kubba")
        r = rules.Rules(13, "standard")
        my_game = game.Game(r, player1, player2)
        self.s = ABState()
        self.s.set_state(my_game.current_state)

    def test_update_substrips_middle_of_board(self):
        self.s.board().set_occ(Pos(7,7), BLACK)

        self.assertEquals(self.s.black_lines, [20, 0, 0, 0, 0])
        self.assertEquals(self.s.white_lines, [0, 0, 0, 0, 0])

    def test_empty_board(self):
        self.assertEquals(self.s.black_lines, [0, 0, 0, 0, 0])
        self.assertEquals(self.s.white_lines, [0, 0, 0, 0, 0])

    def test_update_substrips_SW_corner(self):
        self.s.board().set_occ(Pos(0,0), BLACK)

        self.assertEquals(self.s.black_lines, [3, 0, 0, 0, 0])
        self.assertEquals(self.s.white_lines, [0, 0, 0, 0, 0])

    def test_update_substrips_near_SW_corner(self):
        self.s.board().set_occ(Pos(1,0), BLACK)

        self.assertEquals(self.s.black_lines, [4, 0, 0, 0, 0])
        self.assertEquals(self.s.white_lines, [0, 0, 0, 0, 0])

    def test_update_substrips_NE_corner(self):
        self.s.board().set_occ(Pos(12,12), BLACK)

        self.assertEquals(self.s.black_lines, [3, 0, 0, 0, 0])
        self.assertEquals(self.s.white_lines, [0, 0, 0, 0, 0])

    def test_update_substrips_remove_single_stone(self):
        self.s.board().set_occ(Pos(0,0), BLACK)
        self.s.board().set_occ(Pos(0,0), EMPTY)

        self.assertEquals(self.s.black_lines, [0, 0, 0, 0, 0])
        self.assertEquals(self.s.white_lines, [0, 0, 0, 0, 0])

    def test_update_substrips_two_blacks_SW(self):
        self.s.board().set_occ(Pos(0,0), BLACK)
        self.s.board().set_occ(Pos(1,1), BLACK)

        self.assertEquals(self.s.black_lines, [7, 1, 0, 0, 0])
        self.assertEquals(self.s.white_lines, [0, 0, 0, 0, 0])

    def test_update_substrips_2_opp_colour_pieces(self):
        self.s.board().set_occ(Pos(0,0), BLACK)
        self.s.board().set_occ(Pos(0,1), WHITE)

        self.assertEquals(self.s.black_lines, [2, 0, 0, 0, 0])
        self.assertEquals(self.s.white_lines, [3, 0, 0, 0, 0])

    def test_update_substrips_2_pieces(self):
        self.s.board().set_occ(Pos(0,0), BLACK)
        self.s.board().set_occ(Pos(0,1), BLACK)

        self.assertEquals(self.s.black_lines, [5, 1, 0, 0, 0])
        self.assertEquals(self.s.white_lines, [0, 0, 0, 0, 0])

    def test_update_substrips_5_in_a_row(self):
        self.s.board().set_occ(Pos(0,0), BLACK)
        self.s.board().set_occ(Pos(0,1), BLACK)
        self.s.board().set_occ(Pos(0,2), BLACK)
        self.s.board().set_occ(Pos(0,3), BLACK)
        self.s.board().set_occ(Pos(0,4), BLACK)

        self.assertEquals(self.s.black_lines, [12, 1, 1, 1, 1])
        self.assertEquals(self.s.white_lines, [0, 0, 0, 0, 0])

    '''
{'fraction_non_alphanumeric': 0.16248711782892478, 'fraction_numerical': 0.04671934043284095, 'mean_word_length': 3.069182389937107, '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': '5473215', 'n_tokens_mistral': 2470, 'n_tokens_neox': 2245, 'n_words': 404}