def check_grid_size(self, size): standard_setup() SettingsParser.set_setting('board_size', size) if size not in [4, 5]: with self.assertRaises(IOError): StandardBoggle(number_of_boards=2, board_size=size) else: try: StandardBoggle(number_of_boards=2, board_size=size) except IOError: self.fail()
def test_randomly_rolled(self): standard_setup() boards = (StandardBoggle(number_of_boards=1, board_size=4).get_board(0), StandardBoggle(number_of_boards=1, board_size=4).get_board(0)) unique = False for row in range(len(boards[0])): for col in range(len(boards[0][row])): if boards[0][row][col].value != boards[1][row][col].value: unique = True self.assertTrue(unique, msg="The boards generated are not unique")
def test_dice_configurations(self): load_compleat_language() first_board = StandardBoggle(number_of_boards=2, board_size=4).get_board_string(0, colored=False) load_uncompleat_language() second_board = StandardBoggle(number_of_boards=2, board_size=4).get_board_string(0, colored=False) not_unique = False for row in range(len(first_board)): for col in range(len(first_board[row])): if first_board[row][col] == second_board[row][col]: not_unique = True self.assertTrue(not not_unique)
def find_words_in_board(): SettingsParser.load_settings() DictionaryParser.load_dictionary( language=SettingsParser.get_setting('language')) boogle_instance = StandardBoggle(1, 4) boogle_instance.game_paralell_process() print(boogle_instance.get_game_end_info())
def move_check(self, positions, output_text=""): standard_setup() standard_boggle = StandardBoggle(number_of_boards=1, board_size=4) standard_boggle.set_board_value(position=positions[0], value='c') standard_boggle.set_board_value(position=positions[1], value='o') standard_boggle.set_board_value(position=positions[2], value='w') # PlayerIO.set_mockup(True) # PlayerIO.write_player_gameboard(0, standard_boggle.get_board_string(board_id=0), "", 4) self.assertTrue(standard_boggle._check_move(move='cow', board_id=0, generous_boggle=False, register_used_word=False), msg=output_text) standard_boggle.set_board_value(position=positions[2], value='c') standard_boggle.set_board_value(position=positions[1], value='o') standard_boggle.set_board_value(position=positions[0], value='w') self.assertTrue(standard_boggle._check_move(move='cow', board_id=0, generous_boggle=False, register_used_word=False), msg=output_text)
def test_winner(self): standard_setup() standard_boggle = StandardBoggle(number_of_boards=2, board_size=4) standard_boggle.set_board_value(position=(0, 0), value='c') standard_boggle.set_board_value(position=(0, 1), value='o') standard_boggle.set_board_value(position=(0, 2), value='w') id, points = check_winner(standard_boggle, 'cow') self.assertEqual(id, 0)
def test_reused_dice(self): standard_setup() standard_boggle = StandardBoggle(number_of_boards=2, board_size=4) standard_boggle.set_board_value(position=(1, 0), value='i') standard_boggle.set_board_value(position=(1, 1), value='n') standard_boggle.set_board_value(position=(2, 0), value='t') self.assertTrue(not standard_boggle._check_move(move='init', board_id=0, generous_boggle=False))
def test_generous_reused_dice(self): standard_setup() standard_boggle = StandardBoggle(number_of_boards=2, board_size=4) standard_boggle.set_board_value(position=(0, 0), value='a') standard_boggle.set_board_value(position=(1, 0), value='l') standard_boggle.set_board_value(position=(2, 0), value='k') standard_boggle.set_board_value(position=(2, 1), value='y') self.assertTrue(standard_boggle._check_move(move='alkyl', board_id=0, generous_boggle=True))
def test_get_word_list(self): standard_setup() load_minimal_language() HostIO.set_terminal_output(True) standard_boggle = StandardBoggle(number_of_boards=2, board_size=4) standard_boggle.set_board_value(position=(0, 0), value='w') standard_boggle.set_board_value(position=(0, 1), value='o') standard_boggle.set_board_value(position=(0, 2), value='r') standard_boggle.set_board_value(position=(0, 3), value='d') standard_boggle.game_paralell_process() self.assertCountEqual(standard_boggle.get_words_in_board(), ['word'])
def test_reused_word(self): standard_setup() standard_boggle = StandardBoggle(number_of_boards=2, board_size=4) standard_boggle.set_board_value(position=(0, 0), value='c') standard_boggle.set_board_value(position=(0, 1), value='o') standard_boggle.set_board_value(position=(0, 2), value='w') standard_boggle._check_move(move='cow', board_id=0, generous_boggle=False) self.assertTrue(not standard_boggle._check_move(move='cow', board_id=0, generous_boggle=False))
def test_change_dict(self): load_compleat_language() standard_boggle = StandardBoggle(number_of_boards=2, board_size=4) standard_boggle.set_board_value(position=(1, 0), value='n') standard_boggle.set_board_value(position=(1, 1), value='o') standard_boggle.set_board_value(position=(1, 2), value='t') self.assertTrue(standard_boggle._check_move(move='not', board_id=0, generous_boggle=False)) load_uncompleat_language() self.assertTrue(not standard_boggle._check_move(move='not', board_id=0, generous_boggle=False))
def test_qu(self): standard_setup() self.assertEqual(StandardBoggle(2, 4).get_points('quest'), 2)
def test_winner_length(self): standard_setup() standard_boggle = StandardBoggle(number_of_boards=2, board_size=4) standard_boggle.set_board_value(position=(0, 0), value='i') standard_boggle.set_board_value(position=(0, 1), value='f') id, points = check_winner(standard_boggle, 'if') self.assertEqual(points, 0) standard_boggle = StandardBoggle(number_of_boards=2, board_size=4) standard_boggle.set_board_value(position=(0, 0), value='c') standard_boggle.set_board_value(position=(0, 1), value='o') standard_boggle.set_board_value(position=(0, 2), value='w') id, points = check_winner(standard_boggle, 'cow') self.assertEqual(points, 1) standard_boggle = StandardBoggle(number_of_boards=2, board_size=4) standard_boggle.set_board_value(position=(0, 0), value='c') standard_boggle.set_board_value(position=(0, 1), value='o') standard_boggle.set_board_value(position=(0, 2), value='w') standard_boggle.set_board_value(position=(0, 3), value='s') id, points = check_winner(standard_boggle, 'cows') self.assertEqual(points, 1) standard_boggle = StandardBoggle(number_of_boards=2, board_size=4) standard_boggle.set_board_value(position=(0, 0), value='m') standard_boggle.set_board_value(position=(0, 1), value='a') standard_boggle.set_board_value(position=(0, 2), value='t') standard_boggle.set_board_value(position=(0, 3), value='c') standard_boggle.set_board_value(position=(1, 3), value='h') id, points = check_winner(standard_boggle, 'match') self.assertEqual(points, 2) standard_boggle = StandardBoggle(number_of_boards=2, board_size=4) standard_boggle.set_board_value(position=(0, 0), value='w') standard_boggle.set_board_value(position=(0, 1), value='i') standard_boggle.set_board_value(position=(0, 2), value='n') standard_boggle.set_board_value(position=(0, 3), value='n') standard_boggle.set_board_value(position=(1, 3), value='e') standard_boggle.set_board_value(position=(1, 2), value='r') id, points = check_winner(standard_boggle, 'winner') self.assertEqual(points, 3) standard_boggle = StandardBoggle(number_of_boards=2, board_size=4) standard_boggle.set_board_value(position=(0, 0), value='l') standard_boggle.set_board_value(position=(0, 1), value='e') standard_boggle.set_board_value(position=(0, 2), value='t') standard_boggle.set_board_value(position=(0, 3), value='t') standard_boggle.set_board_value(position=(1, 3), value='e') standard_boggle.set_board_value(position=(1, 2), value='r') standard_boggle.set_board_value(position=(1, 1), value='s') id, points = check_winner(standard_boggle, 'letters') self.assertEqual(points, 5) standard_boggle = StandardBoggle(number_of_boards=2, board_size=4) standard_boggle.set_board_value(position=(0, 0), value='p') standard_boggle.set_board_value(position=(0, 1), value='o') standard_boggle.set_board_value(position=(0, 2), value='s') standard_boggle.set_board_value(position=(0, 3), value='s') standard_boggle.set_board_value(position=(1, 3), value='i') standard_boggle.set_board_value(position=(1, 2), value='b') standard_boggle.set_board_value(position=(1, 1), value='l') standard_boggle.set_board_value(position=(1, 0), value='e') id, points = check_winner(standard_boggle, 'possible') self.assertEqual(points, 11) standard_boggle = StandardBoggle(number_of_boards=2, board_size=4) standard_boggle.set_board_value(position=(0, 0), value='a') standard_boggle.set_board_value(position=(0, 1), value='c') standard_boggle.set_board_value(position=(0, 2), value='t') standard_boggle.set_board_value(position=(0, 3), value='i') standard_boggle.set_board_value(position=(1, 3), value='v') standard_boggle.set_board_value(position=(1, 2), value='i') standard_boggle.set_board_value(position=(1, 1), value='t') standard_boggle.set_board_value(position=(1, 0), value='i') standard_boggle.set_board_value(position=(2, 0), value='e') standard_boggle.set_board_value(position=(3, 0), value='s') id, points = check_winner(standard_boggle, 'activities') self.assertEqual(points, 11)