Changeset 13311 for trunk/sources
- Timestamp:
- 11/19/15 20:53:11 (9 years ago)
- 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 227 227 228 228 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; 235 232 } 236 233 237 234 private static string InterpretBoolValue(ISymbolicExpressionTreeNode node) { 238 var boolNode = node as BooleanTreeNode;235 var boolNode = (BooleanTreeNode)node; 239 236 return string.Format(NumberFormatInfo.InvariantInfo, "{0}", boolNode.Value).ToLower(); 240 237 } 241 238 242 239 private static string InterpretNumber(ISymbolicExpressionTreeNode node) { 243 var numberNode = node as NumberTreeNode;240 var numberNode = (NumberTreeNode)node; 244 241 return string.Format(NumberFormatInfo.InvariantInfo, "{0}", numberNode.Value); 245 242 } 246 243 247 244 private static string InterpetShotPower(ISymbolicExpressionTreeNode node) { 248 var shotPowerNode = node as ShotPowerTreeNode;245 var shotPowerNode = (ShotPowerTreeNode)node; 249 246 return string.Format(NumberFormatInfo.InvariantInfo, "{0:E}", shotPowerNode.Value); 250 247 } … … 311 308 rhs = node.GetSubtree(1); 312 309 313 return Interpret(lhs) + " == "+ Interpret(rhs);310 return Interpret(lhs) + compSy + Interpret(rhs); 314 311 } 315 312 -
trunk/sources/HeuristicLab.Problems.GeneticProgramming/3.3/robocode/Symbols/ShotPowerTreeNode.cs
r13210 r13311 61 61 // mutation 62 62 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; 64 66 } 65 67 }
Note: See TracChangeset
for help on using the changeset viewer.