Advertisement
Guest User

Untitled

a guest
Dec 27th, 2016
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ##################################
  2. ### MINIMALISTIC BOT EXAMPLE 1 ###
  3.  
  4. import cybw
  5. import time
  6.  
  7. client = cybw.BWAPIClient
  8. Broodwar = cybw.Broodwar
  9.  
  10. def connect():
  11.     while not client.connect():
  12.         time.sleep(0.5)
  13.  
  14. connect()
  15. while True:
  16.     while not Broodwar.isInGame():
  17.         client.update()
  18.         if not client.isConnected():
  19.             connect()
  20.     # >>> YOUR STARTING BOT CODE GOES HERE <<<
  21.     while Broodwar.isInGame():
  22.         # >>> YOUR MAIN BOT CODE GOES HERE <<<
  23.         client.update()
  24.     else:
  25.         # >>> YOUR POST-GAME CODE GOES HERE <<<
  26.         quit()
  27.  
  28. ##################################
  29. ### MINIMALISTIC BOT EXAMPLE 2 ###
  30.  
  31. import cybw
  32. import time
  33.  
  34. client = cybw.BWAPIClient
  35. Broodwar = cybw.Broodwar
  36.  
  37. # Pre-game connection-establishing cycle
  38. while True:
  39.     if not client.isConnected():
  40.         # Trying to connect to the game
  41.         client.connect()
  42.         time.sleep(0.5)
  43.     elif not Broodwar.isInGame():
  44.         # Waiting in game menu for a match to commence
  45.         client.update()
  46.     else:
  47.         # Finishing cycle after successful connection and match commencing
  48.         break
  49.  
  50. while Broodwar.isInGame():
  51.     # >>> YOUR BOT GAME LOGIC CODE GOES HERE <<<
  52.     client.update()
  53.  
  54. ##################################
  55. ### MINIMALISTIC BOT EXAMPLE 3 ###
  56.  
  57. import cybw
  58. import time
  59.  
  60. client = cybw.BWAPIClient
  61. Broodwar = cybw.Broodwar
  62.  
  63. # Trying to connect to the game
  64. while not client.connect():
  65.     time.sleep(0.5)
  66.  
  67. # Waiting in game menu for a match to commence
  68. while not Broodwar.isInGame():
  69.     client.update()
  70.  
  71. # Main bot logic loop
  72. while Broodwar.isInGame():
  73.     # >>> YOUR BOT GAME LOGIC CODE GOES HERE <<<
  74.     client.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement