menti words init
This commit is contained in:
@@ -11,6 +11,7 @@ from sodoku import Sodoku
|
||||
from fruit import Fruit
|
||||
from pickaxe import Pickaxe_Field
|
||||
from litris import Litris
|
||||
from menti_words import MentiWords
|
||||
|
||||
|
||||
def run():
|
||||
@@ -69,6 +70,9 @@ def run():
|
||||
ltris = Litris(overlay)
|
||||
ltris.execute_main_loop()
|
||||
ltris.stone_id_thread.run_mode = 'stop'
|
||||
elif overlay.rb_int.get() == 11:
|
||||
menti = MentiWords(overlay)
|
||||
menti.execute_main_loop()
|
||||
|
||||
if __name__ == "__main__":
|
||||
run()
|
||||
|
||||
@@ -33,7 +33,7 @@ class PrimaryOverlay(threading.Thread):
|
||||
self.Emitter_Box = ttk.Combobox
|
||||
|
||||
self.RadioButtons = dict
|
||||
self.RadioButtonNames = ["Equip", "Crops", "Farm", "Magic", "Craft", "Mine", "Fruit", "Sodo", "PAxe", "Ltris"]
|
||||
self.RadioButtonNames = ["Equip", "Crops", "Farm", "Magic", "Craft", "Mine", "Fruit", "Sodo", "PAxe", "Ltris", "Menti"]
|
||||
self.RadioButton1 = tk.Radiobutton
|
||||
self.RadioButton2 = tk.Radiobutton
|
||||
self.RadioButton3 = tk.Radiobutton
|
||||
@@ -44,12 +44,13 @@ class PrimaryOverlay(threading.Thread):
|
||||
self.RadioButton8 = tk.Radiobutton
|
||||
self.RadioButton9 = tk.Radiobutton
|
||||
self.RadioButton10 = tk.Radiobutton
|
||||
self.RadioButton11 = tk.Radiobutton
|
||||
|
||||
self.StartButton = tk.Button
|
||||
self.StopButton = tk.Button
|
||||
self.PauseButton = tk.Button
|
||||
self.QuitButton = tk.Button
|
||||
self.TkPosition = '133x404+60+600'
|
||||
self.TkPosition = '133x429+60+600'
|
||||
self.setDaemon(True)
|
||||
self.StatusLabel = tk.Label
|
||||
|
||||
@@ -77,7 +78,7 @@ class PrimaryOverlay(threading.Thread):
|
||||
self.rb_int = tk.IntVar(self.root, value=1)
|
||||
self.RadioButtons = dict()
|
||||
# var = tk.IntVar(value=1)
|
||||
for i in range(1, 11):
|
||||
for i in range(1, 12):
|
||||
self.RadioButtons[i] = tk.Radiobutton(self.rb_frame, text=self.RadioButtonNames[i - 1],
|
||||
variable=self.rb_int,
|
||||
value=i, command=self.radio_button_callback)
|
||||
@@ -326,6 +327,17 @@ class PrimaryOverlay(threading.Thread):
|
||||
self.SpawnLabel.configure(text="")
|
||||
self.EnergyLabel.configure(text="")
|
||||
self.hide_mining_overlay()
|
||||
elif self.rb_int.get() == 11:
|
||||
self.EnergyEntry.configure(state=tk.DISABLED)
|
||||
self.energy_use.set('')
|
||||
self.SpawnEntry.configure(state=tk.DISABLED)
|
||||
self.spawn_use.set('')
|
||||
self.Emitter_Box.configure(state=tk.DISABLED)
|
||||
self.emitter_use.set('')
|
||||
self.EmitterLabel.configure(text="")
|
||||
self.SpawnLabel.configure(text="")
|
||||
self.EnergyLabel.configure(text="")
|
||||
self.hide_mining_overlay()
|
||||
def get_run_mode(self):
|
||||
return self.run_mode
|
||||
|
||||
|
||||
144
menti_dic
Normal file
144
menti_dic
Normal file
@@ -0,0 +1,144 @@
|
||||
HIT
|
||||
IT
|
||||
HI
|
||||
POT
|
||||
TOP
|
||||
TO
|
||||
HAS
|
||||
ASH
|
||||
HA
|
||||
AS
|
||||
AH
|
||||
NOW
|
||||
NO
|
||||
ON
|
||||
OWN
|
||||
WON
|
||||
WHEN
|
||||
NEW
|
||||
HE
|
||||
WE
|
||||
FORM
|
||||
OR
|
||||
OF
|
||||
FROM
|
||||
FOR
|
||||
HIST
|
||||
HIS
|
||||
HITS
|
||||
THIS
|
||||
SIT
|
||||
ITS
|
||||
FIND
|
||||
IF
|
||||
FIN
|
||||
IN
|
||||
BEST
|
||||
BET
|
||||
SET
|
||||
BE
|
||||
HAT
|
||||
NAT
|
||||
TAN
|
||||
ANT
|
||||
AN
|
||||
THAN
|
||||
RACE
|
||||
ACE
|
||||
ACER
|
||||
CARE
|
||||
ERA
|
||||
ARC
|
||||
CAR
|
||||
EAR
|
||||
TEA
|
||||
LATE
|
||||
LET
|
||||
ATE
|
||||
EAT
|
||||
TALE
|
||||
HIRE
|
||||
TIRE
|
||||
THEIR
|
||||
TIE
|
||||
TIER
|
||||
TAB
|
||||
BOAT
|
||||
BUT
|
||||
OUT
|
||||
ABOUT
|
||||
AUTO
|
||||
HER
|
||||
HERO
|
||||
OTHER
|
||||
TOE
|
||||
HOT
|
||||
RICE
|
||||
PRICE
|
||||
RIP
|
||||
PIE
|
||||
RIPE
|
||||
ICE
|
||||
FIRST
|
||||
FIST
|
||||
SIR
|
||||
FIT
|
||||
FITS
|
||||
SAT
|
||||
TASTE
|
||||
STATE
|
||||
SEA
|
||||
EAST
|
||||
TEST
|
||||
MAIL
|
||||
EMAIL
|
||||
MALE
|
||||
LIE
|
||||
AIM
|
||||
MILE
|
||||
FEAR
|
||||
ART
|
||||
RATE
|
||||
AFTER
|
||||
FAR
|
||||
ARE
|
||||
DEAF
|
||||
FACE
|
||||
CAFE
|
||||
FED
|
||||
FACED
|
||||
INK
|
||||
LINK
|
||||
LINKS
|
||||
SIN
|
||||
SKIN
|
||||
SKI
|
||||
HERO
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
116
menti_words.py
Normal file
116
menti_words.py
Normal file
@@ -0,0 +1,116 @@
|
||||
import cv2 as cv
|
||||
import numpy as np
|
||||
import pydirectinput
|
||||
|
||||
from utils import mse
|
||||
from game_base_class import GameBase
|
||||
import random
|
||||
|
||||
GREEN = 1
|
||||
YELLOW = 2
|
||||
RED = 3
|
||||
BLUE = 4
|
||||
ORANGE = 5
|
||||
|
||||
|
||||
class MentiWords(GameBase):
|
||||
|
||||
def __init__(self, overlay):
|
||||
super().__init__(overlay)
|
||||
|
||||
self.observation = np.zeros((9, 9), dtype=int)
|
||||
|
||||
self.colors = [1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||
|
||||
self.offset_left = 1080
|
||||
self.offset_down = 870
|
||||
|
||||
self.sd_reset_board = cv.imread("control_elements/sodoku_reset_button.jpg", cv.IMREAD_COLOR)
|
||||
|
||||
self.needles = {'E': cv.imread("menti_words/e.jpg", cv.IMREAD_COLOR),
|
||||
'H': cv.imread("menti_words/h.jpg", cv.IMREAD_COLOR),
|
||||
'O': cv.imread("menti_words/o.jpg", cv.IMREAD_COLOR),
|
||||
'R': cv.imread("menti_words/r.jpg", cv.IMREAD_COLOR),
|
||||
'T': cv.imread("menti_words/t.jpg", cv.IMREAD_COLOR)
|
||||
}
|
||||
|
||||
self.current_letters = []
|
||||
self.letter_coords = {}
|
||||
|
||||
with open("menti_dic") as file:
|
||||
self.word_list = [line.rstrip() for line in file]
|
||||
|
||||
def reset_lists(self):
|
||||
self.current_letters = []
|
||||
self.letter_coords = {}
|
||||
|
||||
def assess_playfield_and_make_move(self):
|
||||
self.reset_lists()
|
||||
self.get_current_board_state()
|
||||
if self.overlay.run_mode == 'stopped' or self.overlay.run_mode == 'paused':
|
||||
return
|
||||
matches = self.possible_words(self.word_list, self.current_letters)
|
||||
matches.sort()
|
||||
new_matches = list(map(list,matches))
|
||||
for letter_list in new_matches:
|
||||
self.type_word_into_ui(letter_list)
|
||||
if self.overlay.run_mode == 'stopped' or self.overlay.run_mode == 'paused':
|
||||
return
|
||||
|
||||
def type_word_into_ui(self, letters):
|
||||
|
||||
for letter in letters:
|
||||
pydirectinput.moveTo(self.letter_coords[letter][0] + self.offset_left, self.letter_coords[letter][1] + self.offset_down)
|
||||
pydirectinput.mouseDown()
|
||||
w = random.randint(25, 50)
|
||||
cv.waitKey(100 + w)
|
||||
if self.overlay.run_mode == 'stopped' or self.overlay.run_mode == 'paused':
|
||||
return
|
||||
pydirectinput.mouseUp()
|
||||
cv.waitKey(400)
|
||||
|
||||
|
||||
def get_current_board_state(self):
|
||||
|
||||
screenshot = cv.imread("menti_words/screenshot.jpg")
|
||||
#screenshot = self.capture_window.get_screenshot()
|
||||
screenshot = screenshot[870:1240, 1080:1480]
|
||||
|
||||
#cv.imshow("screenshot", screenshot)
|
||||
#cv.waitKey(150)
|
||||
#continue
|
||||
for needle_key in self.needles.keys():
|
||||
# gray_needle = cv.cvtColor(self.needles[needle_key], cv.COLOR_BGR2GRAY)
|
||||
# thresh_needle = cv.threshold(gray_needle, 0, 255, cv.THRESH_BINARY_INV + cv.THRESH_OTSU)[1]
|
||||
rectangles = self.vision_stun.find(screenshot, self.needles[needle_key], 0.85, 56)
|
||||
if len(rectangles) == 0:
|
||||
continue
|
||||
points = self.vision_stun.get_click_points(rectangles)
|
||||
self.current_letters.append(needle_key)
|
||||
self.letter_coords[needle_key] = points[0]
|
||||
if self.overlay.run_mode == 'stopped' or self.overlay.run_mode == 'paused':
|
||||
return
|
||||
|
||||
def possible_words(self, lwords, charSet):
|
||||
lst = []
|
||||
for word in lwords:
|
||||
if len(word) <= 2:
|
||||
continue
|
||||
flag = 1
|
||||
chars = self.charCount(word)
|
||||
for key in chars:
|
||||
if key not in charSet:
|
||||
flag = 0
|
||||
else:
|
||||
if charSet.count(key) != chars[key]:
|
||||
flag = 0
|
||||
if flag == 1:
|
||||
lst.append(word)
|
||||
#print(word)
|
||||
return list(set(lst))
|
||||
|
||||
def charCount(self, word):
|
||||
dict = {}
|
||||
for i in word:
|
||||
dict[i] = dict.get(i, 0) + 1
|
||||
return dict
|
||||
BIN
menti_words/e.jpg
Normal file
BIN
menti_words/e.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
BIN
menti_words/h.jpg
Normal file
BIN
menti_words/h.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
BIN
menti_words/o.jpg
Normal file
BIN
menti_words/o.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
BIN
menti_words/r.jpg
Normal file
BIN
menti_words/r.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
BIN
menti_words/screenshot.jpg
Normal file
BIN
menti_words/screenshot.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 732 KiB |
BIN
menti_words/t.jpg
Normal file
BIN
menti_words/t.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
Reference in New Issue
Block a user