Commit a75cd64d authored by m1ndgames's avatar m1ndgames

update

parent 582f74c7
......@@ -61,7 +61,7 @@ class GameManager():
if botdata:
if botdata.has_section("Enemy"):
if botdata.has_option("Enemy", "attacktime"):
self.bot.data_attacktime = botdata.get('Enemy', 'attacktime')
self.bot.data_attacktime = int(botdata.get('Enemy', 'attacktime'))
if botdata.has_option("Enemy", "units"):
self.bot.data_attackunits = botdata.get('Enemy', 'units')
if botdata.has_section(str(self.bot.race_self)):
......
......@@ -43,6 +43,31 @@ class ProtossManager():
self.bot.strategy = strategies[self.bot.data_race_strategy]
print("Using strategy: " + str(self.bot.strategy))
else:
print("No Data - Picking random strategy")
self.bot.strategy = random.choice(list(strategies.values()))
print("Using strategy:" + str(self.bot.strategy))
if os.path.isfile('./data/stats.txt'):
statsdata = configparser.ConfigParser()
statsdata.read('./data/stats.txt')
if statsdata.has_section(str(self.bot.race_self)):
if statsdata.has_option(str(self.bot.race_self), "best_strategy"):
best_strategy = statsdata.get(str(self.bot.race_self), 'best_strategy')
enemydatafile = "./data/" + str(self.bot.opponent_id) + ".db"
if os.path.isfile("./data/" + str(self.bot.opponent_id) + ".db"):
enemydata = configparser.ConfigParser()
enemydata.read(enemydatafile)
if enemydata.has_option(str(self.bot.race_self), "loosing_strategy"):
loosingstrategy = enemydata.get(str(self.bot.race_self), 'loosing_strategy')
if loosingstrategy == best_strategy:
print(
"Not picking " + best_strategy + " cause we lost with that - Using random strategy")
del strategies[best_strategy]
self.bot.strategy = random.choice(list(strategies.values()))
print("Using strategy:" + str(self.bot.strategy))
return
print("No Data - Picking overall best strategy")
self.bot.strategy = strategies[best_strategy]
return
print("No Data - Picking random strategy")
self.bot.strategy = random.choice(list(strategies.values()))
print("Using strategy:" + str(self.bot.strategy))
......@@ -4,7 +4,7 @@ from sc2 import Race, Difficulty
from sc2.player import Bot, Computer
from m1ndb0t import m1ndb0t
bot = Bot(Race.Zerg, m1ndb0t())
bot = Bot(Race.Random, m1ndb0t())
# Start game
if __name__ == '__main__':
......@@ -17,5 +17,5 @@ if __name__ == '__main__':
print("Starting local game...")
sc2.run_game(sc2.maps.get("AutomatonLE"), [
bot,
Computer(Race.Random, Difficulty.Medium)
Computer(Race.Random, Difficulty.Hard)
], realtime=False)
......@@ -33,6 +33,31 @@ class TerranManager():
self.bot.strategy = strategies[self.bot.data_race_strategy]
print("Using strategy: " + str(self.bot.strategy))
else:
print("No Data - Picking random strategy")
self.bot.strategy = random.choice(list(strategies.values()))
print("Using strategy:" + str(self.bot.strategy))
if os.path.isfile('./data/stats.txt'):
statsdata = configparser.ConfigParser()
statsdata.read('./data/stats.txt')
if statsdata.has_section(str(self.bot.race_self)):
if statsdata.has_option(str(self.bot.race_self), "best_strategy"):
best_strategy = statsdata.get(str(self.bot.race_self), 'best_strategy')
enemydatafile = "./data/" + str(self.bot.opponent_id) + ".db"
if os.path.isfile("./data/" + str(self.bot.opponent_id) + ".db"):
enemydata = configparser.ConfigParser()
enemydata.read(enemydatafile)
if enemydata.has_option(str(self.bot.race_self), "loosing_strategy"):
loosingstrategy = enemydata.get(str(self.bot.race_self), 'loosing_strategy')
if loosingstrategy == best_strategy:
print(
"Not picking " + best_strategy + " cause we lost with that - Using random strategy")
del strategies[best_strategy]
self.bot.strategy = random.choice(list(strategies.values()))
print("Using strategy:" + str(self.bot.strategy))
return
print("No Data - Picking overall best strategy")
self.bot.strategy = strategies[best_strategy]
return
print("No Data - Picking random strategy")
self.bot.strategy = random.choice(list(strategies.values()))
print("Using strategy:" + str(self.bot.strategy))
......@@ -282,7 +282,7 @@ class UnitManager():
await self.createBuilding(requirementbuildingname, 1, random.choice(self.bot.townhalls).position, 15)
return
else:
await self.createBuilding(requirementbuildingname, 1, random.choice(self.bot.hq_location).position, 15)
await self.createBuilding(requirementbuildingname, 1, self.bot.hq_location, 15)
return
morphinfo = self.bot.techtree.get_building_morphbuilding(buildingid)
......
......@@ -58,7 +58,7 @@ class ZergManager():
loosingstrategy = enemydata.get(str(self.bot.race_self), 'loosing_strategy')
if loosingstrategy == best_strategy:
print("Not picking " + best_strategy + " cause we lost with that - Using random strategy")
list(strategies).remove(best_strategy)
del strategies[best_strategy]
self.bot.strategy = random.choice(list(strategies.values()))
print("Using strategy:" + str(self.bot.strategy))
return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment