int entNum = game.getFirstEntityNum(getLocalPlayer());
int entNum = game.getFirstEntityNum();
  public void calculatePhysicalTurn() {    int entNum = game.getFirstEntityNum(getLocalPlayer());    int first = entNum;    do {      // take the first entity that can do an attack      Entity en = game.getEntity(entNum);      CEntity cen = this.enemies.get(en);      PhysicalOption bestAttack = getBestPhysical(en);      if (bestAttack != null) {        if (bestAttack.type == PhysicalOption.KICK_LEFT || bestAttack.type == PhysicalOption.KICK_RIGHT) {          int side = Compute.getThreatHitArc(bestAttack.target.getPosition(), bestAttack.target.getFacing(), en.getPosition());          double odds = 1.0 - (double)Compute.oddsAbove(Compute.toHitKick(game, entNum, bestAttack.target.getId(), bestAttack.type - 3).getValue())/100;          // Meks can kick Vehicles and Infantry, too!          double mod = 1.0;          if ( bestAttack.target instanceof Mech ) {              double llarmor = bestAttack.target.getArmor(Mech.LOC_LLEG) /                   bestAttack.target.getOArmor(Mech.LOC_LLEG);              double rlarmor = bestAttack.target.getArmor(Mech.LOC_RLEG) /                   bestAttack.target.getOArmor(Mech.LOC_RLEG);              switch (side) {              case CEntity.SIDE_FRONT:                  mod = (llarmor + rlarmor)/2;                  break;              case CEntity.SIDE_LEFT:                  mod = llarmor;                  break;              case CEntity.SIDE_RIGHT:                  mod = rlarmor;                  break;              }          }          else if ( bestAttack.target instanceof Infantry ) {              mod = 0.0;          }          else if ( bestAttack.target instanceof Tank ) {              switch (side) {              case CEntity.SIDE_FRONT:                  mod = bestAttack.target.getArmor(Tank.LOC_FRONT) /                       bestAttack.target.getOArmor(Tank.LOC_FRONT);                  break;              case CEntity.SIDE_LEFT:                  mod = bestAttack.target.getArmor(Tank.LOC_LEFT) /                       bestAttack.target.getOArmor(Tank.LOC_LEFT);                  break;              case CEntity.SIDE_RIGHT:                  mod = bestAttack.target.getArmor(Tank.LOC_RIGHT) /                       bestAttack.target.getOArmor(Tank.LOC_RIGHT);                  break;              case CEntity.SIDE_REAR:                  mod = bestAttack.target.getArmor(Tank.LOC_REAR) /                       bestAttack.target.getOArmor(Tank.LOC_REAR);                  break;              }          }          double damage = 2/(1 + mod)*bestAttack.expectedDmg;          double threat = .2*en.getWeight()*odds*(1-cen.base_psr_odds);          //check for head kick          Hex h = game.board.getHex(bestAttack.target.getPosition());          Hex h1 = game.board.getHex(en.getPosition());          if (h1.getElevation() > h.getElevation()) {            damage *= 2;          }          Enumeration e = game.getEntities();          double temp_threat = 0;          int number = 0;          while (e.hasMoreElements()) {            Entity enemy = (Entity)e.nextElement();            if (!enemy.isProne() && enemy.getPosition().distance(en.getPosition()) < 3) {              if (enemy.isEnemyOf(en)) {                number++;              } else {                number--;              }            }          }          if (number > 0) {            threat += number*temp_threat;          }          //take a kick if it is in your favor and you not healthy and it is risky          if (!((damage > threat && !(cen.overall_armor_percent > .8 && odds > .9)) || (odds < .5 && cen.base_psr_odds > .5))) {            boolean left = false;            boolean right = false;            ToHitData toHit = Compute.toHitPunch(game, en.getId(), bestAttack.target.getId(), PunchAttackAction.LEFT);            if (toHit.getValue() != ToHitData.IMPOSSIBLE) {              left = true;            }            toHit = Compute.toHitPunch(game, en.getId(), bestAttack.target.getId(), PunchAttackAction.RIGHT);            if (toHit.getValue() != ToHitData.IMPOSSIBLE) {              right  = true;            }            if (left) {              if (right) {                bestAttack.type = PhysicalOption.PUNCH_BOTH;              } else {                bestAttack.type = PhysicalOption.PUNCH_LEFT;              }            } else if (right) {              bestAttack.type = PhysicalOption.PUNCH_RIGHT;            } else {              sendAttackData(entNum, new java.util.Vector(0));              return;            }          }        }        java.util.Vector v = new java.util.Vector();        v.addElement(bestAttack.toAction(game, entNum));        sendAttackData(entNum, v);        return;      }      entNum = game.getNextEntityNum(getLocalPlayer(), entNum);    } while (entNum != -1 && entNum != first);  }