Commits

Cory Li committed b241050

added in build orders. changed timing of colossus vs mutalisk

Comments (0)

Files changed (1)

 '''Main Script to Run Bots'''
-
 import pythoncom, pyHook, sys
 from time import sleep
 from Board import Board
 from random import randint
 
 
+###
+### SETUP BUILD ORDER HERE
+###
+bo = [('colossus',700),('mutalisk',200)]
+
+
+
 def OnKbEvent(event):
     print event.ScanCode
     if(event.ScanCode==41):
 
 if __name__ == "__main__":
 
+    #Setup Keyboard Hooking
     hm = pyHook.HookManager()
     hm.KeyDown = OnKbEvent
     hm.HookKeyboard()
-    
+
+    #Initialize Bot
     ai = StupidBot()
     bot = StarjeweledBot("Starcraft II")
+    resetDelay = buildNumber = buildDelay = 0
 
+    #Main Loop
+    while True:
 
-    reset = 0
-    build = 0
-    while True:
+        #Image Analysis Code
         pythoncom.PumpWaitingMessages()
         img = bot.capture()
         board = bot.getBoard(img)
         energy = bot.getEnergy(img)
         move = ai.getMove(Board(board))
+        print move
 
-        print move
-        
+        #Reset Code
         if move==None:
-            reset+=1
-            if reset > 10:                    
+            resetDelay+=1
+            buildDelay+=1
+            if resetDelay > 10:                    
                 print 'board reset!'
                 print bot.getBoard(img)
                 bot.clickButton('reset')
         else:
-            reset = 0
+            resetDelay = 0
             bot.swapTile(move)
 
+        #Building Code
+        i = buildNumber%len(bo)
+        if energy>bo[i][1]:
+            sleep(0.1)
+            bot.clickButton(bo[i][0])
+            buildNumber+=1
+            buildDelay=0
 
-        build+=1
-        if energy>500:
-            bot.clickButton('colossus')
 
-        sleep(0.05)
+        #Delay
+        sleep(0.1)