def testChoosesLetterToCompleteWordFromDictionary(): rx_cache.clear() config.dictionary = ['abc'] grid = Grid() player = BasicPlayer('test') setWholeGrid(grid, 'z') grid.setLetter(0,0,'a', True) grid.setLetter(0,1,'b', True) grid.setLetter(0,2, config.null_char, True) letter = player.chooseLetter(grid) assert letter == 'c'
def testPlacesLetterToCompleteWordFromDictionary(): rx_cache.clear() config.dictionary = ['abc'] grid = Grid() player = BasicPlayer('test') setWholeGrid(grid, 'z') grid.setLetter(0,0,'a', True) grid.setLetter(0,1,'b', True) grid.setLetter(0,2, config.null_char, True) coord = player.placeLetter(grid, 'c') print "coord", coord assert coord == (0,2)
def testScoreComparisonForSingleRowForChooseLetter(): rx_cache.clear() config.dictionary = ['abcd'] grid = Grid() player = BasicPlayer('test') setWholeGrid(grid, 'z') grid.setLetter(0,0,'a', True) grid.setLetter(0,1,'b', True) grid.setLetter(0,2, config.null_char, True) grid.setLetter(0,3, config.null_char, True) # player could reasonably pick 'c' or 'd' letter = player.chooseLetter(grid) print "letter", letter assert letter in ['c', 'd']
def testScoreComparisonForSingleRow(): rx_cache.clear() config.dictionary = ['abcd'] grid = Grid() player = BasicPlayer('test') setWholeGrid(grid, 'z') grid.setLetter(0,0,'a', True) grid.setLetter(0,1,'b', True) grid.setLetter(0,2, config.null_char, True) grid.setLetter(0,3, config.null_char, True) for i in range(0, 10): # 0,2 is clearly the best position to place the letter c coord = player.placeLetter(grid, 'c') print "coord", coord assert coord == (0,2)