Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added unit command options from enum UnitCommandOptions

  • Loading branch information...
commit 39b0335cf9ba4bc9f00cd5f5c7611accc1f3fedf 1 parent d7b4dd3
Andreas Löscher authored
Showing with 10 additions and 36 deletions.
  1. +1 −35 NullPythonAI/src/nullai.py
  2. +9 −1 builder/templates/aiInterface.py
View
36 NullPythonAI/src/nullai.py
@@ -29,43 +29,9 @@ class NullPythonAI(BaseAI):
""" Example AI"""
def __init__(self, team, pyclb):
super(NullPythonAI, self).__init__(team, pyclb)
- self.frame=-1
- self.units = {}
- self.bindFunction(self.eventUnitCreated, PyAI.EVENT_UNIT_CREATED)
self.bindFunction(self.eventInit, PyAI.EVENT_INIT)
- self.bindFunction(self.eventUpdate, PyAI.EVENT_UPDATE)
- self.bindFunction(self.eventRelease, PyAI.EVENT_RELEASE)
-
- def eventUnitCreated(self, data):
- print("Unit created (unit builder)", self.frame, data["unit"], data["builder"])
- self.units[data["unit"]] = data["unit"]
-
- def eventRelease(self, data):
- print("eventRelease")
def eventInit(self,data):
- print("eventInit", self.frame)
- self.units = {}
+ print("eventInit")
print("Map width: ", Map.getWidth(), " Height: ", Map.getHeight())
- def cheatInit(self):
- #Cheat start unit
- print("cheatInit")
- if (len(self.units)>0): #only cheat when no units are avaiable
- return
- Cheats.setEnabled(True)
- Command.giveMeNewUnitCheat(UnitDef.getUnitDefByName("armcom"), Map.getStartPos())
-
- print(Resource.getCount())
- for i in xrange(Resource.getCount()):
- print(i, Resource.getName(i))
- Command.giveMeResourceCheat(i,1000)
-
- def eventUpdate(self,data):
- if (self.frame == -1):
- print("eventUpdate", data["frame"])
- self.initFrame=data["frame"]+1
- if (self.frame==self.initFrame): #process initCreate Events, then cheatInit
- self.cheatInit()
- self.frame=data["frame"]
-
View
10 builder/templates/aiInterface.py
@@ -38,4 +38,12 @@ class Command(object):
id = 0
{% for function in commands %}
{{commands[function]}}
-{% endfor %}
+{% endfor %}
+
+
+# hard coded variables
+UNIT_COMMAND_OPTION_DONT_REPEAT = (1 << 3)
+UNIT_COMMAND_OPTION_RIGHT_MOUSE_KEY = (1 << 4)
+UNIT_COMMAND_OPTION_SHIFT_KEY = (1 << 5)
+UNIT_COMMAND_OPTION_CONTROL_KEY = (1 << 6)
+UNIT_COMMAND_OPTION_ALT_KEY = (1 << 7)
Please sign in to comment.
Something went wrong with that request. Please try again.