Axis & Allies .org Forums
    • Home
    • Categories
    • Recent
    • Popular
    • Users
    • Register
    • Login
    1. Home
    2. mshih
    3. Best
    0% for April
    M
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 8
    • Best 5
    • Controversial 0
    • Groups 0

    Best posts made by mshih

    • RE: Implementation of "true" probability calculator

      This is in response to Dash’s comments about how to compute the probability terms used in his calculator.

      P(n units getting k hits, if p is the probability of 1 unit getting one hit) = (n choose k)p^k(1-p)^(n-k).

      Since axis & allies has non-homogenous forces (i.e. infantry + armor + bombers), these terms need to be further combined with complicated algorithms.

      There’s a simplification to this problem, if we assume fixed order of loss.

      Let p(i) == the probability of the ith unit getting a hit.  (e.g. for attacking inf ==> 1/6, attacking armor 3/6, etc…)
      Let p(i) be defined in the reverse order of loss.  This can be initialized trivially.

      Let P(i, j) == the probability that i units gets j hits.  This is the matrix that we’re trying to fill in.

      The following recurrence relation holds:
        P(i, j) = P(i-1, j-1) * p(i) + P(i-1, j) * (1-p(i))

      We then just need to define the initial conditions:
        P(0, 0) = 1
        P(0, j) = 0 for all j > 0
        P(i, 0) = P(i-1, 0) * (1 - p(i))

      We can now fill in P(i, j) for all i, j and compute all of the probability terms that will be needed for the attackers.

      The beauty of this formulation:

      • No powers
      • No factorials
      • No special logic needed to handle non-homogenous forces.
      • Complexity to compute all probability terms needed is O(n^2) :).
      • All of the subproblems solved are needed and will be used.

      Unfortunately, I believe updating the probabilities themselves is O(n^4).  So the computation of the probability terms themselves shouldn’t really be the bottleneck if they are precomputed.

      • Mitchell
      posted in Software
      M
      mshih
    • RE: Implementation of "true" probability calculator

      Actually fixed order of loss is pretty reasonable assumption for odds calculator…. We have to assume some type of standard order of loss.  It doesn’t have to be strictly decreasing…  For example, if attacker wants to capture at all costs, we can lose fighters and bombers before tanks.  Or if attacker wants to capture with at least 10 ground units, that’s also possible.

      AA guns can be handled by constructing separate tables corresponding to number of AA gun hits.

      So if attacker has 2i, 2a, 2f, and we’re facing AA gun, we need to solve
      F(f, f, a, a, i, i)  ;; 0 AA hits
      F(f, a, a, i, i)  ;; 1 AA hit
      F(a, a, i, i)  ;; 2 AA hits

      Subs only hitting ships can be handled in similar approach…
      Suppose the defending force is 2 fighters, 1 carrier, 1 battleship

      If the attacking force has some subs, then we may need to remove units out of order.  So we need to compute:
      F(B, C, f, f)    ;; 0 naval hits
      F(B, f, f) ;; 1 naval hit
      F(f, f) ;; 2 naval hits

      posted in Software
      M
      mshih
    • RE: mshih's aa1942calc2

      @djensen If you’re using typescript/javascript, my engine is available on npm.

      npm install aacalc2

      The webpage is basically something I vibe coded to showcase the engine.

      posted in Software
      M
      mshih
    • RE: mshih's aa1942calc2

      @djensen Aside from the pure speed. My calculator has some neat advanced features like:

      1. Compute the probability of winning for all sub-battles in one pass. This allows a second pass to implement things like retreat if the probability of winning the battle is too low.

      2. Compute the Expected profit for all sub-battles in one pass. This allows a second pass to implement retreat if the EV profit is too low (typically retreat if EV is negative).

      3. Strafe analysis is_deadzone, combined with the territory value can be used to model a variety of strafe scenarios.

      e.g. If strafing from a capital with a large army next door… a large negative value is warranted. (russia IPC’s * 2 + russia territory IPC value. + value of other allied units lost if the strafe turns into take. Using large values like -50 IPC’s is fair.

      If strafing from W.Russia… and W Russia is safe even if the strafe fails and the territory is captured, a normal positive territory value is good enough.

      1. Army recommendation - which can compute optimal strafes. If you set is_deadzone – and an appropriate territory value (positive or negative based on the situation), the army recommendation can recommend the sub-army that gives maximum expected profit.

      #1 and #2 are simple recurrence relations that I can share

      posted in Software
      M
      mshih
    • RE: mshih's aa1942calc2

      To compute EV profit for all sub-problems, the recurrence relation is:

      EV(i, j) = profit of state i attackers and j defenders.
      profit(ii, jj, i, j) = the incremental profit for moving from state (i, j) to (ii, jj).
      p(ii,jj) = probability of reaching state ii,jj from i, j
      
      EV(i, j) = sum( all next states ii, jj) {
            p(ii,jj) * profit(ii,jj, i, j)   + EV(ii,jj)
      }
      

      This doesn’t consider that you might retreat in the future… to handle that:

      EV(i, j) = sum( all next states ii, jj) {
            p(ii,jj) * profit(ii,jj, i, j)   + EV(ii,jj) > retreatThreshold ? EV(ii,jj) : 0
      }
      

      Initial state:

      EV(i, j) = 0 for all terminal states. // e.g. 0 attackers or 0 defenders, or any retreat conditions met.
      

      To compute Pwin for all sub-problems, the recurrence relation is:

      Pwin(i, j) = probability of winning
      
      Pwin(i, j) = sum (all next states ii, jj) {
           isRetreat = Pwin(ii, jj) < threshold;
           isRetreat ? 0 : p(ii,jj) * Pwin(ii,jj)
      }
      

      Initial state:
      Pwin(i, j) = 1 or 0 depending on win conditions. E.g. if takes then at least one land unit attacker.

      posted in Software
      M
      mshih
    • 1 / 1