CQ全国赛iron and ice (塔防)11000分 参考程序
比赛链接
2022.11.24 8000分代码,更新了地图,行动轨迹,每次循环只执行一个防御塔的建造和传送
map = [[], [0,[18,87],[18,74],[18,62],[18,52],[18,40],[18,28],[18,16]], [0,[30,87],[30,74],[30,62],[30,52],[30,40],[30,28],[30,16]], [0,[42,87],[42,74],[42,62],[42,52],[42,40],[42,28],[42,16]], ] ls = ['cannon','mage','archer','frost'] a = ['A','B','C','D','F','G','I'] b = [[77, 51],[77, 75],[78, 27],[102, 27],[101, 77],[90, 86],[90, 14]] ab = ["cannon","mage","mage","mage","mage","cannon","cannon","mage","mage"] t20 = [[30,51],[30,39],[30,64],[42,75],[42,51],[42,28],[30,26],[30,77],[18,75],[18,27],[30,88],[30,15]] b20 = ["archer","archer","archer","cannon","cannon","cannon","archer","archer","archer","archer","archer","archer"] ac1 = [(2,2,4),(2,2,5),(2,2,3),(0,3,2),(0,3,4),(0,3,6),(2,2,6),(2,2,2),(2,1,6),(2,1,2),(2,2,1),(2,2,7),(0,1,4) ,(1,1,3),(1,1,5),(1,1,1),(1,1,7),(2,3,1),(2,3,7)] i = 0 while i<len(t20): #先把公告区域建造 #print("第%d个建筑,法力值剩余:%d"%(i,hero.mana)) if hero.canBuildAt(t20[i][0], t20[i][1]): hero.build(b20[i], t20[i][0], t20[i][1]) i+=1 if hero.isReady("pull") and hero.isReady("teleport"): hero.special("pull", 60, 51) hero.wait(1.5) hero.special("teleport", 60, 51) hero.special("burst", 14, 51) i = 0 while i<len(a): #先把公告区域建造 #print("第",i,"建筑,法力值剩余:",hero.mana) hero.build(ab[i], a[i]) i+=1 if hero.isReady("pull") and hero.isReady("teleport"): hero.special("pull", 60, 51) hero.wait(1.5) hero.special("teleport", 60, 51) hero.special("burst", 14, 51) for i in range(len(b)): x = b[i][0] y = b[i][1] if hero.canBuildAt(x, y): hero.build("archer", x,y) i = 0 while hero.time<140: if hero.isReady("pull") and hero.isReady("teleport"): hero.special("pull", 60, 51) hero.wait(1.5) hero.special("teleport", 60, 51) hero.special("burst", 14, 51) x = ac1[i][1] y = ac1[i][2] name = ls[ac1[i][0]] hero.build(name,map[x][y][0],map[x][y][1]) i+=1 if i>=len(ac1): i = 0 print(hero.getWaveNumber()) while hero.time<140: if hero.isReady("pull") and hero.isReady("teleport"): hero.special("pull", 60, 51) hero.wait(1.5) hero.special("teleport", 60, 51) hero.special("burst", 14, 51) hero.build("mage", 30,51) hero.build("cannon", 30,39) hero.build("cannon", 30,64) hero.build("cannon", 30,27) hero.build("cannon", 'A') hero.build("cannon", 'F') hero.build("cannon", 'G') hero.build("cannon", 42,75) hero.build("cannon", 42,51) hero.build("cannon", 42,28) hero.build("mage", 'B') hero.build("mage", 'C') hero.special("push", 18, 51) print(hero.getWaveNumber()) while True: if hero.isReady("pull") and hero.isReady("teleport"): hero.special("pull", 60, 51) hero.wait(1.5) hero.special("teleport", 60, 51) hero.special("burst", 14, 51) hero.build("frost", 42,75) hero.build("frost", 42,51) hero.build("frost", 42,28) hero.build("frost", 'G') hero.build("frost", 'F') hero.build("frost", 'H') hero.build("frost", 'I') hero.build("frost", 29,52) hero.build("cannon", 30,39) hero.build("cannon", 30,64) hero.build("mage", 'A') hero.build("mage", 'B') hero.build("mage", 'C') hero.special("push", 18, 51)
2022.12.02 11000分代码,三个行动轨迹列表,把各种打法封装,更加简洁了
list1 = [("archer",30,52),("archer",30,64),("archer",30,40),("archer",42,52),("archer",42,76),("archer",42,28),("archer",30,28),("archer",30,76),("archer",18,76),("archer",18,28),("archer",30,88),("archer",30,16),("archer",42,63),("archer",42,39),("archer",18,87),("archer",18,63),("archer",18,39),("archer",18,15),("archer",42,88),("archer",42,16),("archer",18,51)] list2 = [("archer",30,88),("archer",30,76),("archer",30,52),("archer",30,64),("archer",30,40),("archer",30,28),("archer",30,16),("cannon",42,89),("cannon",42,63),("cannon",42,39),("cannon",42,16),("frost",42,52),("frost",42,76),("frost",42,28),("mage",18,76),("mage",18,28),("mage",18,87),("mage",18,63),("mage",18,15),("mage",18,51),("mage",18,41)] list3 = [("archer",30,88),("cannon",30,76),("cannon",30,52),("archer",30,64),("archer",30,40),("cannon",30,28),("archer",30,16),("frost",42,89),("frost",42,63),("frost",42,39),("frost",42,16),("frost",42,52),("frost",42,76),("frost",42,28),("mage",18,76),("mage",18,28),("mage",18,87),("mage",18,63),("mage",18,15),("mage",18,51),("mage",18,41)] list4 = [("archer",30,88),("cannon",30,76),("cannon",30,52),("frost",30,64),("frost",30,40),("cannon",30,28),("archer",30,16),("frost",42,89),("frost",42,63),("frost",42,39),("frost",42,16),("frost",42,52),("frost",42,76),("frost",42,28),("mage",18,76),("mage",18,28),("mage",18,87),("mage",18,63),("mage",18,15),("frost",18,51),("mage",18,41)] # 反传送 def back(): for i in hero.findActiveAnomalies() : if i.name == "teleport" and hero.isReady("teleport"): hero.wait(0.1) hero.special("teleport", i.endX, i.endY) # 借刀杀人 def back_2(): if len(hero.findActiveAnomalies()) > 0 : for i in hero.findActiveAnomalies() : if i.name == "pull" and 50<i.x<70 and hero.isReady("teleport"): hero.wait(0.8) hero.special("teleport", i.x, i.y) def pull_attack(): if hero.isReady("pull"): hero.special("pull", 114, 51) def pull_protect(): if hero.isReady("pull"): hero.special("pull", 42, 51) def pull_protect_2(): if hero.isReady("pull"): hero.special("pull", 42, 76) def burst(): if hero.isReady("burst"): hero.special("burst",10,51) def burst_attack(): if hero.isReady("burst"): hero.special("burst", 74, 51) def push(): if hero.isReady("push"): hero.special("push",10,51) i = 0 while True: if hero.time > 45: break if hero.mana >= 25: hero.build(list1[i][0],list1[i][1],list1[i][2]) i = i + 1 if i == 21: i = 0 elif len(hero.findActiveAnomalies()) > 0 : back() else: if hero.time >= 3: pull_protect() if hero.time >= 5: burst() push() i = 0 while True: if hero.time > 120: break if hero.mana >= 25: hero.build(list2[i][0],list2[i][1],list2[i][2]) i = i + 1 if i == 21: i = 0 elif len(hero.findActiveAnomalies()) > 0 : back() else: pull_protect_2() burst() push() i = 0 while True: if hero.time >= 155: break if hero.mana >= 25: hero.build(list3[i][0],list3[i][1],list3[i][2]) i = i + 1 if i == 21: i = 0 elif len(hero.findActiveAnomalies()) > 0 : back() else: pull_protect_2() burst() push() i = 0 while True: if hero.mana >= 25: hero.build(list4[i][0],list4[i][1],list4[i][2]) i = i + 1 if i == 21: i = 0 elif len(hero.findActiveAnomalies()) > 0 : back() else: if hero.time > 160: burst_attack() pull_attack() else: burst() push() pull_protect_2()