Ejemplo n.º 1
0
 def test_read_square_assymetric_board(self):
     # given
     boardFile = open('board3.txt', 'r')
     board = [['E','F','J','A','J','C','O','W','S','S'], ['S','D','G','K','S','R','F','D'], ['A','S','R','J','D','U','S','K','L','K','I']]
     # when
     receivedBoard = a3.read_board(boardFile)
     # then
     self.assertEquals(receivedBoard, board)
Ejemplo n.º 2
0
def test_read_board():
    res_1 = a3.read_board("board1.txt")

    with open("board1.txt") as f:
        board_list = f.readlines()

    assert type(res_1) is list
    assert res_1 == board_list
Ejemplo n.º 3
0
 def test_read_rectangular_assymetric_board(self):
     # given
     boardFile = open('board2.txt', 'r')
     board = [['E','F','J','A','J','C','O','W','S','S'], ['S','D','G','K','S','R','F','D'], ['A','S','R','J','D','U','S','K','L','K'], ['H','E','A','N'], ['A','N','S','D','N','C','N','E','O'], ['P','M','S','N','F','H','H','E','J','E'], ['J','E','P']]
     # when
     receivedBoard = a3.read_board(boardFile)
     # then
     self.assertEquals(receivedBoard, board)   
Ejemplo n.º 4
0
 def open_board(self):
     '''
     Get user to select board, read it in via a3 module
     '''
     board_file = askopenfile(mode='r', title='Select board file')
     self.board = a3.read_board(board_file)
     self.draw_board(self.board)
     board_file.close()
Ejemplo n.º 5
0
 def test_get_board_contains_specified_board(self):
     board_list = [['E','F','J','A','J','C','O','W','S','S'],
                   ['S','D','G','K','S','R','F','D','F','F'],
                   ['A','S','R','J','D','U','S','K','L','K'],
                   ['H','E','A','N','D','N','D','J','W','A'],
                   ['A','N','S','D','N','C','N','E','O','P'],
                   ['P','M','S','N','F','H','H','E','J','E'],
                   ['J','E','P','Q','L','Y','N','X','D','L']]
     self.assertEquals(board_list, a3.read_board(open('board1.txt', 'r')))
Ejemplo n.º 6
0
    def test_read_board(self):
        board_file = open('board1.txt','r')
        board = a3.read_board(board_file)

        # Check that number of rows match against our test fixture
        self.assertEqual(len(board),len(self.board4))

        # Check that number of columns match against our test fixture
        for r in range(len(board)):
            self.assertEqual(len(board[r]),len(self.board4[r]))

        # Check that each row/column values matches
        for r in range(len(board)):
            for c in range(len(board[r])):
                self.assertEqual(board[r][c],self.board4[r][c])
Ejemplo n.º 7
0
    print_score(players)
    print_board(board)
    print('Words remaining: {num} words left.'.format(num=num_remaining))
    print('Words found: ' + (' '.join(found_words) or 'No words found, yet.'))

def print_score(players):
    ''' (list of [str, int] list) -> NoneType
    
    Print the scores for each of the players.
    '''
    for name, score in players:
        print('  ' + str(score).rjust(3) + '\t' + name)


# Load the word list and board
words_file = askopenfile(mode='r', title='Select word list file')
words = a3.read_words(words_file)
words_file.close()
print (words)
board_file = askopenfile(mode='r', title='Select board file')
board = a3.read_board(board_file)
board_file.close()
 
found_words = []

players = get_players_list()

play_game(players, board, words)
print_score(players)
Ejemplo n.º 8
0
    print('Words found: ' + (' '.join(found_words) or 'No words found, yet.'))


def print_score(players):
    """ (list of [str, int] list) -> NoneType

    Print the scores for each of the players.
    """
    for name, score in players:
        print('  ' + str(score).rjust(3) + '\t' + name)


# Load the words list.
words_file = askopenfile(mode='r', title='Select word list file')
words = a3.read_words(words_file)
print(words)
words_file.close()

# Load the board.
board_file = askopenfile(mode='r', title='Select board file')
board = a3.read_board(board_file)
print(board)
board_file.close()

found_words = []

players = get_players_list()

play_game(players, board, words)
print_score(players)
Ejemplo n.º 9
0
    print('Words remaining: {num} words left.'.format(num=num_remaining))
    print('Words found: ' + (' '.join(found_words) or 'No words found, yet.'))


def print_score(players):
    """ (list of [str, int] list) -> NoneType

    Print the scores for each of the players.
    """
    for name, score in players:
        print('  ' + str(score).rjust(3) + '\t' + name)


# Load the words list.
# words_file = askopenfile(mode='r', title='Select word list file')
# print(words_file)
words = a3.read_words('wordlist1.txt')
# words_file.close()

# Load the board.
# board_file = askopenfile(mode='r', title='Select board file')
board = a3.read_board('board1.txt')
# board_file.close()

found_words = []

players = get_players_list()

play_game(players, board, words)
print_score(players)
Ejemplo n.º 10
0
import a3

board_file = r'c:\users\andrew\documents\programming\python\learn_to_program_class\assignment3\board1.txt'
board = open(board_file,'r')

wordlist_file = r'c:\users\andrew\documents\programming\python\learn_to_program_class\assignment3\wordlist1.txt'
word_list = open(wordlist_file,'r')

words = a3.read_words(word_list)

gameboard = a3.read_board(board)

player1 = ['John',4]
player2 = ['Sam',3]
player3 = ['Jenny',5]


players = (player1, player2, player3)







Ejemplo n.º 11
0
import a3

board_file = r'c:\users\andrew\documents\programming\python\learn_to_program_class\assignment3\board1.txt'
board = open(board_file, 'r')

wordlist_file = r'c:\users\andrew\documents\programming\python\learn_to_program_class\assignment3\wordlist1.txt'
word_list = open(wordlist_file, 'r')

words = a3.read_words(word_list)

gameboard = a3.read_board(board)

player1 = ['John', 4]
player2 = ['Sam', 3]
player3 = ['Jenny', 5]

players = (player1, player2, player3)
Ejemplo n.º 12
0
 def test03_read_board(self):
     """read board should return the correct list for asymmetric board"""
     self.assertEqual(self.sym_board, a3.read_board(self.sym_file_board))