Exemplo n.º 1
0
 def exchange(self):
     if len(distribution)<7:
         return []
     exchs = self.gac(self.rack, len(self.rack))
     for i in exchs:
         exch = Move(i, self.board, 0, 0, 0, self.board, self.rack, _type = 'e')
         exch.score = 0
         exch.getEvaluation(self.rack)
         yield exch
Exemplo n.º 2
0
    def place(self, slot, pos, word, direc, depth):
        slot, reps = slot
        currPos = pos
        slot = list(slot)

        index = wordPos = 0
        while index < len(word):
            newPos = currPos + index
            if newPos>=len(slot):
                return False
            if slot[newPos] != '.':
                currPos += 1
                index -= 1
            else:
                #cc = (depth, currPos) if direc == 'A' else (currPos, depth)
                #if word[index] not in self.board.crosschecks[cc[0]][cc[1]]: return False
                slot[newPos] = word[index]
                if not wordPos:
                    wordPos = currPos+index
            index += 1
        wordPos += 1
        slot = ''.join(slot)

        if not all(map(self.checkWord, slot.strip('.').split('.'))):
            return False

        newBoardSlot = [reps[index] if newLetter == '.' else newLetter for (index, newLetter) in enumerate(slot)]
        newBoard = self.board.clone()
        if direc == 'A':
            newBoard.board[depth][1:] = newBoardSlot[:]
            col = wordPos
            row = depth
        else:
            for (index, row) in enumerate(newBoard.board[1:]):
                row[depth] = newBoardSlot[index]
            col = depth
            row = wordPos
        move = Move(word, newBoard, row, col, direc, self.board.clone(), self.rack, doNotScoreWord=True)
        if move.board.checkBoard(newBoard.board):
            move.getScore()
            move.getEvaluation(move.rack)
            return move
        return False