SHARE
TWEET

Untitled

a guest Mar 21st, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import imageProcess
  2. import pyautogui
  3. import numpy as np
  4. from multiprocessing import Process, Pipe
  5.  
  6.  
  7. """
  8. This module was writen by Dr_Pixelz on March 7th, 2019
  9.  ________   ________   ________   ___      ___    ___  _______    ___        ________
  10. |\   ___ \ |\   __  \ |\   __  \ |\  \    |\  \  /  /||\  ___ \  |\  \      |\_____  \
  11. \ \  \_|\ \\ \  \|\  \\ \  \|\  \\ \  \   \ \  \/  / /\ \   __/| \ \  \      \|___/  /|
  12.  \ \  \ \\ \\ \   _  _\\ \   ____\\ \  \   \ \    / /  \ \  \_|/__\ \  \         /  / /
  13.   \ \  \_\\ \\ \  \\  \|\ \  \___| \ \  \   /     \/    \ \  \_|\ \\ \  \____   /  /_/__
  14.    \ \_______\\ \__\\ _\ \ \__\     \ \__\ /  /\   \     \ \_______\\ \_______\|\________\
  15.     \|_______| \|__|\|__| \|__|      \|__|/__/ /\ __\     \|_______| \|_______| \|_______|
  16.                                           |__|/ \|__|
  17. """
  18.  
  19.  
  20. #Game Process is responsible for processing position data of variables in gameProcess
  21. #and responding with a risk assesment level and then reacting based on risk level
  22. def gameProcess(conn):
  23.     while 1== 1:
  24.         #Counters for AI Logic
  25.         #-------------------------
  26.         fr_mins = 0
  27.         en_mins = 0
  28.         fr_champ = 0
  29.         en_champ = 0
  30.         en_turret = 0
  31.         fr_turret = 0
  32.         #-------------------------
  33.         #Location Arrays
  34.         en_minion_arr = []
  35.         fr_minion_arr = []
  36.         en_champ_arr = []
  37.         fr_champ_arr = []
  38.         en_turret_arr = []
  39.         fr_turret_arr = []
  40.         league_Loc = (0,0)
  41.         #-------------------------
  42.         #Booleans for AI logic
  43.         #-------------------------
  44.         #Within range to affect AI
  45.         fr_mins_close = False
  46.         en_mins_close = False
  47.         fr_champ_close = False
  48.         en_champ_close = False
  49.         en_turret_close = False
  50.         fr_turret_close = False
  51.         #On Screen but not within range to affect AI
  52.         fr_mins_on_screen = False
  53.         en_mins_on_screen = False
  54.         fr_champ_on_screen = False
  55.         en_champ_on_screen = False
  56.         en_turret_on_screen = False
  57.         fr_turret_on_screen = False
  58.         #-------------------------
  59.  
  60.         #Waits for Pipe from imageProcessing to become active
  61.         if conn.recv():
  62.             #Iterates over information recvieved from Pipe
  63.             for items in conn.recv():
  64.                 try:
  65.                     #Pulls label out of array recieved from Pipe
  66.                     #then updates counters, and location arrays
  67.                     if items[1] == 'League Client':
  68.                         league_Loc = (items[0][0], items[0][1])
  69.                     elif items[1] == 'Friendly Minion':
  70.                         fr_minion_arr.insert(fr_mins,items[0])
  71.                         fr_mins = fr_mins + 1
  72.                     elif items[1] == 'Enemy Minion':
  73.                         en_minion_arr.insert(fr_mins,items[0])
  74.                         en_mins = en_mins + 1
  75.                     elif items[1] == 'Friendly Champion':
  76.                         fr_champ_arr.insert(fr_champ, items[0])
  77.                         fr_champ = fr_champ + 1
  78.                     elif items[1] == 'Enemy Champion':
  79.                         en_champ_arr.insert(en_champ, items[0])
  80.                         en_champ = en_champ + 1
  81.                     elif items[1] == 'Enemy Turret':
  82.                         en_turret_arr.insert(en_turret, items[0])
  83.                         en_turret = en_turret + 1
  84.                 #Except all errors and then pass so program continues to run
  85.                 #Despite errors
  86.                 except:
  87.                     pass
  88.                 #Finally processes information into risk assesment and then
  89.                 #chooses action based on risk level
  90.                 finally:
  91.                     print("-------------------")
  92.                     print("Enemy Turrets: " + str(en_turret))
  93.                     print("Enemy Champions: " + str(en_champ))
  94.                     print("Friendly Champions: " + str(fr_champ))
  95.                     print("Enemy Minions: " + str(en_mins))
  96.                     print("Friendly Minions: " + str(fr_mins))
  97.                     print("-------------------")
  98.  
  99. #Image Processing is responsible from generating labels, and location data
  100. #for searches on screen. This information is then sent via the Pipe to gameProcess
  101. def imageProcessing(conn):
  102.     while 1 == 1:
  103.         #Generates a screenshot of desktop screen to use image searches on
  104.         screenshot = pyautogui.screenshot()
  105.         #Converts screenshot into numpy array
  106.         img = np.array(screenshot)
  107.         #Sends array of labels, and location data to gameProcess via the Pipe
  108.         conn.send(imageProcess.leagueClient(screenshot))
  109.         conn.send(imageProcess.minionSearch(screenshot))
  110.         conn.send(imageProcess.enemyTurretSearch(screenshot))
  111.         conn.send(imageProcess.alsoEnemyTurret(screenshot))
  112.         conn.send(imageProcess.healthBar(screenshot))
  113.  
  114.  
  115.  
  116.  
  117.  
  118. if __name__ == '__main__':
  119.     #Initializes Pipe
  120.     parent_conn, child_conn = Pipe()
  121.     #Defines Process 1 for imageProcessing
  122.     p1 = Process(target=imageProcessing, args=(child_conn,))
  123.     #Defines Process 2 for gameProcess
  124.     p2 = Process(target=gameProcess, args=(parent_conn,))
  125.     #Starts Process 1 for imageProcessing
  126.     p1.start()
  127.     #Starts Process 2 for gameProcess
  128.     p2.start()
  129.     #Joins console output for Process 1
  130.     p1.join()
  131.     #Joins console output for Process 2
  132.     p2.join()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top