Wall Path Calculator

Discussion in 'Build Strategies' started by Skye, Aug 4, 2015.

  1. Skye

    Skye Commodore

    Another little project I made. As usual expect bugs and slight deviations from what actually happens in game. The path units take is usually very complicated.

    http://xskye.com/projects/wpc/wpc.html

    The use of this is to figure out when units will decide to break through a wall vs go around it. As explained in another thread by Lynsey, the way AI currently works is it decides how long it will take to destroy a wall, and figures out whether or not it will be faster to walk around it. I preloaded it with preset values for maxed ac8 bombers/brutes/gunners/hg/sky raiders, and hp values for walls 9-13, as well as all levels of sm and bs. It defaults to 1 lv13 wall with sm3, and 1 bomber with bs4.

    The way it works is it calculates how long it will take to destroy a wall, both in number of hits, and in number of seconds. It then figures out how many tiles it could walk in that amount of time.

    I'm going to illustrate/explain how things work with a couple images. Your starting position is the mine, and you are going to the colorful flowerbox.

    There are a couple scenarios. The first scenario is the straightforward block of walls.
    [​IMG]
    You either spend some time destroying the walls, and walk straight through it, or you walk around the block.
    To walk around the block, you're walking some tiles to the side, walking the thickness of the walls, and walking back.
    First the calculator will tell you how fast you destroy one/all of the walls, and how far you can walk during that.
    Then the calculator will tell you how far away its worth walking to go through a point that is one wall less thick
    The calculator will finally tell you the furthest distance away that the hole its walking thru is faster than destroying the walls. This is the value we're looking for here. As long as the hole is closer than that, it will follow the path shown.

    In the second scenario, everything is very similar, except the target is slightly farther away from the wall, and the wall has a empty row in the middle.
    [​IMG]
    This time, after the unit passes through the hole, it will (read: should, actual results vary) be walking back at a diagonal, to save time. The actual calculation for this is really complicated, as the diagonal is the sqrt of the sum of the squared distance after the wall the target is plus the squared horizontal distance of the wall. I'd be very interested to see how Midoki calculates this, which might be why the paths are so buggy.

    The empty wall in the middle of the walls also means that the time it takes to destroy the walls is less than the previous example.

    The third scenario, the wall starts off thicker, and then gets thinner before ending.
    [​IMG]
    In this example, in addition to looking at how far away the hole is (where the wall ends), we also want to see at what point its better to walk over and break through one wall than it is to just break straight through both.
    If you make your walls taper off faster than this, you can pretty much guarantee the fastest route is going to be just following the perimeter of the walls. If its faster to walk 6 walls and break through 2 instead of breaking through 3, its going to be faster to walk 12 walls and break through 1, or 18 walls and not break through any. As long as you keep your walls sticking to this rule, you can guide troops where you want them.

    Also yes I realize I made the left side slightly shorter on accident, it was supposed to be symmetrical. The unit will actually walk around to the left.

    In the final example, I show you how to figure things out for a gunner. Since gunners can attack from at a range, you're not calculating it for where the target is, but rather the tile they want to walk to to shoot that target.
    [​IMG]
    In this scenario, you want to use a distance of 1, since the gunner can shoot from 5 away. The flowerbox is the square the gunner will be shooting the outhouse from. You have to think about all the tiles the gunner could reach the outhouse from (use my island editor from the other thread, and turn on the gunner range for the building), and then find the closest one and calculate it walking to that square. The square it walks to going around the wall won't always be the same as the square it would walk to shooting through the wall, but the total distance traveled will be within a couple, so adjust as needed.


    As a sidenote, I'm calculating the best result both for a single unit and for a group of units, but I don't believe the game factors in groups when deciding if it should hit a wall. Given the various walk and attack speeds of different troops, it starts to get very complicated to figure it out. Also note that all values are based on grass speed, but that troops walk slower on sand or in water. If you place decorations near walls to give them a lawn, you might make troops walk further around it!

    Let me know if you find any bugs, and I hope this helps you all with some creative bases.
     
    Ebow, mlc, M1nth and 5 others like this.
  2. # Johnny Doe #

    # Johnny Doe # First Mate

    Wow @Skye, I appreciate how long it would take just to write this post...never mind how long to come up with and create the content!

    Awesome!! :)
     
  3. Skye

    Skye Commodore

    Glad you appreciate it :) In game results will probably be a bit different, but its a starting point for sure.
     
  4. awbo

    awbo Captain

    God @Skye can't Midoki just hire you already ;)
     
    Captain Catbeard likes this.
  5. Ultimate Sea Dog

    Ultimate Sea Dog First Mate

    AWESOME! LUV IT! But, PLEASE PLEASE PRETTY PLEASE add walls and troops for other levels...
     
  6. Skye

    Skye Commodore

    I didn't want to add too many buttons but they're easy to add if you know what the stats are - any requests? For now you can type in stats for your troop levels. I know wall 8 is 2750, I think wall 7 is 2500, but I'm unsure of any numbers below that.

    Also I'm not sure on bomber atk speed, I just noticed I set brutes movement too high so I'll fix that and add more troops tonight, and troops don't always seem to do whats actually fastest in the real game :c
     
  7. Ultimate Sea Dog

    Ultimate Sea Dog First Mate

    Wall 6-1400
    Bomber (AC4): 110 DMG
    Jugg (AC4): 110
    Thief has WGT, Bucc, Gun, Brute has abilities. SR dosen't have ROF till PH6/AC5.
    Bomber ATK speed, is 15.
     
  8. Skye

    Skye Commodore

    I added wall 1-8 and juggernaut, and fixed bomber/brute speed stats.
    I'm still going to have to go thru all the AC tiers and calculate stats for ac 1-7 for all troops,
     
  9. Ultimate Sea Dog

    Ultimate Sea Dog First Mate

    Why don't you let us do it ourselves? I mean, like, type "Damage = 100" or "HP = 1000" ourselves? That would save you loads of time.
     
  10. Skye

    Skye Commodore

    You can! You can type it in to the spots. The buttons just fill them in for you to save time.
     
  11. Skye

    Skye Commodore

    [​IMG]

    If you click in these boxes you can type in new numbers (it should only let you type numbers depending on your browser, but if you manage to write "pizza" into the damage, don't expect it to work). Everything will recalculate as you type. And on Chrome, it even gives you nice little up/down arrows you can click to increase/decrease things by 1. On iOS Safari I know you have to type it in yourself though.
     
  12. Ultimate Sea Dog

    Ultimate Sea Dog First Mate

    I am on a Windows computer. And I typed "pizza". LOL IT worked.
     
    Skye and peg-brain bob like this.
  13. peg-brain bob

    peg-brain bob Captain

    Did it direct gunner to nearest Pizza Hut?
     
    Captain Catbeard, Bou Regreg and Skye like this.
  14. Ultimate Sea Dog

    Ultimate Sea Dog First Mate

    No. It directed the gunner to go to the Tavern in hope of finding Pizza.:D
     
    peg-brain bob likes this.
  15. Skye

    Skye Commodore

    I have updated this to include SM4, and also show how many hits it will take when a legendary buff is applied. The legendary hp buff does not impact AI behavior, so I made it a separate line, since the units are still only considering how far they could walk if it wasn't being applied.
     
  16. Skye

    Skye Commodore

    I have updated it with the new walls and AC stats. I also fixed the attack speed to match the actual in game numbers, instead of close estimates. Attack speed is now the time between bullets in seconds (for gunners, it fires a bullet, waits .7 seconds, and then fires again, for example). Lower numbers are faster.

    I also have a theory as to why HG is hitting walls so often when there is an opening nearby when other troops with more dps don't attack it- it could be completely wrong, maybe someone on staff can confirm or deny.

    HG does damage in a special way. It fires 5 bullets at an attack speed of .2, and then has a 1s cooldown before firing again. This means the first five bullets are an attack speed of .2, and if 5 bullets is enough to destroy the wall, the attack speed will be .2. However, if the wall takes 6 bullets to destroy, the attack speed will be .4, as it fires 5 bullets at .2, and then cools down for 1 second. This then goes on firing at .2 up to 10 bullets, where it has fired 10 at .2 and cooled down for 1 second, or .3 average attack speed. It then raises back up to .4 over the next cooldown, and on bullet 11 its back to .4 attack speed before dropping back down slightly. It oscillates between .4 and a number increasingly close to .4. You can see how this gets very complicated very fast, especially if there are multiple HG firing at it. With just one, it could be done with a somewhat simple formula, but with many, possibly firing at offset times to each other, it gets much messier.

    For the purposes of the calculator I have used .2 as the attack speed. If it takes more than 5 bullets, it will take longer to actually destroy, up to twice as long. However, assuming the game uses this simple approach like I am and just counting it as .2 regardless of how long it actually takes, walls may be seen as around twice as easy to destroy as they actually are, as on higher HP walls it has gotten a lot closer to .4s attack speed. Assuming double damage to walls over what they would actually be taking would make them much more optimal to destroy.

    This is a very complicated thing to model when there is more than one unit, as its the sum of several oscillating functions. It is possible, but I understand if they have chosen the simple path like me and just used .2 seconds per attack.

    Given that already damaged walls are already a huge incentive to destroy them as opposed to walking around, and allowing for this twice-as-fast-as-real-damage optimized scenario, HG attacking walls is much more understandable, given their already enormous amount of DPS and slow walking speed.

    I invite someone to come up with a good mathematical model for an arbitrary number of HG at arbitrary time offsets to each other using this oscillating attack speed to get a real answer. I could do it if I had the patience, but the simpler approach is probably more accurate to what they do in game, even if it isn't technically optimal, and I don't think its worth the time.

    To generate an accurate value in real time is probably much more processing time than its worth, and I don't blame Midoki if they are just using .2 like I am. People might be happier if it switches to .4 and uses the limit instead (making them more likely to walk around), I actually like that they prefer walls as it lets me cut an opening in a damaged segment with HG and lets me use more HG and save a couple bombers.
     
  17. Skye

    Skye Commodore

    Thanks to c00ni, I noticed the 100% wallbreaker 1 ability of bombers was increased to 130% - updated with those values.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice