For that, you'd first need an algorithm finding words from a dictionary matching your available letters, like the code below, which prints all words from my_dictionary matching the available letters:
var my_dictionary: PoolStringArray = [
"about", "erase", "laser", "real", "really", "relax", "taxi"
]
func _ready():
var available_letters: Array = ["Y", "A", "L", "S", "E", "R", "L", "X"]
print(get_matching_words(available_letters))
func get_matching_words(available_letters: Array) -> Array:
var result : Array = []
for word in my_dictionary:
var check_array : Array = available_letters.duplicate()
var is_match : bool = true
for letter in word.to_upper():
var letter_pos = check_array.find(letter)
if letter_pos == -1:
is_match = false
break
else:
check_array.remove(letter_pos)
if is_match: result.append(word)
return result
Your enemy could then use one of these words (a random one, the longest or the best one fitting to your scrabble board).