def Carnosaur(UnitList, Points): Rider = UnitList.pop() BRB.Terror( BuildLizardModel(UnitList, 7, 3, 0, 7, 5, 5, 2, 4, 5, 3, 0, Points), 0) setattr(UnitList[-1], 'Blood-frenzy', 1) setattr(UnitList[-1], 'UltimatePredator', 1) UnitList.append(Rider) BRB.MonsterMount(UnitList[-1], UnitList[-2], 210) return UnitList
def deathbattle(UnitListA,UnitListB,verbose): while len(UnitListA) > 1 and len(UnitListB) > 1: Feartest(UnitListA,UnitListB,verbose) CombatRes = BRB.combatround(UnitListA,UnitListB,verbose) rankbonus1 = 3 if (len(UnitListA) - 1) / UnitListA[0].Width > 3 else (len(UnitListA) - 1) / UnitListA[0].Width rankbonus2 = 3 if (len(UnitListB) - 1) / UnitListB[0].Width > 3 else (len(UnitListB) - 1) / UnitListB[0].Width CombatRes += rankbonus1 - rankbonus2 if CombatRes > 0: if verbose >= 2: print "Army One won that round of combat by %i!" %(CombatRes) if len(UnitListB) > 1 and len(UnitListA) > 1 and len(UnitListB)/UnitListB[0].Width <= len(UnitListA)/UnitListA[0].Width: if BRB.breaktest(UnitListB,CombatRes,verbose) == 0: BRB.runaway(UnitListB,UnitListA,verbose) elif CombatRes < 0: CombatRes = abs(CombatRes) if verbose >= 2: print "Army two won that round of combat by %i!" %(CombatRes) if len(UnitListA) > 1 and len(UnitListB) > 1 and len(UnitListA)/UnitListA[0].Width <= len(UnitListB)/UnitListB[0].Width: if BRB.breaktest(UnitListA,CombatRes,verbose) == 0: BRB.runaway(UnitListA,UnitListB,verbose) else: if verbose >= 2: print "Combat was a tie!" if len(UnitListA) == 1: if verbose >= 1: print "Army Two wins with %i Models Remaining!" %(len(UnitListB)-1) return len(UnitListB)-1 elif len(UnitListB) == 1: if verbose >= 1: print "Army One wins with %i Models Remaining!" %(len(UnitListA)-1) return -(len(UnitListA)-1)
def Feartest(UnitListA,UnitListB,verbose): RemoveFear(UnitListA) RemoveFear(UnitListB) SetFear(UnitListA) SetFear(UnitListB) if FearCheck(UnitListA,UnitListB): if verbose >=4: print "Army Two must Fear Test!" if BRB.breaktest(UnitListB,0,verbose): if verbose >=4: print "Fear Test Passed!" else: BRB.runaway(UnitListB,UnitListA,verbose) if verbose >=4: print "Fear Test Failed!" if FearCheck(UnitListB,UnitListA): if verbose >=4: print "Army One must Fear Test!" if BRB.breaktest(UnitListA,0,verbose): if verbose >=4: print "Fear Test Passed!" else: BRB.runaway(UnitListA,UnitListB,verbose) if verbose >=4: print "Fear Test Failed!"
def Feartest(UnitListA, UnitListB, verbose): RemoveFear(UnitListA) RemoveFear(UnitListB) SetFear(UnitListA) SetFear(UnitListB) if FearCheck(UnitListA, UnitListB): if verbose >= 4: print "Army Two must Fear Test!" if BRB.breaktest(UnitListB, 0, verbose): if verbose >= 4: print "Fear Test Passed!" else: BRB.runaway(UnitListB, UnitListA, verbose) if verbose >= 4: print "Fear Test Failed!" if FearCheck(UnitListB, UnitListA): if verbose >= 4: print "Army One must Fear Test!" if BRB.breaktest(UnitListA, 0, verbose): if verbose >= 4: print "Fear Test Passed!" else: BRB.runaway(UnitListA, UnitListB, verbose) if verbose >= 4: print "Fear Test Failed!"
def SaurusWarrior(UnitList, number, Champion, Musician, Standard, spear): number2 = number if Champion == 1: BRB.Champion( BuildLizardModel(UnitList, 4, 3, 0, 4, 4, 1, 1, 3, 8, 2, 0, 11), 12) number2 -= 1 if Musician == 1: BRB.Musician( BuildLizardModel(UnitList, 4, 3, 0, 4, 4, 1, 1, 2, 8, 2, 0, 11), 6) number2 -= 1 if Standard == 1: BRB.Standard( BuildLizardModel(UnitList, 4, 3, 0, 4, 4, 1, 1, 2, 8, 2, 0, 11), 12) number2 -= 1 for x in range(number2): BuildLizardModel(UnitList, 4, 3, 0, 4, 4, 1, 1, 2, 8, 2, 0, 11) for x in range(len(UnitList) - number, len(UnitList)): BRB.Handweapon(BRB.Shield(UnitList[x], 0), 0) if spear == 1: UnitList[x].Points += 1 Spear(UnitList[x])
def SaurusOldblood(UnitList, Weapon, LA, S, Mount, *args): BRB.Handweapon( BuildLizardModel(UnitList, 4, 6, 0, 5, 5, 3, 4, 5, 8, 3, 0, 145), 0) if Weapon == 1: BRB.Spear(UnitList[-1], 8) elif Weapon == 2: BRB.GreatWeapon(UnitList[-1], 12) elif Weapon == 3: BRB.Halberd(UnitList[-1], 8) elif Weapon == 4: BRB.AHW(UnitList[-1], 8) if LA == 1: BRB.LA(UnitList[-1], 10) if S == 1: BRB.Shield(UnitList[-1], 6) if Mount == 1: BRB.ColdOne(UnitList, 30) elif Mount == 2: Carnosaur(UnitList, 210) for arg in args: pass ## insert magical items possible to hold here. suspect magical item assignment subroutine appropriate. try: army subroutine calls BRB subroutine.
def deathbattle(UnitListA, UnitListB, verbose): while len(UnitListA) > 1 and len(UnitListB) > 1: Feartest(UnitListA, UnitListB, verbose) CombatRes = BRB.combatround(UnitListA, UnitListB, verbose) rankbonus1 = 3 if (len(UnitListA) - 1) / UnitListA[0].Width > 3 else (len(UnitListA) - 1) / UnitListA[0].Width rankbonus2 = 3 if (len(UnitListB) - 1) / UnitListB[0].Width > 3 else (len(UnitListB) - 1) / UnitListB[0].Width CombatRes += rankbonus1 - rankbonus2 if CombatRes > 0: if verbose >= 2: print "Army One won that round of combat by %i!" % (CombatRes) if ( len(UnitListB) > 1 and len(UnitListA) > 1 and len(UnitListB) / UnitListB[0].Width <= len(UnitListA) / UnitListA[0].Width ): if BRB.breaktest(UnitListB, CombatRes, verbose) == 0: BRB.runaway(UnitListB, UnitListA, verbose) elif CombatRes < 0: CombatRes = abs(CombatRes) if verbose >= 2: print "Army two won that round of combat by %i!" % (CombatRes) if ( len(UnitListA) > 1 and len(UnitListB) > 1 and len(UnitListA) / UnitListA[0].Width <= len(UnitListB) / UnitListB[0].Width ): if BRB.breaktest(UnitListA, CombatRes, verbose) == 0: BRB.runaway(UnitListA, UnitListB, verbose) else: if verbose >= 2: print "Combat was a tie!" if len(UnitListA) == 1: if verbose >= 1: print "Army Two wins with %i Models Remaining!" % (len(UnitListB) - 1) return len(UnitListB) - 1 elif len(UnitListB) == 1: if verbose >= 1: print "Army One wins with %i Models Remaining!" % (len(UnitListA) - 1) return -(len(UnitListA) - 1)
def Skink(UnitList, number, Champion, Musician, Standard, Kroxigors): number2 = number if Champion == 1: BRB.Champion( BuildLizardModel(UnitList, 6, 2, 3, 3, 2, 1, 4, 2, 6, 1, 1, 5), 8) number2 -= 1 if Musician == 1: BRB.Musician( BuildLizardModel(UnitList, 6, 2, 3, 3, 2, 1, 4, 1, 6, 1, 1, 5), 6) number2 -= 1 if Standard == 1: BRB.Standard( BuildLizardModel(UnitList, 6, 2, 3, 3, 2, 1, 4, 1, 6, 1, 1, 5), 8) number2 -= 1 if Kroxigors > 0: Kroxigor(UnitList, Kroxigors, 0, 0, 0) for x in range(number2): BuildLizardModel(UnitList, 6, 2, 3, 3, 2, 1, 4, 1, 6, 1, 1, 5) for x in range(len(UnitList) - number, len(UnitList)): BRB.Handweapon( BRB.Javelin(BRB.Shield(Aquatic(JunglePoisons(UnitList[x])), 0), 0), 0)
def BuildModel(unitList,Mov,WepS,BalS,Str,Tuf,Wnd,ini,ata,Led,Armr,Ward,Points): BRB.BuildModel(unitList,Mov,WepS,BalS,Str,Tuf,Wnd,ini,ata,Led,Armr,Ward,Points) setattr(unitList[-1],'EternalHatred') setattr(unitList[-1],'Hatred')
'ground.png': load_tile_table('ground.png', MAP_TILE_WIDTH, MAP_TILE_HEIGHT), } SPRITE_CACHE = TileCache(32, 32) sprites = pygame.sprite.RenderUpdates() skelly = [] Unit1 = [] Unit2 = [] Unit1.minX = 0 for pos, tile in level.items.iteritems(): sprite = Sprite(pos, SPRITE_CACHE[tile["sprite"]]) if tile['name'] == 'skeleton': print pos if pos[1] < 12: Unit1.append( (sprite, BRB.Model(4, 3, 3, 4, 4, 1, 2, 2, 9, 2, 1, 10))) else: Unit2.append( (sprite, BRB.Model(4, 3, 3, 4, 4, 1, 2, 2, 9, 2, 1, 10))) skelly.append(sprite) sprites.add(sprite) clock = pygame.time.Clock() background, overlay_dict = level.render() overlays = pygame.sprite.RenderUpdates() sprites.clear(screen, background) sprites.update() dirty = sprites.draw(screen) overlays.draw(screen) pygame.display.update(dirty)
def BuildLizardModel(unitList, Mov, WepS, BalS, Str, Tuf, Wnd, ini, ata, Led, Armr, Ward, Points): BRB.BuildModel(unitList, Mov, WepS, BalS, Str, Tuf, Wnd, ini, ata, Led, Armr, Ward, Points) setattr(unitList[-1], "ColdBlooded", 1) return unitList[-1]
import BRB import Lizardmen def initializearmies(UnitList1, UnitList2): Lizardmen.SaurusWarrior(UnitList1, 32, 1, 1, 1, 0) Lizardmen.SaurusOldblood(UnitList2, 2, 1, 1, 2) return UnitList1, UnitList2 sims = 5000 total = 0 totalMargin1 = 0 totalMargin2 = 0 for x in range(sims): UnitList1 = [BRB.Unit()] UnitList1[0].Width = 8 UnitList2 = [BRB.Unit()] UnitList2[0].Width = 2 UnitList1, UnitList2 = initializearmies(UnitList1, UnitList2) margin = units.deathbattle(UnitList1, UnitList2, 0) if margin < 0: total -= 1 totalMargin1 += 1.0 * margin else: total += 1 totalMargin2 += 1.0 * margin if total < 0: base = (sims + total) / (sims * .02) print "Army One won %f percent of the time; Army Two won %f percent." % ( (base + (abs(total) / (sims / 100.0))), base)