default : case 0 : return new Coords(game.getBoard().getWidth() / 2, game.getBoard().getHeight() / 2); case 1 : return new Coords(1, 1); case 2 : return new Coords(game.getBoard().getWidth() / 2, 1); case 3 : return new Coords(game.getBoard().getWidth() - 2, 1); case 4 : return new Coords(game.getBoard().getWidth() - 2, game.getBoard().getHeight() / 2); case 5 : return new Coords(game.getBoard().getWidth() - 2, game.getBoard().getHeight() - 2); case 6 : return new Coords(game.getBoard().getWidth() / 2, game.getBoard().getHeight() - 2); case 7 : return new Coords(1, game.getBoard().getHeight() - 2); case 8 : return new Coords(1, game.getBoard().getHeight() / 2); }
default : case 0 : valid_array = new Coords[game.getBoard().getWidth()*game.getBoard().getHeight()]; fitness = new double[game.getBoard().getWidth()*game.getBoard().getHeight()]; break; case 1 : valid_array = new Coords[(3*game.getBoard().getWidth())+(3*game.getBoard().getHeight())-9]; fitness = new double[(3*game.getBoard().getWidth())+(3*game.getBoard().getHeight())-9]; break; case 2 : valid_array = new Coords[game.getBoard().getWidth()*3]; fitness = new double[game.getBoard().getWidth()*3]; break; case 3 : valid_array = new Coords[(3*game.getBoard().getWidth())+(3*game.getBoard().getHeight())-9]; fitness = new double[(3*game.getBoard().getWidth())+(3*game.getBoard().getHeight())-9]; break; case 4 : valid_array = new Coords[game.getBoard().getHeight()*3]; fitness = new double[game.getBoard().getHeight()*3]; break; case 5 : valid_array = new Coords[(3*game.getBoard().getWidth())+(3*game.getBoard().getHeight())-9]; fitness = new double[(3*game.getBoard().getWidth())+(3*game.getBoard().getHeight())-9]; break; case 6 : valid_array = new Coords[game.getBoard().getWidth()*3]; fitness = new double[game.getBoard().getWidth()*3]; break; case 7 : valid_array = new Coords[(3*game.getBoard().getWidth())+(3*game.getBoard().getHeight())-9]; fitness = new double[(3*game.getBoard().getWidth())+(3*game.getBoard().getHeight())-9]; break; case 8 : valid_array = new Coords[game.getBoard().getHeight()*3]; fitness = new double[game.getBoard().getHeight()*3]; break; }  counter = 0; for (test_x = 0; test_x <= game.getBoard().getWidth(); test_x++){ for (test_y = 0; test_y <= game.getBoard().getHeight(); test_y++){ test_hex.x = test_x; test_hex.y = test_y; if (game.getBoard().isLegalDeployment(test_hex, this.getLocalPlayer())){ if (!deployed_ent.isHexProhibited(game.getBoard().getHex(test_hex.x, test_hex.y))) { valid_array[counter] = new Coords(test_hex); counter++; } } } }     for (valid_arr_index = 0; valid_arr_index < counter; valid_arr_index++){ arr_x_index = Compute.randomInt(counter); if (arr_x_index < 0){ arr_x_index = 0; } test_hex = valid_array[valid_arr_index]; valid_array[valid_arr_index] = valid_array[arr_x_index]; valid_array[arr_x_index] = test_hex; }    highest_elev = -100; lowest_elev = 100; for (valid_arr_index = 0; valid_arr_index < counter; valid_arr_index++){ if (game.getBoard().getHex(valid_array[valid_arr_index].x, valid_array[valid_arr_index].y).getElevation() > highest_elev) { highest_elev = game.getBoard().getHex(valid_array[valid_arr_index].x, valid_array[valid_arr_index].y).getElevation(); } if (game.getBoard().getHex(valid_array[valid_arr_index].x, valid_array[valid_arr_index].y).getElevation() < lowest_elev) { lowest_elev = game.getBoard().getHex(valid_array[valid_arr_index].x, valid_array[valid_arr_index].y).getElevation(); } }      av_range = 0.0; weapon_count = 0; weapons = deployed_ent.getWeaponList(); for (Enumeration i = weapons.elements(); i.hasMoreElements();) { Mounted mounted = (Mounted)i.nextElement(); WeaponType wtype = (WeaponType)mounted.getType(); if ((wtype.getName() != "ATM 3") && (wtype.getName() != "ATM 6") && (wtype.getName() != "ATM 9") && (wtype.getName() != "ATM 12")){ if (deployed_ent.getC3Master() != null){ av_range += (((double) wtype.getLongRange()) * 1.25); } else { av_range += (double) wtype.getLongRange(); } weapon_count = ++weapon_count; } } ammo_slots = deployed_ent.getAmmo(); while (ammo_slots.hasMoreElements()) { Mounted mounted = (Mounted)ammo_slots.nextElement(); AmmoType atype = (AmmoType)mounted.getType(); if (atype.getAmmoType() == AmmoType.T_ATM){ weapon_count = ++weapon_count; av_range += 15.0; if (atype.getMunitionType() == AmmoType.M_HIGH_EXPLOSIVE){ av_range -= 6; } if (atype.getMunitionType() == AmmoType.M_EXTENDED_RANGE){ av_range += 12.0; } } }  av_range = av_range/weapon_count;    ideal_elev = lowest_elev + ((av_range/18) * (highest_elev - lowest_elev)); if (ideal_elev > highest_elev){ ideal_elev = highest_elev; }  best_fitness = -100.0; for (valid_arr_index = 0; valid_arr_index < counter; valid_arr_index++){     fitness[valid_arr_index] = (double) -1*(Math.abs(ideal_elev - game.getBoard().getHex(valid_array[valid_arr_index].x, valid_array[valid_arr_index].y).getElevation()));   total_damage = 0.0; deployed_ent.setPosition(valid_array[valid_arr_index]); valid_attackers = game.getValidTargets(deployed_ent); for (Enumeration i = valid_attackers.elements(); i.hasMoreElements();){ test_ent = (Entity)i.nextElement(); if (test_ent.isDeployed() == true){ weapons = test_ent.getWeaponList(); test_hit = new ToHitData(); for (Enumeration j = weapons.elements(); j.hasMoreElements();) {  Mounted mounted = (Mounted)j.nextElement(); WeaponType wtype = (WeaponType)mounted.getType();  test_attack = new WeaponAttackAction(test_ent.getId(), deployed_ent.getId(), test_ent.getEquipmentNum(mounted)); adjusted_damage = getDeployDamage(game, test_attack); total_damage += adjusted_damage; }  }  }  fitness[valid_arr_index] = fitness[valid_arr_index] - (total_damage/10);     total_damage = 0.0; weapons = deployed_ent.getWeaponList(); for (Enumeration i = weapons.elements(); i.hasMoreElements();) { Mounted mounted = (Mounted)i.nextElement(); WeaponType wtype = (WeaponType)mounted.getType(); max_damage = 0.0; for (Enumeration j = valid_attackers.elements(); j.hasMoreElements();){ test_ent = (Entity)j.nextElement(); if (test_ent.isDeployed() == true){ test_attack = new WeaponAttackAction(deployed_ent.getId(), test_ent.getId(), deployed_ent.getEquipmentNum(mounted)); adjusted_damage = getDeployDamage(game, test_attack); if (adjusted_damage > max_damage){ max_damage = adjusted_damage; } } } total_damage += max_damage; } fitness[valid_arr_index] = fitness[valid_arr_index] + (total_damage/10);    if(deployed_ent instanceof Mech){     if (game.getBoard().getHex(valid_array[valid_arr_index].x, valid_array[valid_arr_index].y).containsTerrain(Terrains.WOODS)){ fitness[valid_arr_index] += 1; } if (game.getBoard().getHex(valid_array[valid_arr_index].x, valid_array[valid_arr_index].y).containsTerrain(Terrains.WATER)){ if (game.getBoard().getHex(valid_array[valid_arr_index].x, valid_array[valid_arr_index].y).depth() > 1){ fitness[valid_arr_index] -= game.getBoard().getHex(valid_array[valid_arr_index].x, valid_array[valid_arr_index].y).depth(); } } }    if(deployed_ent instanceof Infantry){     if (game.getBoard().getHex(valid_array[valid_arr_index].x, valid_array[valid_arr_index].y).containsTerrain(Terrains.WOODS)){ fitness[valid_arr_index] += 2; } if (game.getBoard().getHex(valid_array[valid_arr_index].x, valid_array[valid_arr_index].y).containsTerrain(Terrains.BUILDING)){ fitness[valid_arr_index] += 4; } highest_hex = valid_array[valid_arr_index]; Enumeration ent_list = game.getEntities(highest_hex); while (ent_list.hasMoreElements()) { test_ent = (Entity) ent_list.nextElement(); if (deployed_ent.getOwner() == test_ent.getOwner() && !deployed_ent.equals(test_ent)) { if (test_ent instanceof Infantry){ fitness[valid_arr_index] += 2; break; } } } outer_loop: for (int x = 0; x < 6; x++) { highest_hex = valid_array[valid_arr_index]; highest_hex = highest_hex.translated(x); Enumeration adj_ents = game.getEntities(highest_hex); while (adj_ents.hasMoreElements()) { test_ent = (Entity) adj_ents.nextElement(); if (deployed_ent.getOwner() == test_ent.getOwner() && !deployed_ent.equals(test_ent)) { if (test_ent instanceof Infantry){ fitness[valid_arr_index] += 1; break outer_loop; } } } }    if (game.getBoard().getHex(valid_array[valid_arr_index].x, valid_array[valid_arr_index].y).containsTerrain(Terrains.WATER)){ fitness[valid_arr_index] -= 10; }  }  if(deployed_ent instanceof Tank){    if(deployed_ent.getMovementType() == Entity.MovementType.TRACKED){ if (game.getBoard().getHex(valid_array[valid_arr_index].x, valid_array[valid_arr_index].y).containsTerrain(Terrains.WOODS)){ fitness[valid_arr_index] += 2; } }      if(deployed_ent.getMovementType() == Entity.MovementType.HOVER){ if (game.getBoard().getHex(valid_array[valid_arr_index].x, valid_array[valid_arr_index].y).containsTerrain(Terrains.WATER)){ fitness[valid_arr_index] += 2; } }  }     if(deployed_ent instanceof Protomech){ if (game.getBoard().getHex(valid_array[valid_arr_index].x, valid_array[valid_arr_index].y).containsTerrain(Terrains.WOODS)){ fitness[valid_arr_index] += 2; } }     if (fitness[valid_arr_index] > best_fitness){ best_fitness = fitness[valid_arr_index]; } }    fitness_count2 = 0; for (valid_arr_index = 0; valid_arr_index < counter; valid_arr_index++){ if (fitness[valid_arr_index] == best_fitness){ highest_hex = valid_array[valid_arr_index]; valid_arr_index = fitness.length-1; } }  return highest_hex;
    protected Coords getStartingCoords() {        switch (getLocalPlayer().getStartingPos()) {            default :            case 0 :                return new Coords(game.getBoard().getWidth() / 2, game.getBoard().getHeight() / 2);            case 1 :                return new Coords(1, 1);            case 2 :                return new Coords(game.getBoard().getWidth() / 2, 1);            case 3 :                return new Coords(game.getBoard().getWidth() - 2, 1);            case 4 :                return new Coords(game.getBoard().getWidth() - 2, game.getBoard().getHeight() / 2);            case 5 :                return new Coords(game.getBoard().getWidth() - 2, game.getBoard().getHeight() - 2);            case 6 :                return new Coords(game.getBoard().getWidth() / 2, game.getBoard().getHeight() - 2);            case 7 :                return new Coords(1, game.getBoard().getHeight() - 2);            case 8 :                return new Coords(1, game.getBoard().getHeight() / 2);        }    }