Examples of ECState


Examples of com.fray.evo.EcState

    return score;
  }

  @Override
  public double score(EcState candidate, EcState metric) {
    EcState c = candidate;
    double score = 0;

    boolean keepgoing = true;
    EcState state = EcState.defaultDestination();
    for (EcState s : metric.waypoints)
    {
      if (keepgoing)
        state.union(s);
      if (!s.isSatisfied(c))
        keepgoing = false;
      else
        score += 500.0;
    }
    if (keepgoing)
    {
      state.union(metric);
      score = augmentScore(c, metric, score, false);
    }
    else
      score = augmentScore(c, metric, score, false);

    if (state.isSatisfied(c))
    {
     
     
      score *= 5.0;
      score += Math.min(c.supply() - c.supplyUsed,8);
View Full Code Here

Examples of com.fray.evo.EcState

public final class EcStandardFitness implements EcFitness {

  public double augmentScore(EcState current, EcState destination, double score, boolean waypoint)
  {
    EcState c = current;
    int overlordScore;
   
    if (c.getOverlords() > destination.getOverlords())
      overlordScore = (int)Math.min(100, (destination.getOverlords() * (1 / Math.max(1, destination.supply() - destination.supplyUsed))) * 10);
    else
      overlordScore = (int)Math.min(100, (c.getOverlords() * (1 / Math.max(1, c.supply() - c.supplyUsed))) * 10);

    score = augmentScore(score, c.getZerglings(), destination.getZerglings(), 25, .25, waypoint);
    score = augmentScore(score, c.getBanelings(), destination.getBanelings(), 75, .75, waypoint);
    score = augmentScore(score, c.getRoaches(), destination.getRoaches(), 100, 1.0, waypoint);
    score = augmentScore(score, c.getMutalisks(), destination.getMutalisks(), 200, 2.0, waypoint);
    score = augmentScore(score, c.getQueens(), destination.getQueens(), 150, 1.5, waypoint);
    score = augmentScore(score, c.getHydralisks(), destination.getHydralisks(), 150, 1.5, waypoint);
    score = augmentScore(score, c.getInfestors(), destination.getInfestors(), 250, 2.5, waypoint);
    score = augmentScore(score, c.getCorruptors(), destination.getCorruptors(), 250, 2.5, waypoint);
    score = augmentScore(score, c.getUltralisks(), destination.getUltralisks(), 500, 5.0, waypoint);
    score = augmentScore(score, c.getBroodlords(), destination.getBroodlords(), 400, 4.0, waypoint);
   
    score = augmentScore(score, c.getOverlords(), destination.getOverlords(), overlordScore, overlordScore / 100.0, waypoint);
   
    score = augmentScore(score, c.getOverseers(), destination.getOverseers(), 250, 2.5, waypoint);
    score = augmentScore(score, c.getGasExtractors(), destination.getGasExtractors(), 25, .25, waypoint);

    score = augmentScore(score, c.getHatcheries(), destination.getHatcheries(), 300, 3, waypoint);
    score = augmentDropoffScore(score, c.getLairs(), destination.getLairs(), 550, 5.5, waypoint);
    score = augmentDropoffScore(score, c.getHives(), destination.getHives(), 900, 9, waypoint);
    score = augmentDropoffScore(score, c.getSpawningPools(), destination.getSpawningPools(), 200, 2, waypoint);
    score = augmentDropoffScore(score, c.getRoachWarrens(), destination.getRoachWarrens(), 150, 1.5, waypoint);
    score = augmentDropoffScore(score, c.getHydraliskDen(), destination.getHydraliskDen(), 200, 2, waypoint);
    score = augmentDropoffScore(score, c.getBanelingNest(), destination.getBanelingNest(), 150, 1.5, waypoint);
    score = augmentDropoffScore(score, c.getGreaterSpire(), destination.getGreaterSpire(), 650, 6.5, waypoint);
    score = augmentDropoffScore(score, c.getUltraliskCavern(), destination.getUltraliskCavern(), 350, 3.5, waypoint);
    score = augmentDropoffScore(score, c.getSpire(), destination.getSpire(), 400, 4, waypoint);
    score = augmentDropoffScore(score, c.getInfestationPit(), destination.getInfestationPit(), 200, 2.0, waypoint);
    score = augmentDropoffScore(score, c.getEvolutionChambers(), destination.getEvolutionChambers(), 75, 0.75, waypoint);
    score = augmentScore(score, c.getSpineCrawlers(), destination.getSpineCrawlers(), 100, 1.00, waypoint);
    score = augmentScore(score, c.getSporeCrawlers(), destination.getSporeCrawlers(), 75, .75, waypoint);
    score = augmentDropoffScore(score, c.getNydusNetwork(), destination.getNydusNetwork(), 350, 3.00, waypoint);
    score = augmentScore(score, c.getNydusWorm(), destination.getNydusWorm(), 200, 2.00, waypoint);

    score = augmentScore(score, c.isMetabolicBoost(), destination.isMetabolicBoost(), 200, 2.0, waypoint);
    score = augmentScore(score, c.isAdrenalGlands(), destination.isAdrenalGlands(), 400, 4.0, waypoint);
    score = augmentScore(score, c.isGlialReconstitution(), destination.isGlialReconstitution(), 200, 2.0, waypoint);
    score = augmentScore(score, c.isTunnelingClaws(), destination.isTunnelingClaws(), 300, 3.0, waypoint);
    score = augmentScore(score, c.isBurrow(), destination.isBurrow(), 200, 2.0, waypoint);
    score = augmentScore(score, c.isPneumatizedCarapace(), destination.isPneumatizedCarapace(), 200, 2.0, waypoint);
    score = augmentScore(score, c.isVentralSacs(), destination.isVentralSacs(), 400, 4.0, waypoint);
    score = augmentScore(score, c.isCentrifugalHooks(), destination.isCentrifugalHooks(), 300, 3.0, waypoint);
    score = augmentScore(score, c.isMelee1(), destination.isMelee1(), 200, 2.0, waypoint);
    score = augmentScore(score, c.isMelee2(), destination.isMelee2(), 300, 3.0, waypoint);
    score = augmentScore(score, c.isMelee3(), destination.isMelee3(), 400, 4.0, waypoint);
    score = augmentScore(score, c.isMissile1(), destination.isMissile1(), 200, 2.0, waypoint);
    score = augmentScore(score, c.isMissile2(), destination.isMissile2(), 300, 3.0, waypoint);
    score = augmentScore(score, c.isMissile3(), destination.isMissile3(), 400, 4.0, waypoint);
    score = augmentScore(score, c.isArmor1(), destination.isArmor1(), 200, 3.0, waypoint);
    score = augmentScore(score, c.isArmor2(), destination.isArmor2(), 300, 3.0, waypoint);
    score = augmentScore(score, c.isArmor3(), destination.isArmor3(), 400, 3.0, waypoint);
    score = augmentScore(score, c.isGroovedSpines(), destination.isGroovedSpines(), 300, 3.0, waypoint);
    score = augmentScore(score, c.isNeuralParasite(), destination.isNeuralParasite(), 300, 3.0, waypoint);
    score = augmentScore(score, c.isPathogenGlands(), destination.isPathogenGlands(), 300, 3.0, waypoint);
    score = augmentScore(score, c.isFlyerAttack1(), destination.isFlyerAttack1(), 200, 2.0, waypoint);
    score = augmentScore(score, c.isFlyerAttack2(), destination.isFlyerAttack2(), 350, 3.5, waypoint);
    score = augmentScore(score, c.isFlyerAttack3(), destination.isFlyerAttack3(), 500, 5.0, waypoint);
    score = augmentScore(score, c.isFlyerArmor1(), destination.isFlyerArmor1(), 300, 3.0, waypoint);
    score = augmentScore(score, c.isFlyerArmor2(), destination.isFlyerArmor2(), 450, 4.5, waypoint);
    score = augmentScore(score, c.isFlyerArmor3(), destination.isFlyerArmor3(), 600, 6.0, waypoint);
    score = augmentScore(score, c.isChitinousPlating(), destination.isChitinousPlating(), 300, 3.0, waypoint);
    return score;
  }
View Full Code Here

Examples of com.fray.evo.EcState

    return score;
  }

  @Override
  public double score(EcState candidate, EcState metric) {
    EcState c = candidate;
    double score = 0;

    boolean keepgoing = true;
    EcState state = EcState.defaultDestination();
    for (int i = 0; i < metric.waypoints.size(); ++i)
    {
      EcState s = metric.waypoints.get(i);
      if (keepgoing)
        state.union(s);
      if (!s.isSatisfied(c))
        keepgoing = false;
    }
    if (keepgoing)
    {
      state.union(metric);
View Full Code Here

Examples of com.fray.evo.EcState

public final class EcEconFitness implements EcFitness {

  public double augmentScore(EcState current, EcState destination, double score, boolean waypoint)
  {
    EcState c = current;
   
    score = augmentCappedScore(score, c.getDrones(), destination.getDrones(), c.bases()*30, 50, 4, waypoint);
    score = augmentScore(score, c.getZerglings(), destination.getZerglings(), 25, .25, waypoint);
    score = augmentScore(score, c.getBanelings(), destination.getBanelings(), 75, .75, waypoint);
    score = augmentScore(score, c.getRoaches(), destination.getRoaches(), 100, 1.0, waypoint);
    score = augmentScore(score, c.getMutalisks(), destination.getMutalisks(), 200, 2.0, waypoint);
    score = augmentCappedScore(score, c.getQueens(), destination.getQueens(), c.bases()*2, 150, 2.5, waypoint);
    score = augmentScore(score, c.getHydralisks(), destination.getHydralisks(), 150, 1.5, waypoint);
    score = augmentScore(score, c.getInfestors(), destination.getInfestors(), 250, 2.5, waypoint);
    score = augmentScore(score, c.getCorruptors(), destination.getCorruptors(), 250, 2.5, waypoint);
    score = augmentScore(score, c.getUltralisks(), destination.getUltralisks(), 500, 5.0, waypoint);
    score = augmentScore(score, c.getBroodlords(), destination.getBroodlords(), 400, 4.0, waypoint);
    score = augmentCappedScore(score, c.getOverlords(), destination.getOverlords(), 25, 100, 1.8, waypoint);
    score = augmentScore(score, c.getOverseers(), destination.getOverseers(), 250, 2.5, waypoint);

    score = augmentScore(score, c.getGasExtractors(), destination.getGasExtractors(), 25, 1.5, waypoint);
   
   
    score = augmentDropoffScore(score, c.getHatcheries(), destination.getHatcheries(), 300, 4.5, waypoint);
    score = augmentDropoffScore(score, c.getLairs(), destination.getLairs(), 550, 5.5, waypoint);
    score = augmentDropoffScore(score, c.getHives(), destination.getHives(), 900, 9, waypoint);
    score = augmentDropoffScore(score, c.getSpawningPools(), destination.getSpawningPools(), 200, 2, waypoint);
    score = augmentDropoffScore(score, c.getRoachWarrens(), destination.getRoachWarrens(), 150, 1.5, waypoint);
    score = augmentDropoffScore(score, c.getHydraliskDen(), destination.getHydraliskDen(), 200, 2, waypoint);
    score = augmentDropoffScore(score, c.getBanelingNest(), destination.getBanelingNest(), 150, 1.5, waypoint);
    score = augmentDropoffScore(score, c.getGreaterSpire(), destination.getGreaterSpire(), 650, 6.5, waypoint);
    score = augmentDropoffScore(score, c.getUltraliskCavern(), destination.getUltraliskCavern(), 350, 3.5, waypoint);
    score = augmentDropoffScore(score, c.getSpire(), destination.getSpire(), 400, 4, waypoint);
    score = augmentDropoffScore(score, c.getInfestationPit(), destination.getInfestationPit(), 200, 2.0, waypoint);
    score = augmentDropoffScore(score, c.getEvolutionChambers(), destination.getEvolutionChambers(), 75, 0.75, waypoint);
    score = augmentScore(score, c.getSpineCrawlers(), destination.getSpineCrawlers(), 100, 1.00, waypoint);
    score = augmentScore(score, c.getSporeCrawlers(), destination.getSporeCrawlers(), 75, .75, waypoint);
    score = augmentDropoffScore(score, c.getNydusNetwork(), destination.getNydusNetwork(), 350, 3.00, waypoint);
    score = augmentScore(score, c.getNydusWorm(), destination.getNydusWorm(), 200, 2.00, waypoint);

    score = augmentScore(score, c.isMetabolicBoost(), destination.isMetabolicBoost(), 200, 2.0, waypoint);
    score = augmentScore(score, c.isAdrenalGlands(), destination.isAdrenalGlands(), 400, 4.0, waypoint);
    score = augmentScore(score, c.isGlialReconstitution(), destination.isGlialReconstitution(), 200, 2.0, waypoint);
    score = augmentScore(score, c.isTunnelingClaws(), destination.isTunnelingClaws(), 300, 3.0, waypoint);
    score = augmentScore(score, c.isBurrow(), destination.isBurrow(), 200, 2.0, waypoint);
    score = augmentScore(score, c.isPneumatizedCarapace(), destination.isPneumatizedCarapace(), 200, 2.0, waypoint);
    score = augmentScore(score, c.isVentralSacs(), destination.isVentralSacs(), 400, 4.0, waypoint);
    score = augmentScore(score, c.isCentrifugalHooks(), destination.isCentrifugalHooks(), 300, 3.0, waypoint);
    score = augmentScore(score, c.isMelee1(), destination.isMelee1(), 200, 2.0, waypoint);
    score = augmentScore(score, c.isMelee2(), destination.isMelee2(), 300, 3.0, waypoint);
    score = augmentScore(score, c.isMelee3(), destination.isMelee3(), 400, 4.0, waypoint);
    score = augmentScore(score, c.isMissile1(), destination.isMissile1(), 200, 2.0, waypoint);
    score = augmentScore(score, c.isMissile2(), destination.isMissile2(), 300, 3.0, waypoint);
    score = augmentScore(score, c.isMissile3(), destination.isMissile3(), 400, 4.0, waypoint);
    score = augmentScore(score, c.isArmor1(), destination.isArmor1(), 200, 3.0, waypoint);
    score = augmentScore(score, c.isArmor2(), destination.isArmor2(), 300, 3.0, waypoint);
    score = augmentScore(score, c.isArmor3(), destination.isArmor3(), 400, 3.0, waypoint);
    score = augmentScore(score, c.isGroovedSpines(), destination.isGroovedSpines(), 300, 3.0, waypoint);
    score = augmentScore(score, c.isNeuralParasite(), destination.isNeuralParasite(), 300, 3.0, waypoint);
    score = augmentScore(score, c.isPathogenGlands(), destination.isPathogenGlands(), 300, 3.0, waypoint);
    score = augmentScore(score, c.isFlyerAttack1(), destination.isFlyerAttack1(), 200, 2.0, waypoint);
    score = augmentScore(score, c.isFlyerAttack2(), destination.isFlyerAttack2(), 350, 3.5, waypoint);
    score = augmentScore(score, c.isFlyerAttack3(), destination.isFlyerAttack3(), 500, 5.0, waypoint);
    score = augmentScore(score, c.isFlyerArmor1(), destination.isFlyerArmor1(), 300, 3.0, waypoint);
    score = augmentScore(score, c.isFlyerArmor2(), destination.isFlyerArmor2(), 450, 4.5, waypoint);
    score = augmentScore(score, c.isFlyerArmor3(), destination.isFlyerArmor3(), 600, 6.0, waypoint);
    score = augmentScore(score, c.isChitinousPlating(), destination.isChitinousPlating(), 300, 3.0, waypoint);
    return score;
  }
View Full Code Here

Examples of com.fray.evo.EcState

    @Override
    public double score(EcState candidate, EcState metric) {
        double score = 0;

        boolean keepgoing = true;
        EcState state = EcState.defaultDestination();
        for (EcState s : metric.waypoints) {
            if (keepgoing) {
                state.union(s);
            }
            if (!s.isSatisfied(candidate)) {
                keepgoing = false;
            }
        }
        if (keepgoing) {
            state.union(metric);
        }

        score = augmentScore(candidate, state, score, false);

        if (state.isSatisfied(candidate)) {//user options satisfied
            //by setting the "too many" drone score to .58 we weigh drones higher then minerals
            score = augmentScore(score, candidate.getDrones(), state.getDrones(), 50, .58, false);
            //by setting mineral scores above 0.01, builds without required buildings/units get a higher score
            score = augmentScore(score, (int) candidate.minerals, (int) state.minerals, .011, .011, false);
            //by setting gas scores above 0.01, builds without required buildings/units get a higher score
            score = augmentScore(score, (int) candidate.gas, (int) state.gas, .015, .015, false);
            score = Math.max(score, 0);

            candidate.preTimeScore = score;
            //using targetSeconds
            score *= ((double) candidate.targetSeconds / (double) candidate.seconds) * ((double) candidate.targetSeconds / (double) candidate.seconds);
            candidate.timeBonus = score - candidate.preTimeScore;

            //System.out.println(String.format("PreTimeScore: %.2f",c.preTimeScore));
            //System.out.println(String.format("Time Bonus: %.2f",c.timeBonus));

        } else {//user options not satisfied
            double xtraDroneScore = .6;
            if (metric.settings.overDrone || metric.settings.workerParity) {
                xtraDroneScore = 2;
            }
            score = augmentScore(score, candidate.getDrones(), state.getDrones(), 50, xtraDroneScore, false);
            score = augmentScore(score, (int) candidate.minerals, (int) state.minerals, .001, .001, false);
            score = augmentScore(score, (int) candidate.gas, (int) state.gas, .0012, .0012, false);
            score = Math.max(score - candidate.invalidActions, 0);
        }
        // score = Math.max(score - candidate.invalidActions -
View Full Code Here

Examples of com.fray.evo.EcState

    BufferedReader in = null;
    List<String> unknownKeywords = new ArrayList<String>();
    try {
      in = new BufferedReader(reader);
      String line;
      EcState curWaypoint = null;
      boolean inSettingsBlock = false;
      while ((line = in.readLine()) != null) {
        //remove comments
        int hash = line.indexOf('#');
        if (hash >= 0){
          line = line.substring(0, hash);
        }
       
        line = line.trim();
        if (line.length() == 0) {
          continue;
        }

        String split[] = line.split("\\s+");
        String word = split[0];
        String value = split.length > 1 ? split[1] : null;
        if (word.equals("scout-timing")) {
          scoutTiming = parseTime(value);
        } else if (word.equals("settings")) {
          if (settings == null){
            settings = new EcSettings();
           
            //set boolean values to false because they must be included in the settings block in order for them to be set to true
            settings.avoidMiningGas = false;
            settings.pullThreeWorkersOnly = false;
            settings.pullWorkersFromGas = false;
            settings.useExtractorTrick = false;
            settings.overDrone = false;
            settings.workerParity = false;
          }
          inSettingsBlock = true;
        } else if (word.equals("waypoint")) {
          inSettingsBlock = false;
          if (curWaypoint != null) {
            waypoints.add(curWaypoint);
          }
          curWaypoint = EcState.defaultDestination();
          curWaypoint.targetSeconds = parseTime(value);
        } else if (!inSettingsBlock && buildables.containsKey(word)) {
          Buildable b = buildables.get(word)[0];
          if (b instanceof Unit) {
            int num = value == null ? 1 : Integer.parseInt(value);
            curWaypoint.setUnits((Unit) b, num);
          } else if (b instanceof Building) {
            int num = value == null ? 1 : Integer.parseInt(value);
            curWaypoint.setBuilding((Building) b, num);
          } else if (b instanceof Upgrade) {
            int num = value == null ? 0 : Integer.parseInt(value) - 1;
            curWaypoint.addUpgrade((Upgrade) buildables.get(word)[num]);
          }
        } else if (inSettingsBlock) {
          boolean validKeyword = processSetting(settings, word, value);
          if (!validKeyword){
            unknownKeywords.add(word);
View Full Code Here

Examples of com.fray.evo.EcState

      public int compare(EcState arg0, EcState arg1) {
        return arg0.targetSeconds - arg1.targetSeconds;
      }
    });
   
    EcState destination;
    if (waypoints.size() > 0){
      destination = waypoints.get(waypoints.size()-1);
      destination.waypoints = new ArrayList<EcState>(waypoints.subList(0, waypoints.size()-1));
    } else {
      destination = EcState.defaultDestination();
View Full Code Here

Examples of com.fray.evo.EcState

   */
  @Test
  public void testNoWaypoints() throws Exception {
    StringReader sr = new StringReader("");
    InputFile file = new InputFile(sr);
    EcState destination = file.getDestination();
    Assert.assertTrue(destination.waypoints.isEmpty());
    Assert.assertEquals(1, destination.getEstimatedActions());
  }
View Full Code Here

Examples of com.fray.evo.EcState

   */
  @Test
  public void testParsing() throws Exception {
    StringReader sr = new StringReader("scout-timing\t  2:12");
    InputFile file = new InputFile(sr);
    EcState destination = file.getDestination();
    Assert.assertEquals(132, destination.scoutDrone);
  }
View Full Code Here

Examples of com.fray.evo.EcState

   */
  @Test
  public void testComments() throws Exception {
    StringReader sr = new StringReader("waypoint 3:00\n#mutalisk 10\nzergling 6");
    InputFile file = new InputFile(sr);
    EcState destination = file.getDestination();
    Assert.assertEquals(0, destination.getMutalisks());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.