Commit a2dcabec authored by m1ndgames's avatar m1ndgames

update

parent 073ad5ab
......@@ -160,6 +160,7 @@ class GameManager():
self.bot._client.game_step = 1
return
elif self.bot.real_time and self.bot.last_game_loop + 3 > self.bot.state.game_loop:
self.bot._client.game_step = 4
return
self.bot.last_game_loop = self.bot.state.game_loop
......
......@@ -27,10 +27,10 @@ class m1ndb0t(sc2.BotAI):
# STDOUT
self.showstatus = False
self.printdebug = True
self.printdebug = False
# Chat
self.usechat = True
self.usechat = False
async def on_start(self):
await self.gamemanager.startGame()
......
......@@ -24,6 +24,16 @@ class ProtossManager():
else:
await self.bot.strategy.Run()
def setStrategy(self, strategy):
if strategy:
strategies = {
'ZealotRush': ZealotRush(self.bot),
'StalkerRush': StalkerRush(self.bot),
'SkyToss': SkyToss(self.bot),
'DarkTemplar': DarkTemplar(self.bot)
}
self.bot.strategy = strategies[strategy]
def pickStrategy(self):
strategies = {
'ZealotRush': ZealotRush(self.bot),
......@@ -37,7 +47,7 @@ class ProtossManager():
# self.bot.strategy = ZealotRush(self.bot)
# self.bot.strategy = SkyToss(self.bot)
# self.bot.strategy = DarkTemplar(self.bot)
#return
# return
if self.bot.data_race_strategy in strategies:
self.bot.strategy = strategies[self.bot.data_race_strategy]
......
from sc2.constants import *
class ProtossMicro:
"""Protoss Micro"""
def __init__(self, bot=None):
self.bot = bot
async def Ground(self, unit, kite=False, support=False):
if not unit:
return
unit_abilities = await self.bot.get_available_abilities(unit)
enemie_units = self.bot.enemy_units
enemie_structures = self.bot.enemy_structures
if support:
if self.bot.commandertarget and unit.tag != self.bot.commander:
if unit.position.distance_to(self.bot.commandertarget.position) <= self.bot.techtree.get_unit_weaponrange(unit.type_id):
self.bot.do(unit.attack(self.bot.commandertarget))
return
if enemie_units:
closeenemies = enemie_units.closer_than(30, unit)
if closeenemies:
for ce in closeenemies:
if not self.bot.techtree.can_attack(unit, ce) or not ce.can_be_attacked or ce.name == 'Larva':
closeenemies.remove(ce)
if closeenemies:
next_enemy = closeenemies.closest_to(unit)
distance2enemy = unit.distance_to(next_enemy)
if kite:
if distance2enemy < self.bot.techtree.get_unit_weaponrange(unit.type_id):
# Stalker Blink
if (AbilityId.EFFECT_BLINK_STALKER in unit_abilities) and (unit.health_percentage < 0.25):
if not next_enemy.position:
blinkposition = unit.position.towards(self.bot.hq_location, 8)
else:
blinkposition = unit.position.towards(next_enemy.position, -8)
if blinkposition:
if self.bot.in_pathing_grid(blinkposition) or (blinkposition == unit.position):
self.bot.do(unit(AbilityId.EFFECT_BLINK_STALKER, blinkposition))
else:
moveposition = unit.position.towards(blinkposition, 1)
if moveposition and self.bot.in_pathing_grid(moveposition):
self.bot.do(unit.move(moveposition))
else:
if not next_enemy.position:
moveposition = unit.position.towards(self.bot.hq_location, 1)
if moveposition and self.bot.in_pathing_grid(moveposition):
self.bot.do(unit.move(moveposition))
else:
moveposition = unit.position.towards(next_enemy.position, -1)
if moveposition and self.bot.in_pathing_grid(moveposition):
self.bot.do(unit.move(moveposition))
else:
if distance2enemy < 30:
self.bot.do(unit.attack(next_enemy))
return
if enemie_structures:
closestructures = enemie_structures.closer_than(30, unit)
if closestructures:
for cs in closestructures:
if not self.bot.techtree.can_attack(unit, cs) or not cs.can_be_attacked:
closestructures.remove(cs)
if closestructures:
next_structure = closestructures.closest_to(unit)
if next_structure:
distance2structure = unit.position.distance_to(next_structure.position)
if distance2structure < 30:
self.bot.do(unit.attack(next_structure))
return
async def Air(self, unit, kite=False, support=False):
if not unit:
return
unit_abilities = await self.bot.get_available_abilities(unit)
enemie_units = self.bot.enemy_units
enemie_structures = self.bot.enemy_structures
if support:
if self.bot.commandertarget and unit.tag != self.bot.commander:
if unit.position.distance_to(self.bot.commandertarget.position) <= self.bot.techtree.get_unit_weaponrange(unit.type_id):
self.bot.do(unit.attack(self.bot.commandertarget))
return
if enemie_units:
closeenemies = enemie_units.closer_than(30, unit)
if closeenemies:
for ce in closeenemies:
if not self.bot.techtree.can_attack(unit, ce) or not ce.can_be_attacked or ce.name == 'Larva':
closeenemies.remove(ce)
if closeenemies:
next_enemy = closeenemies.closest_to(unit)
distance2enemy = unit.distance_to(next_enemy)
if kite:
if distance2enemy < self.bot.techtree.get_unit_weaponrange(unit.type_id):
if not next_enemy.position:
moveposition = unit.position.towards(self.bot.hq_location, 1)
if moveposition and self.bot.in_pathing_grid(moveposition):
self.bot.do(unit.move(moveposition))
else:
moveposition = unit.position.towards(next_enemy.position, -1)
if moveposition and self.bot.in_pathing_grid(moveposition):
self.bot.do(unit.move(moveposition))
else:
if distance2enemy < 30:
self.bot.do(unit.attack(next_enemy))
return
if enemie_structures:
closestructures = enemie_structures.closer_than(30, unit)
if closestructures:
for cs in closestructures:
if not self.bot.techtree.can_attack(unit, cs) or not cs.can_be_attacked:
closestructures.remove(cs)
if closestructures:
next_structure = closestructures.closest_to(unit)
if next_structure:
distance2structure = unit.position.distance_to(next_structure.position)
if distance2structure < 30:
self.bot.do(unit.attack(next_structure))
return
\ No newline at end of file
from sc2.constants import *
from sc2 import race_worker
from protoss_micro import *
class DarkTemplar:
"""Protoss DarkTemplar"""
......@@ -14,10 +14,13 @@ class DarkTemplar:
"""Runs on every GameStep"""
if self.bot.iteration == 1:
self.bot.current_strategy = 'DarkTemplar'
self.bot.squadsize = 10
self.bot.attack_count = 10
self.bot.squadsize = 5
self.bot.attack_count = 5
self.bot.retreat_count = 0
self.bot.not_squadunit.extend([UnitTypeId.ADEPT])
self.bot.not_commanderunit.extend([UnitTypeId.ADEPT])
if self.bot.usechat:
await self.bot._client.chat_send("Strategy: DarkTemplar", team_only=True)
......@@ -45,8 +48,7 @@ class DarkTemplar:
await self.bot.unitmanager.createUnit("DarkTemplar", 100)
if self.bot.time >= 300:
await self.bot.warmanager.scout()
await self.bot.warmanager.scout()
# Check if expansion is needed
if (self.bot.units(race_worker[self.bot.race]).ready.amount / 1.1) >= self.bot.neededworkers:
......@@ -59,25 +61,19 @@ class DarkTemplar:
async def Micro(self):
"""Micro Routine"""
pm = ProtossMicro(self.bot)
# DT Micro
darktemplars = self.bot.units(UnitTypeId.DARKTEMPLAR).ready
if darktemplars:
ground_enemies = self.bot.enemy_units.not_flying
if ground_enemies:
for darktemplar in darktemplars:
closeenemies = ground_enemies.closer_than(30, darktemplar)
if closeenemies:
for e in closeenemies:
if not self.bot.techtree.can_attack(darktemplar, e) or not e.can_be_attacked:
closeenemies.remove(e)
if not closeenemies:
break
next_enemy = closeenemies.closest_to(darktemplar)
distance2enemy = darktemplar.distance_to(next_enemy)
if distance2enemy < 20:
self.bot.do(darktemplar.attack(next_enemy))
for darktemplar in darktemplars:
await pm.Ground(darktemplar)
# Adept Micro
adepts = self.bot.units(UnitTypeId.ADEPT).ready
if adepts:
for adept in adepts:
await pm.Ground(adept, True, True)
async def Buffs(self):
"""Buff Routine"""
......
from sc2.constants import *
from sc2 import race_worker
from protoss_micro import *
class SkyToss:
"""Protoss SkyToss"""
......@@ -49,8 +49,7 @@ class SkyToss:
await self.bot.unitmanager.createUnit("Mothership", 1)
await self.bot.unitmanager.createUnit("Tempest", 3)
if self.bot.time >= 330:
await self.bot.warmanager.scout()
await self.bot.warmanager.scout()
# Check if expansion is needed
if (self.bot.units(race_worker[self.bot.race]).ready.amount / 1.1) >= self.bot.neededworkers:
......@@ -63,130 +62,31 @@ class SkyToss:
async def Micro(self):
"""Micro Routine"""
pm = ProtossMicro(self.bot)
# Adept
adepts = self.bot.units(UnitTypeId.ADEPT).ready
if adepts:
for adept in adepts:
enemies = self.bot.enemy_units
if enemies:
closeenemies = enemies.closer_than(30, adept)
if closeenemies:
for e in closeenemies:
if not self.bot.techtree.can_attack(adept, e) or not e.can_be_attacked:
closeenemies.remove(e)
if not closeenemies:
break
next_enemy = closeenemies.closest_to(adept)
if not next_enemy:
break
distance2enemy = adept.position.distance_to(next_enemy.position)
if distance2enemy < 20:
self.bot.do(adept.attack(next_enemy))
await pm.Air(adept, True, True)
# Voidray
voidrays = self.bot.units(UnitTypeId.VOIDRAY).ready
if voidrays:
for voidray in voidrays:
if self.bot.commandertarget and voidray.tag != self.bot.commander:
if voidray.position.distance_to(self.bot.commandertarget.position) <= (self.bot.techtree.get_unit_weaponrange(voidray.type_id) + 10):
self.bot.do(voidray.attack(self.bot.commandertarget))
else:
if self.bot.enemy_units:
enemies = self.bot.enemy_units
if enemies:
closeenemies = enemies.closer_than(30, voidray)
if closeenemies:
for e in closeenemies:
if not self.bot.techtree.can_attack(voidray, e) or not e.can_be_attacked:
closeenemies.remove(e)
if not closeenemies:
break
next_enemy = closeenemies.closest_to(voidray)
if not next_enemy:
break
distance2enemy = voidray.position.distance_to(next_enemy.position)
if distance2enemy < self.bot.techtree.get_unit_weaponrange(voidray.type_id):
if (next_enemy.name != 'Probe') or (next_enemy.name != 'SCV') or (next_enemy.name != 'Drone'):
moveposition = voidray.position.towards(next_enemy.position, -1)
if not moveposition or not self.bot.in_pathing_grid(moveposition):
break
self.bot.do(voidray.move(moveposition))
await pm.Air(voidray, True, True)
# Carrier
carriers = self.bot.units(UnitTypeId.CARRIER).ready
if carriers:
for carrier in carriers:
if self.bot.commandertarget and carrier.tag != self.bot.commander:
if carrier.position.distance_to(self.bot.commandertarget.position) <= 8:
self.bot.do(carrier.attack(self.bot.commandertarget))
else:
if self.bot.enemy_units:
enemies = self.bot.enemy_units
if enemies:
closeenemies = enemies.closer_than(30, carrier)
if closeenemies:
for e in closeenemies:
if not self.bot.techtree.can_attack(carrier, e) or not e.can_be_attacked:
closeenemies.remove(e)
if not closeenemies:
break
next_enemy = closeenemies.closest_to(carrier)
if not next_enemy:
break
distance2enemy = carrier.position.distance_to(next_enemy.position)
if distance2enemy <= 10:
if (next_enemy.name != 'Probe') or (next_enemy.name != 'SCV') or (next_enemy.name != 'Drone'):
moveposition = carrier.position.towards(next_enemy.position, -1)
if not moveposition or not self.bot.in_pathing_grid(moveposition):
break
self.bot.do(carrier.move(moveposition))
await pm.Air(carrier)
# Tempest
tempests = self.bot.units(UnitTypeId.TEMPEST).ready
if tempests:
for tempest in tempests:
if self.bot.commandertarget and tempest.tag != self.bot.commander:
if tempest.position.distance_to(self.bot.commandertarget.position) <= (self.bot.techtree.get_unit_weaponrange(tempest.type_id) + 10):
self.bot.do(tempest.attack(self.bot.commandertarget))
else:
if self.bot.enemy_units:
enemies = self.bot.enemy_units
if enemies:
closeenemies = enemies.closer_than(30, tempest)
if closeenemies:
for e in closeenemies:
if not self.bot.techtree.can_attack(tempest, e) or not e.can_be_attacked:
closeenemies.remove(e)
if not closeenemies:
break
next_enemy = closeenemies.closest_to(tempest)
if not next_enemy:
break
distance2enemy = tempest.position.distance_to(next_enemy.position)
if distance2enemy < self.bot.techtree.get_unit_weaponrange(tempest.type_id):
if (next_enemy.name != 'Probe') or (next_enemy.name != 'SCV') or (next_enemy.name != 'Drone'):
moveposition = tempest.position.towards(next_enemy.position, -1)
if not moveposition or not self.bot.in_pathing_grid(moveposition):
break
self.bot.do(tempest.move(moveposition))
await pm.Air(tempest)
# Mothership
motherships = self.bot.units(UnitTypeId.MOTHERSHIP).ready
......
......@@ -2,7 +2,7 @@ from sc2.position import Point3
from sc2.constants import *
from sc2 import race_worker
from protoss_micro import *
class StalkerRush:
"""Protoss StalkerRush"""
......@@ -19,8 +19,8 @@ class StalkerRush:
if self.bot.iteration == 1:
self.bot.current_strategy = 'StalkerRush'
self.bot.squadsize = 10
self.bot.attack_count = 1
self.bot.retreat_count = 0
self.bot.attack_count = 10
self.bot.retreat_count = 3
self.bot.not_commanderunit.append(UnitTypeId.SENTRY)
......@@ -77,52 +77,13 @@ class StalkerRush:
async def Micro(self):
"""Micro Routine"""
pm = ProtossMicro(self.bot)
# Stalker
stalkers = self.bot.units(UnitTypeId.STALKER).ready
if stalkers:
for stalker in stalkers:
if self.bot.commandertarget and stalker.tag != self.bot.commander:
if stalker.position.distance_to(self.bot.commandertarget.position) <= (self.bot.techtree.get_unit_weaponrange(stalker.type_id) + 3):
self.bot.do(stalker.attack(self.bot.commandertarget))
else:
if self.bot.enemy_units:
#enemies2 = self.units.filter(lambda unit: unit.type_id == UnitTypeId.STALKER and unit.distance_to(my_target) < 15)
enemies = self.bot.enemy_units
if enemies:
closeenemies = enemies.closer_than(15, stalker)
if closeenemies:
for e in closeenemies:
if not self.bot.techtree.can_attack(stalker, e) or not e.can_be_attacked:
closeenemies.remove(e)
if not closeenemies:
break
next_enemy = closeenemies.closest_to(stalker)
if not next_enemy:
break
distance2enemy = stalker.position.distance_to(next_enemy.position)
if distance2enemy < self.bot.techtree.get_unit_weaponrange(stalker.type_id):
if (next_enemy.name != 'Probe') or (next_enemy.name != 'SCV') or (
next_enemy.name != 'Drone'):
abilities = await self.bot.get_available_abilities(stalker)
if (AbilityId.EFFECT_BLINK_STALKER in abilities) and (stalker.health_percentage < 25):
if not next_enemy.position:
break
blinkposition = stalker.position.towards(next_enemy.position, -8)
if not blinkposition:
break
if stalker.position != next_enemy.position:
if self.bot.in_pathing_grid(blinkposition) or (blinkposition == stalker.position):
self.bot.do(stalker(AbilityId.EFFECT_BLINK_STALKER, blinkposition))
else:
moveposition = stalker.position.towards(next_enemy.position, -1)
if not moveposition or not self.bot.in_pathing_grid(moveposition):
break
self.bot.do(stalker.move(moveposition))
await pm.Ground(stalker, True, True)
# Sentry
sentries = self.bot.units(UnitTypeId.SENTRY).ready
......
from sc2.constants import *
from sc2 import race_worker
from protoss_micro import *
class ZealotRush:
......@@ -36,8 +37,7 @@ class ZealotRush:
await self.bot.unitmanager.createUnit("Zealot", 100)
if self.bot.time >= 120:
await self.bot.warmanager.scout()
await self.bot.warmanager.scout()
# Check if expansion is needed
if (self.bot.units(race_worker[self.bot.race]).ready.amount / 1.1) >= self.bot.neededworkers:
......@@ -50,20 +50,10 @@ class ZealotRush:
async def Micro(self):
"""Micro Routine"""
pm = ProtossMicro(self.bot)
# Zealot Micro
zealots = self.bot.units(UnitTypeId.ZEALOT).ready
if zealots:
for zealot in zealots:
enemies = self.bot.enemy_units
if enemies:
closeenemies = enemies.closer_than(30, zealot)
if closeenemies:
for e in closeenemies:
if not self.bot.techtree.can_attack(zealot, e) or not e.can_be_attacked or e.name == 'Larva':
closeenemies.remove(e)
if closeenemies:
next_enemy = closeenemies.closest_to(zealot)
distance2enemy = zealot.distance_to(next_enemy)
if distance2enemy < 20:
self.bot.do(zealot.attack(next_enemy))
await pm.Ground(zealot)
from sc2.constants import *
from sc2 import race_worker
from sc2 import race_gas
from terran_micro import *
class MarineRush:
"""Terran MarineRush"""
......@@ -29,10 +31,6 @@ class MarineRush:
async def Macro(self):
"""Macro Routine"""
if not self.bot.structures(race_gas[self.bot.race]):
await self.bot.ressources.createGas()
# await self.bot.unitmanager.createUnit("Medivac", 3)
await self.createWall()
await self.bot.unitmanager.trainSkill("SCANNERSWEEP_SCAN")
......@@ -54,64 +52,13 @@ class MarineRush:
async def Micro(self):
"""Micro Routine"""
tm = TerranMicro(self.bot)
# marine
marines = self.bot.units(UnitTypeId.MARINE).ready
if marines:
for marine in marines:
enemies = self.bot.enemy_units
if enemies:
closeenemies = enemies.closer_than(30, marine)
if closeenemies:
for e in closeenemies:
if not self.bot.techtree.can_attack(marine, e) or not e.can_be_attacked or e.name == 'Larva':
closeenemies.remove(e)
if closeenemies:
next_enemy = closeenemies.closest_to(marine)
if next_enemy:
distance2enemy = marine.position.distance_to(next_enemy.position)
if distance2enemy < self.bot.techtree.get_unit_weaponrange(UnitTypeId.MARINE):
if (next_enemy.name != 'Probe') or (next_enemy.name != 'SCV') or (
next_enemy.name != 'Drone'):
if distance2enemy < 2:
break
else:
moveposition = marine.position.towards(next_enemy.position, -1)
if not moveposition or not self.bot.in_pathing_grid(moveposition):
break
self.bot.do(marine.move(moveposition))
if distance2enemy < 20:
self.bot.do(marine.attack(next_enemy))
structures = self.bot.enemy_structures
if structures and not enemies:
closestructures = structures.closer_than(30, marine)
if closestructures:
for e in closestructures:
if not self.bot.techtree.can_attack(marine, e) or not e.can_be_attacked:
closestructures.remove(e)
if closestructures:
next_structure = closestructures.closest_to(marine)
if next_structure:
distance2structure = marine.position.distance_to(next_structure.position)
if distance2structure < 20:
self.bot.do(marine.attack(next_structure))
# medivac
medivacs = self.bot.units(UnitTypeId.MEDIVAC).ready
marines = self.bot.units(UnitTypeId.MARINE).ready
if medivacs:
for medivac in medivacs:
if marines:
if self.bot.commanderposition:
distance2commander = medivac.position.distance_to(self.bot.commanderposition)
if distance2commander >= 5:
self.bot.do(medivac.move(self.bot.commanderposition))
await tm.Ground(marine, True, True)
async def Buffs(self):
# Supply Depots
......
This diff is collapsed.
from sc2.constants import *
from sc2 import race_worker
from zerg_micro import *
class BanelingSpam:
"""Zerg BanelingSpam"""
......@@ -37,7 +37,7 @@ class BanelingSpam:
if self.bot.structures(UnitTypeId.LAIR).ready:
zerglings = self.bot.units(UnitTypeId.ZERGLING).ready
if zerglings.amount >= 20:
if zerglings.amount >= 12:
await self.bot.unitmanager.createUnit("Baneling", 10)
if self.bot.townhalls.ready.amount >= 2:
await self.bot.unitmanager.createUnit("Queen", self.bot.townhalls.ready.amount)
......@@ -50,98 +50,19 @@ class BanelingSpam:
await self.bot.warmanager.scout()
async def Micro(self):
zm = ZergMicro(self.bot)
# zergling
zerglings = self.bot.units(UnitTypeId.ZERGLING).ready
if zerglings:
for zergling in zerglings:
enemies = self.bot.enemy_units
if enemies:
closeenemies = enemies.closer_than(30, zergling)
if closeenemies:
for e in closeenemies:
if not self.bot.techtree.can_attack(zergling, e) or not e.can_be_attacked:
closeenemies.remove(e)
if not closeenemies:
break
next_enemy = closeenemies.closest_to(zergling)
if not next_enemy:
break
distance2enemy = zergling.position.distance_to(next_enemy.position)
if distance2enemy < 20:
self.bot.do(zergling.attack(next_enemy))
break
structures = self.bot.enemy_structures
if structures and not enemies:
closestructures = structures.closer_than(30, zergling)
if closestructures:
for e in closestructures:
if not self.bot.techtree.can_attack(zergling, e) or not e.can_be_attacked:
closestructures.remove(e)
if not closestructures:
break
next_structure = closestructures.closest_to(zergling)
if not next_structure:
break
distance2structure = zergling.position.distance_to(next_structure.position)
if distance2structure < 20:
self.bot.do(zergling.attack(next_structure))
break
await zm.Ground(zergling)
# baneling
banelings = self.bot.units(UnitTypeId.BANELING).ready
if banelings:
for baneling in banelings:
enemies = self.bot.enemy_units
if enemies:
closeenemies = enemies.closer_than(30, baneling)
if closeenemies:
for e in closeenemies:
if not self.bot.techtree.can_attack(baneling, e) or not e.can_be_attacked:
closeenemies.remove(e)
if not closeenemies:
break
next_enemy = closeenemies.closest_to(baneling)
if not next_enemy:
break
distance2enemy = baneling.position.distance_to(next_enemy.position)
if distance2enemy < 20:
self.bot.do(baneling.attack(next_enemy))