diff options
Diffstat (limited to 'computer.py')
-rwxr-xr-x | computer.py | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/computer.py b/computer.py index 7a40006..a41d7fe 100755 --- a/computer.py +++ b/computer.py @@ -56,21 +56,33 @@ class Computer: self.add_letter(letter) - def make_move(self, board, moves): + def make_move(self, board, dict, moves): ''' Function which calculates the move that the computer will make. @param board: the current gameboard + @param dict: the dictionary @param moves: the list of Moves that were made along the game. + @return: the Move made. ''' - # calcular movimiento - # insertar en la tabla el movimiento - new_move = [] - - # implementar ...... - - - + move = Move() + for i in range(0, board.get_size()): + for j in range(0, board.get_size()): + if not board.is_tile_empty(i, j): + letter = board.get_value_at(i, j) + criterion, type = utility.can_form_a_word(board, + self.get_letters(), + letter, i, j) + words = utility.search_words_that_match(criterion, + dict) + for w in words: + possible = move.try_move(board, w, type, i, j) + if possible: + move.calculate_score() + return move + # probar intercambiar letras. + # else pasar turno. + # to be continued.. |