Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13311 for trunk/sources


Ignore:
Timestamp:
11/19/15 20:53:11 (9 years ago)
Author:
mkommend
Message:

#2069: Minor code changes in interpreter, restricted ShotPowerTreeNode to [0.1,3], changed evaluation of InterpretComparison.

Location:
trunk/sources/HeuristicLab.Problems.GeneticProgramming/3.3/robocode
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.GeneticProgramming/3.3/robocode/Interpreter.cs

    r13309 r13311  
    227227
    228228    private static string InterpretCodeSymbol(ISymbolicExpressionTreeNode node) {
    229       var sy = node.Symbol as CodeSymbol;
    230       string code = string.Join(Environment.NewLine, node.Subtrees.Select(Interpret));
    231       return string.Format(
    232 @"{0}
    233 {1}
    234 {2}", sy.Prefix, code, sy.Suffix);
     229      var sy = (CodeSymbol)node.Symbol;
     230      string code = string.Join(Environment.NewLine, node.Subtrees.Select(Interpret));
     231      return sy.Prefix + Environment.NewLine + code + Environment.NewLine + sy.Suffix;
    235232    }
    236233
    237234    private static string InterpretBoolValue(ISymbolicExpressionTreeNode node) {
    238       var boolNode = node as BooleanTreeNode;
     235      var boolNode = (BooleanTreeNode)node;
    239236      return string.Format(NumberFormatInfo.InvariantInfo, "{0}", boolNode.Value).ToLower();
    240237    }
    241238
    242239    private static string InterpretNumber(ISymbolicExpressionTreeNode node) {
    243       var numberNode = node as NumberTreeNode;
     240      var numberNode = (NumberTreeNode)node;
    244241      return string.Format(NumberFormatInfo.InvariantInfo, "{0}", numberNode.Value);
    245242    }
    246243
    247244    private static string InterpetShotPower(ISymbolicExpressionTreeNode node) {
    248       var shotPowerNode = node as ShotPowerTreeNode;
     245      var shotPowerNode = (ShotPowerTreeNode)node;
    249246      return string.Format(NumberFormatInfo.InvariantInfo, "{0:E}", shotPowerNode.Value);
    250247    }
     
    311308      rhs = node.GetSubtree(1);
    312309
    313       return Interpret(lhs) + " == " + Interpret(rhs);
     310      return Interpret(lhs) + compSy + Interpret(rhs);
    314311    }
    315312
  • trunk/sources/HeuristicLab.Problems.GeneticProgramming/3.3/robocode/Symbols/ShotPowerTreeNode.cs

    r13210 r13311  
    6161      // mutation
    6262      var d = random.NextDouble() * 2.0 - 1.0;
    63       value = Math.Max(0.1, value + shakingFactor * d);
     63      value += shakingFactor * d;
     64      if (value < 0.1) value = 0.1;
     65      if (value > 3) value = 3;
    6466    }
    6567  }
Note: See TracChangeset for help on using the changeset viewer.