this.enemies.get(mustMove).refresh(); this.enemies.get(mustMove).moved = false;
CEntity centity = this.enemies.get(mustMove);  centity.refresh = true; centity.moved = false; centity.refresh();  this.old_moves = null; System.out.println("reset entity " + mustMove.getId());
  public void calculateMoveTurn() {    long enter = System.currentTimeMillis();    int initiative = 0;    EntityState min = null;    //I'm not quite sure where to put this, but we need to make sure that if    //an entity falls, and gets another turn, that it takes it -- Ben    if (game.getTurn() instanceof GameTurn.SpecificEntityTurn) {        GameTurn.SpecificEntityTurn turn = (GameTurn.SpecificEntityTurn)game.getTurn();        Entity mustMove = game.getEntity(turn.getEntityNum());        this.enemies.get(mustMove).refresh();        this.enemies.get(mustMove).moved = false;    }    //first check and make sure that someone else has moved so that we don't replan    Object[] enemy_array = this.getEnemyEntities().toArray();    for (int j = 0; j < enemy_array.length; j++) {      if (!((Entity)enemy_array[j]).isSelectable()) {        initiative++;      }    }        if (initiative == enemies_moved && old_moves != null) {      min = this.old_moves.getResult();      if (min == null) return;      if (!min.isMoveLegal() || (min.isPhysical && min.PhysicalTarget.isPhysicalTarget)) {        this.old_moves = null;        this.calculateMoveTurn();        return;      }    } else {      enemies_moved = initiative;      Vector possible = new Vector();      Iterator i = this.getEntitiesOwned().iterator();      boolean short_circuit = false;            while(i.hasNext()) {            Entity entity = (Entity)i.next();        CEntity cen = this.enemies.get(entity);                // if we can't move this entity right now, ignore it        if (!game.getTurn().isValidEntity(entity)) {            continue;        }                MoveThread mt = new MoveThread(entity); //so things don't slow down too much, use a thread        System.out.println("Contimplating movement of "+entity.getShortName()+" "+entity.getId());        mt.start();        try {          mt.join();        } catch (Exception e) {          e.printStackTrace();        }	// If this entity can still move, add its	// move result to the list of possible moves.	if ( !cen.moved ) {	    possible.add(mt.result);	}        if (cen.entity.isImmobile() && !cen.moved) {          cen.moved = true;          this.calculateMoveTurn();          return;        } else if (!cen.moved && mt.result.length < 6) {          min = (EntityState)mt.result[0];          //move to the head of the class...          short_circuit = true;        }      }      //should ignore mechs that are not engaged      //and only do the below when there are 2 or mechs left to move      if (!short_circuit) {        if (this.getEntitiesOwned().size() > 1) {          try {            GALance lance = new GALance(this, possible, 50, 80);            Thread lanceThread = new Thread(lance);            lanceThread.start();            lanceThread.join();            min = lance.getResult();            this.old_moves = lance;          } catch (GAException gae) {            System.out.println(gae.getMessage());          } catch (Exception e) {            e.printStackTrace();          }        } else {          min = ((EntityState[])possible.elementAt(0))[0];        }      }    }    for (int d = 0; d < enemy_array.length; d++) {      Entity en = (Entity)enemy_array[d];      CEntity enemy = this.enemies.get(en);      int enemy_hit_arc = Compute.getThreatHitArc(enemy.old.curPos, enemy.old.curFacing, min.curPos);      enemy.expected_damage[enemy_hit_arc] += min.damages[d];      if (enemy.expected_damage[enemy_hit_arc] > 0) {        enemy.hasTakenDamage = true;      }    }    if (min.isPhysical) {      min.PhysicalTarget.isPhysicalTarget = true;    }    Iterator k = min.tv.iterator();    String threat = "";    while(k.hasNext()) threat += k.next()+" ";    System.out.println(min.entity.getShortName()+" "+min.entity.getId()+" to "+min.getKey()+" from "+this.enemies.get(min.entity).old.getKey()+" "+min+"\n Utility: "+min.getUtility()+" \n"+threat+"\n");    sendChat("Moved " + min.entity.getShortName()+" to "+min.curPos);    this.my_mechs_moved++;    moveEntity(min.entity.getId(), min.getMovementData());    min.centity.moved = true;    min.centity.old = min;    min.centity.last = min;        long exit = System.currentTimeMillis();    System.out.println("move turn took " + (exit - enter) + " ms");  }