Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import imageProcess
- import pyautogui
- import numpy as np
- from multiprocessing import Process, Pipe
- """
- This module was writen by Dr_Pixelz on March 7th, 2019
- ________ ________ ________ ___ ___ ___ _______ ___ ________
- |\ ___ \ |\ __ \ |\ __ \ |\ \ |\ \ / /||\ ___ \ |\ \ |\_____ \
- \ \ \_|\ \\ \ \|\ \\ \ \|\ \\ \ \ \ \ \/ / /\ \ __/| \ \ \ \|___/ /|
- \ \ \ \\ \\ \ _ _\\ \ ____\\ \ \ \ \ / / \ \ \_|/__\ \ \ / / /
- \ \ \_\\ \\ \ \\ \|\ \ \___| \ \ \ / \/ \ \ \_|\ \\ \ \____ / /_/__
- \ \_______\\ \__\\ _\ \ \__\ \ \__\ / /\ \ \ \_______\\ \_______\|\________\
- \|_______| \|__|\|__| \|__| \|__|/__/ /\ __\ \|_______| \|_______| \|_______|
- |__|/ \|__|
- """
- #Game Process is responsible for processing position data of variables in gameProcess
- #and responding with a risk assesment level and then reacting based on risk level
- def gameProcess(conn):
- while 1== 1:
- #Counters for AI Logic
- #-------------------------
- fr_mins = 0
- en_mins = 0
- fr_champ = 0
- en_champ = 0
- en_turret = 0
- fr_turret = 0
- #-------------------------
- #Location Arrays
- en_minion_arr = []
- fr_minion_arr = []
- en_champ_arr = []
- fr_champ_arr = []
- en_turret_arr = []
- fr_turret_arr = []
- league_Loc = (0,0)
- #-------------------------
- #Booleans for AI logic
- #-------------------------
- #Within range to affect AI
- fr_mins_close = False
- en_mins_close = False
- fr_champ_close = False
- en_champ_close = False
- en_turret_close = False
- fr_turret_close = False
- #On Screen but not within range to affect AI
- fr_mins_on_screen = False
- en_mins_on_screen = False
- fr_champ_on_screen = False
- en_champ_on_screen = False
- en_turret_on_screen = False
- fr_turret_on_screen = False
- #-------------------------
- #Waits for Pipe from imageProcessing to become active
- if conn.recv():
- #Iterates over information recvieved from Pipe
- for items in conn.recv():
- try:
- #Pulls label out of array recieved from Pipe
- #then updates counters, and location arrays
- if items[1] == 'League Client':
- league_Loc = (items[0][0], items[0][1])
- elif items[1] == 'Friendly Minion':
- fr_minion_arr.insert(fr_mins,items[0])
- fr_mins = fr_mins + 1
- elif items[1] == 'Enemy Minion':
- en_minion_arr.insert(fr_mins,items[0])
- en_mins = en_mins + 1
- elif items[1] == 'Friendly Champion':
- fr_champ_arr.insert(fr_champ, items[0])
- fr_champ = fr_champ + 1
- elif items[1] == 'Enemy Champion':
- en_champ_arr.insert(en_champ, items[0])
- en_champ = en_champ + 1
- elif items[1] == 'Enemy Turret':
- en_turret_arr.insert(en_turret, items[0])
- en_turret = en_turret + 1
- #Except all errors and then pass so program continues to run
- #Despite errors
- except:
- pass
- #Finally processes information into risk assesment and then
- #chooses action based on risk level
- finally:
- print("-------------------")
- print("Enemy Turrets: " + str(en_turret))
- print("Enemy Champions: " + str(en_champ))
- print("Friendly Champions: " + str(fr_champ))
- print("Enemy Minions: " + str(en_mins))
- print("Friendly Minions: " + str(fr_mins))
- print("-------------------")
- #Image Processing is responsible from generating labels, and location data
- #for searches on screen. This information is then sent via the Pipe to gameProcess
- def imageProcessing(conn):
- while 1 == 1:
- #Generates a screenshot of desktop screen to use image searches on
- screenshot = pyautogui.screenshot()
- #Converts screenshot into numpy array
- img = np.array(screenshot)
- #Sends array of labels, and location data to gameProcess via the Pipe
- conn.send(imageProcess.leagueClient(screenshot))
- conn.send(imageProcess.minionSearch(screenshot))
- conn.send(imageProcess.enemyTurretSearch(screenshot))
- conn.send(imageProcess.alsoEnemyTurret(screenshot))
- conn.send(imageProcess.healthBar(screenshot))
- if __name__ == '__main__':
- #Initializes Pipe
- parent_conn, child_conn = Pipe()
- #Defines Process 1 for imageProcessing
- p1 = Process(target=imageProcessing, args=(child_conn,))
- #Defines Process 2 for gameProcess
- p2 = Process(target=gameProcess, args=(parent_conn,))
- #Starts Process 1 for imageProcessing
- p1.start()
- #Starts Process 2 for gameProcess
- p2.start()
- #Joins console output for Process 1
- p1.join()
- #Joins console output for Process 2
- p2.join()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement