Skip to content

Instantly share code, notes, and snippets.

@Rickyxrc
Created December 26, 2022 05:43
Show Gist options
  • Save Rickyxrc/e4a95fe2ea29ee558fc4016b62073e79 to your computer and use it in GitHub Desktop.
Save Rickyxrc/e4a95fe2ea29ee558fc4016b62073e79 to your computer and use it in GitHub Desktop.
import re,pyautogui
pyautogui.PAUSE = 0.1
f = open('./word.txt')
word_data = f.read()
f.close()
common_type_ex = []
spec_type_ex = [[],[],[],[],[]]
spec_filt = []
confirmed = ['.','.','.','.','.']
def confirm(pos,chart):
global confirmed
confirmed[pos]=chart
def add_except(chart):
global common_type_ex,spec_type_ex
for i in range(5):
if chart in spec_type_ex[i]:
return
common_type_ex.append(chart)
def num_except(pos,chart):
global spec_type_ex,spec_filt
spec_type_ex[pos].append(chart)
spec_filt.append(chart)
def get_pos(pos):
global confirmed,common_type_ex,spec_type_ex
if confirmed[pos] == '.':
strr = ''
for t in common_type_ex:
strr+=t
for t in spec_type_ex[pos]:
strr+=t
return '[^' + strr + ']'
return confirmed[pos]
def guess(strr,res):
for i in range(5):
if res[i] == 'g' :
confirm(i,strr[i])
elif res[i] == 's' :
num_except(i,strr[i])
elif res[i] == 'n' :
add_except(strr[i])
last_guess = 0
pyautogui.hotkey('alt','tab')
pyautogui.press('enter')
pyautogui.hotkey('alt','tab')
while True:
if last_guess == 0:
pyautogui.hotkey('alt','tab')
for i in 'frisk':
pyautogui.press(i)
pyautogui.press('enter')
pyautogui.hotkey('alt','tab')
word = 'frisk'
last_guess = 1
stat = input("stat:")
guess(word,stat)
res = re.findall(get_pos(0)+get_pos(1)+get_pos(2)+get_pos(3)+get_pos(4)+'\n',word_data)
print(get_pos(0)+get_pos(1)+get_pos(2)+get_pos(3)+get_pos(4))
for t in res:
yes=True
for ch in spec_filt:
if not ch in t:
yes=False
break
if yes:
print(t,end='')
word=t
break
pyautogui.hotkey('alt','tab')
for i in t:
pyautogui.press(i)
pyautogui.hotkey('alt','tab')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment